Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpObstruction.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | return | ||||
"<param name='minInclusive'>1.5</param>" | "<param name='minInclusive'>1.5</param>" | ||||
"</data>" | "</data>" | ||||
"</attribute>" | "</attribute>" | ||||
"<attribute name='depth'>" | "<attribute name='depth'>" | ||||
"<data type='decimal'>" | "<data type='decimal'>" | ||||
"<param name='minInclusive'>1.5</param>" | "<param name='minInclusive'>1.5</param>" | ||||
"</data>" | "</data>" | ||||
"</attribute>" | "</attribute>" | ||||
"<optional>" | |||||
"<attribute name='clearance' a:help='Extra clearance to be applied when placing the entity, ensures there is passable space around it (can be negative to allow for overlap, if the overlap is small enough to not cause problems).'>" | |||||
"<data type='decimal'/>" | |||||
"</attribute>" | |||||
"</optional>" | |||||
"</element>" | "</element>" | ||||
"<element name='Unit'>" | "<element name='Unit'>" | ||||
"<empty/>" | "<empty/>" | ||||
"</element>" | "</element>" | ||||
"<element name='Obstructions'>" | "<element name='Obstructions'>" | ||||
"<zeroOrMore>" | "<zeroOrMore>" | ||||
"<element>" | "<element>" | ||||
"<anyName/>" | "<anyName/>" | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | if (paramNode.GetChild("Unit").IsOk()) | ||||
if (cmpUnitMotion) | if (cmpUnitMotion) | ||||
m_Clearance = cmpUnitMotion->GetUnitClearance(); | m_Clearance = cmpUnitMotion->GetUnitClearance(); | ||||
} | } | ||||
else if (paramNode.GetChild("Static").IsOk()) | else if (paramNode.GetChild("Static").IsOk()) | ||||
{ | { | ||||
m_Type = STATIC; | m_Type = STATIC; | ||||
m_Size0 = paramNode.GetChild("Static").GetChild("@width").ToFixed(); | m_Size0 = paramNode.GetChild("Static").GetChild("@width").ToFixed(); | ||||
m_Size1 = paramNode.GetChild("Static").GetChild("@depth").ToFixed(); | m_Size1 = paramNode.GetChild("Static").GetChild("@depth").ToFixed(); | ||||
m_Clearance = paramNode.GetChild("Static").GetChild("@clearance").ToFixed(); | |||||
ENSURE(m_Size0 > minObstruction); | ENSURE(m_Size0 > minObstruction); | ||||
ENSURE(m_Size1 > minObstruction); | ENSURE(m_Size1 > minObstruction); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
m_Type = CLUSTER; | m_Type = CLUSTER; | ||||
CFixedVector2D max = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0)); | CFixedVector2D max = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0)); | ||||
CFixedVector2D min = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0)); | CFixedVector2D min = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0)); | ||||
Show All 12 Lines | else | ||||
m_Shapes.push_back(b); | m_Shapes.push_back(b); | ||||
max.X = std::max(max.X, b.dx + b.size0/2); | max.X = std::max(max.X, b.dx + b.size0/2); | ||||
max.Y = std::max(max.Y, b.dz + b.size1/2); | max.Y = std::max(max.Y, b.dz + b.size1/2); | ||||
min.X = std::min(min.X, b.dx - b.size0/2); | min.X = std::min(min.X, b.dx - b.size0/2); | ||||
min.Y = std::min(min.Y, b.dz - b.size1/2); | min.Y = std::min(min.Y, b.dz - b.size1/2); | ||||
} | } | ||||
m_Size0 = fixed::FromInt(2).Multiply(std::max(max.X, -min.X)); | m_Size0 = fixed::FromInt(2).Multiply(std::max(max.X, -min.X)); | ||||
m_Size1 = fixed::FromInt(2).Multiply(std::max(max.Y, -min.Y)); | m_Size1 = fixed::FromInt(2).Multiply(std::max(max.Y, -min.Y)); | ||||
// TODO perhaps support clearance per obstruction | |||||
m_Clearance = entity_pos_t::Zero(); | |||||
} | } | ||||
m_Active = paramNode.GetChild("Active").ToBool(); | m_Active = paramNode.GetChild("Active").ToBool(); | ||||
m_ControlPersist = paramNode.GetChild("ControlPersist").IsOk(); | m_ControlPersist = paramNode.GetChild("ControlPersist").IsOk(); | ||||
m_Tag = tag_t(); | m_Tag = tag_t(); | ||||
if (m_Type == CLUSTER) | if (m_Type == CLUSTER) | ||||
m_ClusterTags.clear(); | m_ClusterTags.clear(); | ||||
▲ Show 20 Lines • Show All 300 Lines • ▼ Show 20 Lines | virtual EFoundationCheck CheckFoundation(const std::string& className, bool onlyCenterPoint) const | ||||
// Ignore collisions within the same control group, or with other non-foundation-blocking shapes. | // Ignore collisions within the same control group, or with other non-foundation-blocking shapes. | ||||
// 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 non-foundation-blocking shapes. | // equivalent to only ignoring the entity's own shape and other non-foundation-blocking shapes. | ||||
SkipControlGroupsRequireFlagObstructionFilter filter(m_ControlGroup, m_ControlGroup2, | SkipControlGroupsRequireFlagObstructionFilter filter(m_ControlGroup, m_ControlGroup2, | ||||
ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); | ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); | ||||
if (m_Type == UNIT) | if (m_Type == UNIT) | ||||
return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Clearance, passClass, onlyCenterPoint); | return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Clearance, passClass); | ||||
else | else | ||||
return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, onlyCenterPoint); | return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, m_Clearance * 2); | ||||
} | } | ||||
virtual bool CheckDuplicateFoundation() const | virtual bool CheckDuplicateFoundation() const | ||||
{ | { | ||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); | CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); | ||||
if (!cmpPosition) | if (!cmpPosition) | ||||
return false; // error | return false; // error | ||||
▲ Show 20 Lines • Show All 232 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator