18 #include "precompiled.h"
44 #define DEBUG_RANGE_MANAGER_BOUNDS 0
69 if (owner >= -1 && owner < 31)
70 return 1 << (1+owner);
80 if (player > 0 && player <= 16)
91 for (
size_t i = 0; i < players.size(); i++)
110 i64 d2 = (xx + zz) >> 1;
158 serialize.Bool(
"enabled", value.
enabled);
159 serialize.Bool(
"parabolic",value.
parabolic);
160 serialize.NumberFixed_Unbounded(
"min range", value.
minRange);
161 serialize.NumberFixed_Unbounded(
"max range", value.
maxRange);
162 serialize.NumberFixed_Unbounded(
"elevation bonus", value.
elevationBonus);
163 serialize.NumberU32_Unbounded(
"owners mask", value.
ownersMask);
164 serialize.NumberI32_Unbounded(
"interface", value.
interface);
166 serialize.NumberU8_Unbounded(
"flagsMask", value.
flagsMask);
171 Common(serialize, name, value);
179 Common(deserialize, name, value);
197 serialize.NumberFixed_Unbounded(
"x", value.
x);
198 serialize.NumberFixed_Unbounded(
"z", value.
z);
199 serialize.NumberFixed_Unbounded(
"vision", value.
visionRange);
200 serialize.NumberU8(
"retain in fog", value.
retainInFog, 0, 1);
201 serialize.NumberI8_Unbounded(
"owner", value.
owner);
202 serialize.NumberU8(
"in world", value.
inWorld, 0, 1);
203 serialize.NumberU8_Unbounded(
"flags", value.
flags);
311 return "<a:component type='system'/><empty/>";
348 serialize.NumberFixed_Unbounded(
"world x0",
m_WorldX0);
349 serialize.NumberFixed_Unbounded(
"world z0",
m_WorldZ0);
350 serialize.NumberFixed_Unbounded(
"world x1",
m_WorldX1);
351 serialize.NumberFixed_Unbounded(
"world z1",
m_WorldZ1);
353 serialize.NumberU32_Unbounded(
"query next",
m_QueryNext);
433 if (it->second.inWorld)
438 LosMove(it->second.owner, it->second.visionRange, from, to);
444 LosAdd(it->second.owner, it->second.visionRange, to);
447 it->second.inWorld = 1;
448 it->second.x = msgData.
x;
449 it->second.z = msgData.
z;
453 if (it->second.inWorld)
457 LosRemove(it->second.owner, it->second.visionRange, from);
460 it->second.inWorld = 0;
478 if (it->second.inWorld)
481 LosRemove(it->second.owner, it->second.visionRange, pos);
482 LosAdd(msgData.
to, it->second.visionRange, pos);
485 ENSURE(-128 <= msgData.
to && msgData.
to <= 127);
486 it->second.owner = (
i8)msgData.
to;
501 if (it->second.inWorld)
506 ENSURE(it->second.owner == -1);
533 if (it->second.inWorld)
534 LosRemove(it->second.owner, oldRange, pos);
536 it->second.visionRange = newRange;
538 if (it->second.inWorld)
539 LosAdd(it->second.owner, newRange, pos);
587 for (
size_t i = 0; i < oldPlayerCounts.size(); ++i)
590 for (
size_t j = 0; j < oldPlayerCounts[i].size(); ++j)
644 if (it->second.inWorld)
670 if (it->second.inWorld)
677 std::vector<int> owners,
int requiredInterface,
u8 flags)
687 std::vector<int> owners,
int requiredInterface,
u8 flags)
699 LOGERROR(L
"CCmpRangeManager: DestroyActiveQuery called with invalid tag %u", tag);
708 std::map<tag_t, Query>::iterator it =
m_Queries.find(tag);
711 LOGERROR(L
"CCmpRangeManager: EnableActiveQuery called with invalid tag %u", tag);
715 Query& q = it->second;
721 std::map<tag_t, Query>::iterator it =
m_Queries.find(tag);
724 LOGERROR(L
"CCmpRangeManager: DisableActiveQuery called with invalid tag %u", tag);
728 Query& q = it->second;
734 std::vector<int> owners,
int requiredInterface)
740 std::vector<entity_id_t> r;
743 if (!cmpSourcePosition || !cmpSourcePosition->
IsInWorld())
762 std::vector<entity_id_t> r;
764 std::map<tag_t, Query>::iterator it =
m_Queries.find(tag);
767 LOGERROR(L
"CCmpRangeManager: ResetActiveQuery called with invalid tag %u", tag);
771 Query& q = it->second;
775 if (!cmpSourcePosition || !cmpSourcePosition->
IsInWorld())
795 std::vector<entity_id_t> entities;
803 entities.push_back(it->first);
826 std::vector<std::pair<entity_id_t, CMessageRangeUpdate> > messages;
827 std::vector<entity_id_t> results;
828 std::vector<entity_id_t> added;
829 std::vector<entity_id_t> removed;
831 for (std::map<tag_t, Query>::iterator it =
m_Queries.begin(); it !=
m_Queries.end(); ++it)
833 Query& query = it->second;
839 if (!cmpSourcePosition || !cmpSourcePosition->
IsInWorld())
851 std::set_difference(results.begin(), results.end(), query.
lastMatch.begin(), query.
lastMatch.end(),
852 std::back_inserter(added));
853 std::set_difference(query.
lastMatch.begin(), query.
lastMatch.end(), results.begin(), results.end(),
854 std::back_inserter(removed));
855 if (added.empty() && removed.empty())
860 messages.resize(messages.size() + 1);
861 std::pair<entity_id_t, CMessageRangeUpdate>& back = messages.back();
863 back.second.tag = it->first;
864 back.second.added.swap(added);
865 back.second.removed.swap(removed);
866 it->second.lastMatch.swap(results);
870 for (
size_t i = 0; i < messages.size(); ++i)
871 cmpMgr.
PostMessage(messages[i].first, messages[i].second);
908 if (!cmpSourcePosition || !cmpSourcePosition->
IsInWorld())
920 r.push_back(it->first);
933 for (
int i = 0; i < ents.
size(); ++i)
942 if (!cmpSecondPosition || !cmpSecondPosition->
IsInWorld())
960 r.push_back(it->first);
970 for (
int i = 0; i < ents.
size(); ++i)
990 r.push_back(it->first);
1000 pos.
Y += elevationBonus;
1006 int numberOfSteps = 16;
1011 std::vector<entity_pos_t> coords =
getParabolicRangeForm(pos, range, range*2, minAngle, maxAngle, numberOfSteps);
1015 for (
int i = 0; i < numberOfSteps; i++)
1030 std::vector<entity_pos_t> r;
1036 entity_pos_t thisHeight = pos.
Y > waterLevel ? pos.
Y : waterLevel;
1040 for (
int i = 0; i < numberOfSteps; i++)
1042 entity_pos_t angle = minAngle + (maxAngle - minAngle) / numberOfSteps * i;
1053 targetHeight = targetHeight > waterLevel ? targetHeight : waterLevel;
1057 r.push_back(maxVector.
X);
1058 r.push_back(maxVector.
Y);
1063 while ((maxVector - minVector).CompareLength(precision) > 0)
1072 targetHeight = targetHeight > waterLevel ? targetHeight : waterLevel;
1077 minVector = newVector;
1078 minDistance = newDistance;
1083 maxVector = newVector;
1084 maxDistance = newDistance;
1088 r.push_back(maxVector.
X);
1089 r.push_back(maxVector.
Y);
1102 const std::vector<int>& owners,
int requiredInterface,
u8 flagsMask)
1106 LOGWARNING(L
"CCmpRangeManager: Invalid min range %f in query for entity %u", minRange.
ToDouble(), source);
1110 LOGWARNING(L
"CCmpRangeManager: Invalid max range %f in query for entity %u", maxRange.
ToDouble(), source);
1121 for (
size_t i = 0; i < owners.size(); ++i)
1132 const std::vector<int>& owners,
int requiredInterface,
u8 flagsMask)
1145 static CColor disabledRingColour(1, 0, 0, 1);
1146 static CColor enabledRingColour(0, 1, 0, 1);
1147 static CColor subdivColour(0, 0, 1, 1);
1148 static CColor rayColour(1, 1, 0, 0.2f);
1154 for (std::map<tag_t, Query>::iterator it =
m_Queries.begin(); it !=
m_Queries.end(); ++it)
1156 Query& q = it->second;
1159 if (!cmpSourcePosition || !cmpSourcePosition->
IsInWorld())
1176 std::vector<entity_pos_t> coords;
1213 CColor thiscolor = q.
enabled ? enabledRingColour : disabledRingColour;
1216 for (
size_t i = 3; i < coords.size(); i += 2)
1218 std::vector<float> c;
1219 c.push_back((coords[i-3]+pos.
X).ToFloat());
1220 c.push_back((coords[i-2]+pos.
Z).ToFloat());
1221 c.push_back((coords[i-1]+pos.
X).ToFloat());
1222 c.push_back((coords[i]+pos.
Z).ToFloat());
1236 for (
size_t i = 0; i < q.
lastMatch.size(); ++i)
1239 if (!cmpTargetPosition || !cmpTargetPosition->
IsInWorld())
1243 std::vector<float> coords;
1246 coords.push_back(targetPos.
X.
ToFloat());
1247 coords.push_back(targetPos.
Y.
ToFloat());
1259 for (
int x = 0; x < width; ++x)
1261 for (
int y = 0; y < height; ++y)
1266 float xpos = x*divSize + divSize/2;
1267 float zpos = y*divSize + divSize/2;
1282 if (identifier ==
"normal")
1284 if (identifier ==
"injured")
1287 LOGWARNING(L
"CCmpRangeManager: Invalid flag identifier %hs", identifier.c_str());
1304 LOGWARNING(L
"CCmpRangeManager: Invalid flag identifier %hs for entity %u", identifier.c_str(), ent);
1309 it->second.flags |= flag;
1311 it->second.flags &= ~flag;
1334 if (!cmpPosition || !cmpPosition->
IsInWorld())
1361 if (forceRetainInFog || (cmpVision && cmpVision->
GetRetainInFog()))
1383 std::map<player_id_t, bool>::const_iterator it;
1417 std::map<player_id_t, u32>::const_iterator it =
m_SharedLosMasks.find(player);
1435 for (
u16 j = 0; j < grid.
m_H; ++j)
1437 for (
u16 i = 0; i < grid.
m_W; ++i)
1476 return (dist2 >= r*r);
1498 for (
i32 idx = idx0; idx <= idx1; ++idx)
1501 if (counts[idx] == 0)
1503 i32 i = i0 + idx - idx0;
1511 ASSERT(counts[idx] < 65535);
1512 counts[idx] = (
u16)(counts[idx] + 1);
1526 for (
i32 idx = idx0; idx <= idx1; ++idx)
1529 counts[idx] = (
u16)(counts[idx] - 1);
1532 if (counts[idx] == 0)
1545 template<
bool adding>
1559 u16* countsData = &counts[0];
1574 i32 j0clamp = std::max(j0, 1);
1575 i32 j1clamp = std::min(j1, m_TerrainVerticesPerSide-2);
1591 for (
i32 j = j0clamp; j <= j1clamp; ++j)
1609 #if DEBUG_RANGE_MANAGER_BOUNDS
1621 i32 i0clamp = std::max(i0, 1);
1622 i32 i1clamp = std::min(i1, m_TerrainVerticesPerSide-2);
1640 PROFILE(
"LosUpdateHelperIncremental");
1648 u16* countsData = &counts[0];
1661 i32 j0clamp = std::max(std::min(j0_from, j0_to), 1);
1662 i32 j1clamp = std::min(std::max(j1_from, j1_to), m_TerrainVerticesPerSide-2);
1676 i32 i0_from = xfloor_from;
1677 i32 i1_from = xceil_from;
1678 i32 i0_to = xfloor_to;
1679 i32 i1_to = xceil_to;
1681 for (
i32 j = j0clamp; j <= j1clamp; ++j)
1705 #if DEBUG_RANGE_MANAGER_BOUNDS
1706 if (i0_from <= i1_from)
1723 if (!(i0_to == i0_from && i1_to == i1_from))
1725 i32 i0clamp_from = std::max(i0_from, 1);
1726 i32 i1clamp_from = std::min(i1_from, m_TerrainVerticesPerSide-2);
1727 i32 i0clamp_to = std::max(i0_to, 1);
1728 i32 i1clamp_to = std::min(i1_to, m_TerrainVerticesPerSide-2);
1732 if (i1clamp_from < i0clamp_from)
1736 else if (i1clamp_to < i0clamp_to)
1765 LosUpdateHelper<true>((
u8)owner, visionRange, pos);
1773 LosUpdateHelper<false>((
u8)owner, visionRange, pos);
1781 if ((from - to).CompareLength(visionRange) > 0)
1785 LosUpdateHelper<false>((
u8)owner, visionRange, from);
1786 LosUpdateHelper<true>((
u8)owner, visionRange, to);
int CompareLength(fixed cmp) const
Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument.
An entity initialisation parameter node.
void SubscribeToMessageType(MessageTypeId mtid)
Subscribe the current component type to the given message type.
void RenderSubmit(SceneCollector &collector)
u32 m_TotalInworldVertices
A simple fixed-point number class.
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z)=0
std::vector< u32 > m_LosState
uint32_t GetWidth() const
void operator()(ISerializer &serialize, const char *name, Query &value, const CSimContext &context)
virtual void SetBounds(entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, ssize_t vertices)
Set the bounds of the world.
virtual entity_pos_t GetWaterLevel(entity_pos_t x, entity_pos_t z)=0
Get the current water level at the given point.
#define REGISTER_COMPONENT_TYPE(cname)
virtual void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize)
This is sent immediately after a new entity's components have all been created and initialised...
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
#define FIXED_MUL_I64_I32_I32(a, b)
Line-based overlay, with world-space coordinates, rendered in the world potentially behind other obje...
Sent by CCmpVision when an entity's vision range changes.
void LosUpdateHelperIncremental(u8 owner, entity_pos_t visionRange, CFixedVector2D from, CFixedVector2D to)
Update the LOS state of tiles within a given circular range, by removing visibility around the 'from'...
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
void insert(const key_type key, const mapped_type &value)
void GetNear(SpatialQueryArray &out, CFixedVector2D pos, entity_pos_t range)
Returns a sorted list of unique items that includes all items within the given circular distance of t...
void Remove(uint32_t item, CFixedVector2D fromMin, CFixedVector2D fromMax)
Remove an item with the given 'from' size.
virtual void SetSharedLos(player_id_t player, std::vector< player_id_t > players)
Sets shared LOS data for player to the given list of players.
void LosRemoveStripHelper(u8 owner, i32 i0, i32 i1, i32 j, u16 *counts)
Update the LOS state of tiles within a given horizontal strip (i0,j) to (i1,j) (inclusive).
void Reset(entity_pos_t maxX, entity_pos_t maxZ, entity_pos_t divisionSize)
#define ENTITY_IS_LOCAL(id)
void ResetDerivedData(bool skipLosState)
void operator()(IDeserializer &deserialize, const char *name, Query &value, const CSimContext &context)
EntityDistanceOrdering(const EntityMap< EntityData > &entities, const CFixedVector2D &source)
Serialization interface; see serialization overview.
IComponent * QueryInterface(entity_id_t ent, InterfaceId iid) const
Add renderable objects to the scene collector.
uint32_t GetHeight() const
Object wrapping an entity_id_t, with a SEntityComponentCache to support fast QueryInterface() / CmpPt...
iterator find(const entity_id_t key)
virtual std::vector< entity_id_t > ResetActiveQuery(tag_t tag)
Immediately execute a query, and re-enable it if disabled.
virtual void NumberU32_Unbounded(const char *name, uint32_t &out)
virtual tag_t CreateActiveQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, std::vector< int > owners, int requiredInterface, u8 flags)
Construct an active query.
Provides efficient range-based queries of the game world, and also LOS-based effects (fog of war)...
virtual const Grid< u8 > & GetTerritoryGrid()=0
For each tile, the TERRITORY_PLAYER_MASK bits are player ID; TERRITORY_CONNECTED_MASK is set if the t...
Representation of an entity, with the data needed for queries.
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
T GetInternalValue() const
virtual void Init(const CParamNode ¶mNode)
virtual bool NeedUpdate(size_t *dirtyID)=0
Serialization helper template for Query.
Contains pointers to various 'global' objects that are needed by the simulation code, to allow easy access without using real (evil) global variables.
virtual void SetEntityFlag(entity_id_t ent, std::string identifier, bool value)
Set the flag specified by the identifier to the supplied value for the entity.
std::vector< u32 > m_LosStateRevealed
virtual bool IsInWorld()=0
Returns true if the entity currently exists at a defined position in the world.
const EntityMap< EntityData > & m_EntityData
entity_pos_t elevationBonus
void PerformQuery(const Query &q, std::vector< entity_id_t > &r)
Returns a list of distinct entity IDs that match the given query, sorted by ID.
static const player_id_t MAX_LOS_PLAYER_ID
std::vector< entity_pos_t > outline
std::vector< u32 > m_ExploredVertices
virtual std::vector< entity_id_t > GetEntitiesByPlayer(player_id_t player)
Returns list of all entities for specific player.
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
This interface accepts renderable objects.
void UpdateTerritoriesLos()
CEntityHandle LookupEntityHandle(entity_id_t ent, bool allowCreate=false)
Returns a CEntityHandle with id ent.
void LosUpdateHelper(u8 owner, entity_pos_t visionRange, CFixedVector2D pos)
Update the LOS state of tiles within a given circular range, either adding or removing visibility dep...
static bool InParabolicRange(CFixedVector3D v, fixed range)
Checks whether v is in a parabolic range of (0,0,0) The highest point of the paraboloid is (0...
Range manager implementation.
virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player, bool forceRetainInFog)
Query ConstructParabolicQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t elevationBonus, const std::vector< int > &owners, int requiredInterface, u8 flagsMask)
virtual bool GetRetainInFog()=0
virtual bool GetLosRevealAll(player_id_t player)
Returns whether the whole map has been made visible to the given player.
std::map< player_id_t, u32 > m_SharedLosMasks
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
void ConstructCircleOnGround(const CSimContext &context, float x, float z, float radius, SOverlayLine &overlay, bool floating, float heightOffset=0.25f)
Constructs overlay line as a circle with given center and radius, conforming to terrain.
std::map< tag_t, Query > m_Queries
virtual int GetType() const =0
EntityDistanceOrdering & operator=(const EntityDistanceOrdering &)
void LosAddStripHelper(u8 owner, i32 i0, i32 i1, i32 j, u16 *counts)
Update the LOS state of tiles within a given horizontal strip (i0,j) to (i1,j) (inclusive).
virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player, bool forceRetainInFog)
Returns the visibility status of the given entity, with respect to the given player.
void ConstructLineOnGround(const CSimContext &context, const std::vector< float > &xz, SOverlayLine &overlay, bool floating, float heightOffset=0.25f)
Constructs overlay line from given points, conforming to terrain.
static std::map< entity_id_t, EntityParabolicRangeOutline > ParabolicRangesOutlines
bool operator()(entity_id_t a, entity_id_t b)
virtual void Verify()
Perform some internal consistency checks for testing/debugging.
virtual std::vector< entity_id_t > ExecuteQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, std::vector< int > owners, int requiredInterface)
Execute a passive query.
This is sent immediately before a destroyed entity is flushed and really destroyed.
static u32 CalcOwnerMask(player_id_t owner)
Convert an owner ID (-1 = unowned, 0 = gaia, 1..30 = players) into a 32-bit mask for quick set-member...
virtual CLosQuerier GetLosQuerier(player_id_t player)
Returns a CLosQuerier for checking whether vertex positions are visible to the given player (or other...
static u32 CalcPlayerLosMask(player_id_t player)
Returns LOS mask for given player.
float ToFloat() const
Convert to float. May be lossy - float can't represent all values.
virtual u32 GetSharedLosMask(player_id_t player)
Returns shared LOS mask for player.
virtual CFixedVector2D GetPosition2D()=0
Returns the current x,z position (no interpolation).
std::vector< SOverlayLine > m_DebugOverlayLines
void Common(S &serialize, const char *name, Query &value)
virtual entity_pos_t GetElevationAdaptedRange(CFixedVector3D pos, CFixedVector3D rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle)
Get the average elevation over 8 points on distance range around the entity.
void ResetSubdivisions(entity_pos_t x1, entity_pos_t z1)
entity_id_t GetId() const
static u32 CalcSharedLosMask(std::vector< player_id_t > players)
Returns shared LOS mask for given list of players.
#define DEFAULT_COMPONENT_ALLOCATOR(cname)
const CSimContext & GetSimContext() const
void LosMove(player_id_t owner, entity_pos_t visionRange, CFixedVector2D from, CFixedVector2D to)
void SubscribeGloballyToMessageType(MessageTypeId mtid)
Subscribe the current component type to all messages of the given message type.
virtual void EnableActiveQuery(tag_t tag)
Re-enable the processing of a query.
void SerializeCommon(S &serialize)
void NumberU32_Unbounded(const char *name, uint32_t value)
Serialize a number.
virtual u8 GetEntityFlagMask(std::string identifier)
Returns the mask for the specified identifier.
double ToDouble() const
Convert to double. Won't be lossy - double can precisely represent all values.
A simplified syntax for accessing entity components.
virtual entity_pos_t GetRange()=0
virtual void SetLosCircular(bool enabled)
Set the LOS to be restricted to a circular map.
CEntityHandle GetSystemEntity() const
static CFixed FromInt(int n)
bool LosIsOffWorld(ssize_t i, ssize_t j)
Returns whether the given vertex is outside the normal bounds of the world (i.e.
static std::string GetSchema()
Representation of a range query.
Helper functions related to rendering.
std::vector< std::vector< u16 > > m_LosPlayerCounts
void PostMessage(entity_id_t ent, const CMessage &msg) const
Send a message, targeted at a particular entity.
CFixedVector2D Multiply(fixed n) const
Multiply by a CFixed.
A very basic subdivision scheme for finding items in ranges.
static void ClassInit(CComponentManager &componentManager)
fixed Length() const
Returns the length of the vector.
bool IsVisible(ssize_t i, ssize_t j)
Returns whether the given vertex is visible (i.e.
std::map< player_id_t, bool > m_LosRevealAll
bool IsExplored(ssize_t i, ssize_t j)
Returns whether the given vertex is explored (i.e.
virtual void DestroyActiveQuery(tag_t tag)
Destroy a query and clean up resources.
virtual CFixedVector3D GetPosition()=0
Returns the current x,y,z position (no interpolation).
static const int TERRITORY_PLAYER_MASK
bool IsZero() const
Returns true if the number is precisely 0.
SceneCollector & collector
virtual void HandleMessage(const CMessage &msg, bool global)
virtual u8 GetPercentMapExplored(player_id_t player)
Get percent map explored statistics for specified player.
Object providing efficient abstracted access to the LOS state.
T & get(int i, int j) const
bool TestEntityQuery(const Query &q, entity_id_t id, const EntityData &entity)
Returns whether the given entity matches the given query (ignoring maxRange)
bool m_DebugOverlayEnabled
void ConstructSquareOnGround(const CSimContext &context, float x, float z, float w, float h, float a, SOverlayLine &overlay, bool floating, float heightOffset=0.25f)
Constructs overlay line as rectangle with given center and dimensions, conforming to terrain...
static CFixed FromFloat(float n)
Functor for sorting entities by distance from a source point.
std::vector< entity_id_t > lastMatch
static Handle handle(size_t idx, u64 tag)
#define debug_warn(expr)
display the error dialog with the given text.
void sincos_approx(CFixed_15_16 a, CFixed_15_16 &sin_out, CFixed_15_16 &cos_out)
Compute sin(a) and cos(a).
A simple fixed-size array that works similar to an std::vector but is obviously limited in its max it...
CFixed Square() const
Multiply the value by itself.
void Move(uint32_t item, CFixedVector2D fromMin, CFixedVector2D fromMax, CFixedVector2D toMin, CFixedVector2D toMax)
Equivalent to Remove() then Add(), but potentially faster.
size_t m_TerritoriesDirtyID
Query ConstructQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, const std::vector< int > &owners, int requiredInterface, u8 flagsMask)
void Add(uint32_t item, CFixedVector2D toMin, CFixedVector2D toMax)
Add an item with the given 'to' size.
virtual void SetDebugOverlay(bool enabled)
Toggle the rendering of debug info.
void LosRemove(player_id_t owner, entity_pos_t visionRange, CFixedVector2D pos)
#define cassert(expr)
Compile-time assertion.
EntityMap< EntityData > m_EntityData
const entity_id_t INVALID_ENTITY
Invalid entity ID.
virtual void Serialize(ISerializer &serialize)
virtual void SetLosRevealAll(player_id_t player, bool enabled)
Set whether the whole map should be made visible to the given player.
virtual void DisableActiveQuery(tag_t tag)
Disable the processing of a query (no RangeUpdate messages will be sent).
u32 entity_id_t
Entity ID type.
virtual void Submit(CPatch *patch)=0
Submit a terrain patch that is part of the scene.
void operator()(S &serialize, const char *name, EntityData &value)
entity_pos_t GetDivisionSize() const
static const player_id_t INVALID_PLAYER
void ExecuteActiveQueries()
Update all currently-enabled active queries.
virtual tag_t CreateActiveParabolicQuery(entity_id_t source, entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t elevationBonus, std::vector< int > owners, int requiredInterface, u8 flags)
Construct an active query of a paraboloic form around the unit.
Serialization helper template for EntityData.
virtual bool GetLosCircular()
Returns whether the LOS is restricted to a circular map.
SpatialSubdivision m_Subdivision
u32 tag_t
External identifiers for active queries.
void LosAdd(player_id_t owner, entity_pos_t visionRange, CFixedVector2D pos)
CComponentManager & GetComponentManager() const
virtual std::vector< entity_pos_t > getParabolicRangeForm(CFixedVector3D pos, entity_pos_t maxRange, entity_pos_t cutoff, entity_pos_t minAngle, entity_pos_t maxAngle, int numberOfSteps)
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
i32 m_TerrainVerticesPerSide
Deserialization interface; see serialization overview.