mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-11 02:28:18 +00:00
0df6d0541f
Conflicts: bam.lua src/engine/console.h src/engine/server.h src/engine/server/server.cpp src/engine/shared/config.h src/engine/shared/config_variables.h src/engine/shared/console.cpp src/engine/shared/console.h src/game/client/components/binds.cpp src/game/client/components/chat.h src/game/client/components/console.cpp src/game/client/components/console.h src/game/client/components/controls.cpp src/game/client/components/emoticon.h src/game/client/components/maplayers.cpp src/game/client/components/menus.h src/game/client/components/scoreboard.h src/game/client/components/spectator.h src/game/client/components/voting.h src/game/client/gameclient.cpp src/game/client/gameclient.h src/game/client/render.h src/game/collision.cpp src/game/editor/ed_layer_tiles.cpp src/game/gamecore.cpp src/game/gamecore.h src/game/layers.cpp src/game/layers.h src/game/mapitems.h src/game/server/entities/character.cpp src/game/server/entities/laser.cpp src/game/server/entities/laser.h src/game/server/entities/pickup.cpp src/game/server/entities/pickup.h src/game/server/entities/projectile.cpp src/game/server/gamecontext.cpp src/game/server/gamecontroller.cpp src/game/server/gamecontroller.h src/game/server/gameworld.cpp src/game/server/gameworld.h src/game/server/player.cpp src/game/variables.h
173 lines
4.1 KiB
C++
173 lines
4.1 KiB
C++
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
|
#ifndef GAME_SERVER_GAMEWORLD_H
|
|
#define GAME_SERVER_GAMEWORLD_H
|
|
|
|
#include <game/gamecore.h>
|
|
|
|
#include <list>
|
|
|
|
class CEntity;
|
|
class CCharacter;
|
|
|
|
/*
|
|
Class: Game World
|
|
Tracks all entities in the game. Propagates tick and
|
|
snap calls to all entities.
|
|
*/
|
|
class CGameWorld
|
|
{
|
|
public:
|
|
enum
|
|
{
|
|
ENTTYPE_PROJECTILE = 0,
|
|
ENTTYPE_LASER,
|
|
ENTTYPE_PICKUP,
|
|
ENTTYPE_FLAG,
|
|
ENTTYPE_CHARACTER,
|
|
NUM_ENTTYPES
|
|
};
|
|
|
|
private:
|
|
void Reset();
|
|
void RemoveEntities();
|
|
|
|
CEntity *m_pNextTraverseEntity;
|
|
CEntity *m_apFirstEntityTypes[NUM_ENTTYPES];
|
|
|
|
class CGameContext *m_pGameServer;
|
|
class IServer *m_pServer;
|
|
|
|
public:
|
|
class CGameContext *GameServer() { return m_pGameServer; }
|
|
class IServer *Server() { return m_pServer; }
|
|
|
|
bool m_ResetRequested;
|
|
bool m_Paused;
|
|
CWorldCore m_Core;
|
|
|
|
CGameWorld();
|
|
~CGameWorld();
|
|
|
|
void SetGameServer(CGameContext *pGameServer);
|
|
|
|
CEntity *FindFirst(int Type);
|
|
|
|
/*
|
|
Function: find_entities
|
|
Finds entities close to a position and returns them in a list.
|
|
|
|
Arguments:
|
|
pos - Position.
|
|
radius - How close the entities have to be.
|
|
ents - Pointer to a list that should be filled with the pointers
|
|
to the entities.
|
|
max - Number of entities that fits into the ents array.
|
|
type - Type of the entities to find.
|
|
|
|
Returns:
|
|
Number of entities found and added to the ents array.
|
|
*/
|
|
int FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, int Type);
|
|
|
|
/*
|
|
Function: InterserctCharacters
|
|
Finds the CCharacters that intersects the line. // made for types lasers=1 and doors=0
|
|
|
|
Arguments:
|
|
pos0 - Start position
|
|
pos2 - End position
|
|
radius - How for from the line the CCharacter is allowed to be.
|
|
new_pos - Intersection position
|
|
notthis - Entity to ignore intersecting with
|
|
|
|
Returns:
|
|
Returns a pointer to the closest hit or NULL of there is no intersection.
|
|
*/
|
|
//class CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis = 0);
|
|
class CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CCharacter *pNotThis = 0, int CollideWith = -1, class CCharacter *pThisOnly = 0);
|
|
/*
|
|
Function: closest_CCharacter
|
|
Finds the closest CCharacter to a specific point.
|
|
|
|
Arguments:
|
|
pos - The center position.
|
|
radius - How far off the CCharacter is allowed to be
|
|
notthis - Entity to ignore
|
|
|
|
Returns:
|
|
Returns a pointer to the closest CCharacter or NULL if no CCharacter is close enough.
|
|
*/
|
|
class CCharacter *ClosestCharacter(vec2 Pos, float Radius, CEntity *ppNotThis);
|
|
|
|
/*
|
|
Function: insert_entity
|
|
Adds an entity to the world.
|
|
|
|
Arguments:
|
|
entity - Entity to add
|
|
*/
|
|
void InsertEntity(CEntity *pEntity);
|
|
|
|
/*
|
|
Function: remove_entity
|
|
Removes an entity from the world.
|
|
|
|
Arguments:
|
|
entity - Entity to remove
|
|
*/
|
|
void RemoveEntity(CEntity *pEntity);
|
|
|
|
/*
|
|
Function: destroy_entity
|
|
Destroys an entity in the world.
|
|
|
|
Arguments:
|
|
entity - Entity to destroy
|
|
*/
|
|
void DestroyEntity(CEntity *pEntity);
|
|
|
|
/*
|
|
Function: snap
|
|
Calls snap on all the entities in the world to create
|
|
the snapshot.
|
|
|
|
Arguments:
|
|
snapping_client - ID of the client which snapshot
|
|
is being created.
|
|
*/
|
|
void Snap(int SnappingClient);
|
|
|
|
/*
|
|
Function: tick
|
|
Calls tick on all the entities in the world to progress
|
|
the world to the next tick.
|
|
|
|
*/
|
|
void Tick();
|
|
|
|
// DDRace
|
|
|
|
std::list<class CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis);
|
|
void ReleaseHooked(int ClientID);
|
|
|
|
|
|
/*
|
|
Function: interserct_CCharacters
|
|
Finds all CCharacters that intersect the line.
|
|
|
|
Arguments:
|
|
pos0 - Start position
|
|
pos2 - End position
|
|
radius - How for from the line the CCharacter is allowed to be.
|
|
new_pos - Intersection position
|
|
notthis - Entity to ignore intersecting with
|
|
|
|
Returns:
|
|
Returns list with all Characters on line.
|
|
*/
|
|
std::list<class CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis = 0);
|
|
};
|
|
|
|
#endif
|