Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpObstruction.cpp
Show First 20 Lines • Show All 618 Lines • ▼ Show 20 Lines | public: | ||||
{ | { | ||||
std::vector<entity_id_t> ret; | std::vector<entity_id_t> ret; | ||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | ||||
if (!cmpObstructionManager) | if (!cmpObstructionManager) | ||||
return ret; // error | return ret; // error | ||||
// There are four 'block' flags: construction, foundation, movement, | // There are four 'block' flags: construction, foundation, movement, | ||||
// and pathfinding. Structures have all of these flags, while units | // and pathfinding. Structures have all of these flags, while most units | ||||
// block only movement and construction. | // block only movement and construction. | ||||
flags_t flags = ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION; | flags_t flags = ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION; | ||||
// Ignore collisions within the same control group, or with other shapes that don't match the filter. | // Ignore collisions within the same control group, or with other shapes that don't match the filter. | ||||
// Note that, since the control group for each entity defaults to the entity's ID, this is typically | // Note that, since the control group for each entity defaults to the entity's ID, this is typically | ||||
// equivalent to only ignoring the entity's own shape and other shapes that don't match the filter. | // equivalent to only ignoring the entity's own shape and other shapes that don't match the filter. | ||||
SkipControlGroupsRequireFlagObstructionFilter filter(false, m_ControlGroup, m_ControlGroup2, flags); | SkipControlGroupsRequireFlagObstructionFilter filter(false, m_ControlGroup, m_ControlGroup2, flags); | ||||
ICmpObstructionManager::ObstructionSquare square; | ICmpObstructionManager::ObstructionSquare square; | ||||
if (!GetObstructionSquare(square)) | if (!GetObstructionSquare(square)) | ||||
return ret; // error | return ret; // error | ||||
cmpObstructionManager->GetUnitsOnObstruction(square, ret, filter); | cmpObstructionManager->GetUnitsOnObstruction(square, ret, filter); | ||||
return ret; | return ret; | ||||
} | } | ||||
virtual std::vector<entity_id_t> GetEntityCollisions() const | |||||
{ | |||||
std::vector<entity_id_t> ret; | |||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | |||||
if (!cmpObstructionManager) | |||||
return ret; // error | |||||
// Ignore collisions within the same control group. | |||||
SkipControlGroupsRequireFlagObstructionFilter filter(true, m_ControlGroup, m_ControlGroup2, 0); | |||||
ICmpObstructionManager::ObstructionSquare square; | |||||
if (!GetObstructionSquare(square)) | |||||
return ret; // error | |||||
cmpObstructionManager->GetUnitsOnObstruction(square, ret, filter, false); | |||||
cmpObstructionManager->GetStaticObstructionsOnObstruction(square, ret, filter); | |||||
return ret; | |||||
} | |||||
virtual void SetMovingFlag(bool enabled) | virtual void SetMovingFlag(bool enabled) | ||||
{ | { | ||||
m_Moving = enabled; | m_Moving = enabled; | ||||
if (m_Tag.valid() && m_Type == UNIT) | if (m_Tag.valid() && m_Type == UNIT) | ||||
{ | { | ||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | ||||
if (cmpObstructionManager) | if (cmpObstructionManager) | ||||
▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator