Changeset View
Changeset View
Standalone View
Standalone View
0ad/source/simulation2/components/CCmpTerritoryManager.cpp
Show First 20 Lines • Show All 480 Lines • ▼ Show 20 Lines | for (entity_id_t ent : ents) | ||||
u32 weight = cmpTerritoryInfluence->GetWeight(); | u32 weight = cmpTerritoryInfluence->GetWeight(); | ||||
u32 radius = cmpTerritoryInfluence->GetRadius(); | u32 radius = cmpTerritoryInfluence->GetRadius(); | ||||
if (weight == 0 || radius == 0) | if (weight == 0 || radius == 0) | ||||
continue; | continue; | ||||
u32 falloff = weight * (Pathfinding::NAVCELL_SIZE * NAVCELLS_PER_TERRITORY_TILE).ToInt_RoundToNegInfinity() / radius; | u32 falloff = weight * (Pathfinding::NAVCELL_SIZE * NAVCELLS_PER_TERRITORY_TILE).ToInt_RoundToNegInfinity() / radius; | ||||
CFixedVector2D pos = cmpPosition->GetPosition2D(); | CFixedVector2D pos = cmpPosition->GetPosition2D(); | ||||
u16 i, j; | u16 i, j; | ||||
NearestTerritoryTile(pos.X, pos.Y, i, j, tilesW, tilesH); | NearestTerritoryTile(pos.getX(), pos.getY(), i, j, tilesW, tilesH); | ||||
if (cmpTerritoryInfluence->IsRoot()) | if (cmpTerritoryInfluence->IsRoot()) | ||||
rootInfluenceEntities.push_back(ent); | rootInfluenceEntities.push_back(ent); | ||||
// Initialise the tile under the entity | // Initialise the tile under the entity | ||||
entityGrid.set(i, j, weight); | entityGrid.set(i, j, weight); | ||||
if (weight > bestWeightGrid.get(i, j)) | if (weight > bestWeightGrid.get(i, j)) | ||||
{ | { | ||||
Show All 36 Lines | void CCmpTerritoryManager::CalculateTerritories() | ||||
for (entity_id_t ent : rootInfluenceEntities) | for (entity_id_t ent : rootInfluenceEntities) | ||||
{ | { | ||||
// (These components must be valid else the entities wouldn't be added to this list) | // (These components must be valid else the entities wouldn't be added to this list) | ||||
CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), ent); | CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), ent); | ||||
CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), ent); | CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), ent); | ||||
CFixedVector2D pos = cmpPosition->GetPosition2D(); | CFixedVector2D pos = cmpPosition->GetPosition2D(); | ||||
u16 i, j; | u16 i, j; | ||||
NearestTerritoryTile(pos.X, pos.Y, i, j, tilesW, tilesH); | NearestTerritoryTile(pos.getX(), pos.getY(), i, j, tilesW, tilesH); | ||||
u8 owner = (u8)cmpOwnership->GetOwner(); | u8 owner = (u8)cmpOwnership->GetOwner(); | ||||
if (m_Territories->get(i, j) != owner) | if (m_Territories->get(i, j) != owner) | ||||
continue; | continue; | ||||
m_Territories->set(i, j, owner | TERRITORY_CONNECTED_MASK); | m_Territories->set(i, j, owner | TERRITORY_CONNECTED_MASK); | ||||
▲ Show 20 Lines • Show All 308 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator