Changeset View
Changeset View
Standalone View
Standalone View
0ad/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp
Show First 20 Lines • Show All 359 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
msg->size = g_Game->GetWorld()->GetTerrain()->GetTilesPerSide(); | msg->size = g_Game->GetWorld()->GetTerrain()->GetTilesPerSide(); | ||||
} | } | ||||
BEGIN_COMMAND(ResizeMap) | BEGIN_COMMAND(ResizeMap) | ||||
{ | { | ||||
bool Within(const CFixedVector3D& pos, const int centerX, const int centerZ, const int radius) | bool Within(const CFixedVector3D& pos, const int centerX, const int centerZ, const int radius) | ||||
{ | { | ||||
int dx = abs(pos.X.ToInt_RoundToZero() - centerX); | int dx = abs(pos.getX().ToInt_RoundToZero() - centerX); | ||||
if (dx > radius) | if (dx > radius) | ||||
return false; | return false; | ||||
int dz = abs(pos.Z.ToInt_RoundToZero() - centerZ); | int dz = abs(pos.getZ().ToInt_RoundToZero() - centerZ); | ||||
if (dz > radius) | if (dz > radius) | ||||
return false; | return false; | ||||
if (dx + dz <= radius) | if (dx + dz <= radius) | ||||
return true; | return true; | ||||
return dx * dx + dz * dz <= radius * radius; | return dx * dx + dz * dz <= radius * radius; | ||||
} | } | ||||
struct DeletedObject | struct DeletedObject | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | for (const DeletedObject& deleted : deletedObjects) | ||||
{ | { | ||||
LOGERROR("Failed to load entity template '%s'", deleted.templateName.c_str()); | LOGERROR("Failed to load entity template '%s'", deleted.templateName.c_str()); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
CmpPtr<ICmpPosition> cmpPosition(sim, deleted.entityId); | CmpPtr<ICmpPosition> cmpPosition(sim, deleted.entityId); | ||||
if (cmpPosition) | if (cmpPosition) | ||||
{ | { | ||||
cmpPosition->JumpTo(deleted.pos.X, deleted.pos.Z); | cmpPosition->JumpTo(deleted.pos.getX(), deleted.pos.getZ()); | ||||
cmpPosition->SetXZRotation(deleted.rot.X, deleted.rot.Z); | cmpPosition->SetXZRotation(deleted.rot.getX(), deleted.rot.getZ()); | ||||
cmpPosition->SetYRotation(deleted.rot.Y); | cmpPosition->SetYRotation(deleted.rot.getY()); | ||||
} | } | ||||
CmpPtr<ICmpOwnership> cmpOwnership(sim, deleted.entityId); | CmpPtr<ICmpOwnership> cmpOwnership(sim, deleted.entityId); | ||||
if (cmpOwnership) | if (cmpOwnership) | ||||
cmpOwnership->SetOwner(deleted.owner); | cmpOwnership->SetOwner(deleted.owner); | ||||
CmpPtr<ICmpVisual> cmpVisual(sim, deleted.entityId); | CmpPtr<ICmpVisual> cmpVisual(sim, deleted.entityId); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
cmpVisual->SetActorSeed(deleted.actorSeed); | cmpVisual->SetActorSeed(deleted.actorSeed); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void SetMovedEntitiesPosition(const std::vector<std::pair<entity_id_t, CFixedVector3D>>& movedObjects) | void SetMovedEntitiesPosition(const std::vector<std::pair<entity_id_t, CFixedVector3D>>& movedObjects) | ||||
{ | { | ||||
for (const std::pair<entity_id_t, CFixedVector3D>& obj : movedObjects) | for (const std::pair<entity_id_t, CFixedVector3D>& obj : movedObjects) | ||||
{ | { | ||||
const entity_id_t id = obj.first; | const entity_id_t id = obj.first; | ||||
const CFixedVector3D position = obj.second; | const CFixedVector3D position = obj.second; | ||||
CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id); | CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id); | ||||
ENSURE(cmpPosition); | ENSURE(cmpPosition); | ||||
cmpPosition->JumpTo(position.X, position.Z); | cmpPosition->JumpTo(position.getX(), position.getZ()); | ||||
} | } | ||||
} | } | ||||
void Do() | void Do() | ||||
{ | { | ||||
CSimulation2& sim = *g_Game->GetSimulation2(); | CSimulation2& sim = *g_Game->GetSimulation2(); | ||||
CmpPtr<ICmpTemplateManager> cmpTemplateManager(sim, SYSTEM_ENTITY); | CmpPtr<ICmpTemplateManager> cmpTemplateManager(sim, SYSTEM_ENTITY); | ||||
ENSURE(cmpTemplateManager); | ENSURE(cmpTemplateManager); | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator