Block new buildings being placed on top of existing not-yet-started foundations. Fixes #740.
This was SVN commit r8980.
This commit is contained in:
parent
798278a6c1
commit
f4f36af852
@ -21,5 +21,7 @@
|
||||
<BlockPathfinding>false</BlockPathfinding>
|
||||
<BlockFoundation>false</BlockFoundation>
|
||||
<BlockConstruction>true</BlockConstruction>
|
||||
<DisableBlockMovement>false</DisableBlockMovement>
|
||||
<DisableBlockPathfinding>false</DisableBlockPathfinding>
|
||||
</Obstruction>
|
||||
</Entity>
|
||||
|
@ -104,7 +104,11 @@ Foundation.prototype.Build = function(builderEnt, work)
|
||||
return;
|
||||
}
|
||||
|
||||
cmpObstruction.SetActive(true);
|
||||
// The obstruction always blocks new foundations/construction,
|
||||
// but we've temporarily allowed units to walk all over it
|
||||
// (via CCmpTemplateManager). Now we need to remove that temporary
|
||||
// blocker-disabling, so that we'll perform standard unit blocking instead.
|
||||
cmpObstruction.SetDisableBlockMovementPathfinding(false);
|
||||
}
|
||||
|
||||
this.committed = true;
|
||||
|
@ -21,5 +21,7 @@
|
||||
<BlockPathfinding>true</BlockPathfinding>
|
||||
<BlockFoundation>true</BlockFoundation>
|
||||
<BlockConstruction>true</BlockConstruction>
|
||||
<DisableBlockMovement>false</DisableBlockMovement>
|
||||
<DisableBlockPathfinding>false</DisableBlockPathfinding>
|
||||
</Obstruction>
|
||||
</Entity>
|
||||
|
@ -67,5 +67,7 @@
|
||||
<BlockPathfinding>true</BlockPathfinding>
|
||||
<BlockFoundation>true</BlockFoundation>
|
||||
<BlockConstruction>true</BlockConstruction>
|
||||
<DisableBlockMovement>false</DisableBlockMovement>
|
||||
<DisableBlockPathfinding>false</DisableBlockPathfinding>
|
||||
</Obstruction>
|
||||
</Entity>
|
||||
|
@ -22,6 +22,8 @@
|
||||
<BlockPathfinding>false</BlockPathfinding>
|
||||
<BlockFoundation>true</BlockFoundation>
|
||||
<BlockConstruction>true</BlockConstruction>
|
||||
<DisableBlockMovement>false</DisableBlockMovement>
|
||||
<DisableBlockPathfinding>false</DisableBlockPathfinding>
|
||||
</Obstruction>
|
||||
<Vision>
|
||||
<Range>0</Range>
|
||||
|
@ -82,6 +82,8 @@
|
||||
<BlockPathfinding>false</BlockPathfinding>
|
||||
<BlockFoundation>false</BlockFoundation>
|
||||
<BlockConstruction>true</BlockConstruction>
|
||||
<DisableBlockMovement>false</DisableBlockMovement>
|
||||
<DisableBlockPathfinding>false</DisableBlockPathfinding>
|
||||
</Obstruction>
|
||||
<Vision>
|
||||
<Range>24</Range>
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
} m_Type;
|
||||
entity_pos_t m_Size0; // radius or width
|
||||
entity_pos_t m_Size1; // radius or depth
|
||||
u8 m_Flags;
|
||||
u8 m_TemplateFlags;
|
||||
|
||||
// Dynamic state:
|
||||
|
||||
@ -56,6 +56,7 @@ public:
|
||||
bool m_Moving;
|
||||
entity_id_t m_ControlGroup;
|
||||
ICmpObstructionManager::tag_t m_Tag;
|
||||
u8 m_Flags;
|
||||
|
||||
static std::string GetSchema()
|
||||
{
|
||||
@ -91,6 +92,12 @@ public:
|
||||
"</element>"
|
||||
"<element name='BlockConstruction' a:help='Whether players should be unable to begin constructing buildings placed on top of this entity'>"
|
||||
"<data type='boolean'/>"
|
||||
"</element>"
|
||||
"<element name='DisableBlockMovement' a:help='If true, BlockMovement will be overridden and treated as false. (This is a special case to handle foundations)'>"
|
||||
"<data type='boolean'/>"
|
||||
"</element>"
|
||||
"<element name='DisableBlockPathfinding' a:help='If true, BlockPathfinding will be overridden and treated as false. (This is a special case to handle foundations)'>"
|
||||
"<data type='boolean'/>"
|
||||
"</element>";
|
||||
}
|
||||
|
||||
@ -108,15 +115,21 @@ public:
|
||||
m_Size1 = paramNode.GetChild("Static").GetChild("@depth").ToFixed();
|
||||
}
|
||||
|
||||
m_Flags = 0;
|
||||
m_TemplateFlags = 0;
|
||||
if (paramNode.GetChild("BlockMovement").ToBool())
|
||||
m_Flags |= ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;
|
||||
m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;
|
||||
if (paramNode.GetChild("BlockPathfinding").ToBool())
|
||||
m_Flags |= ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;
|
||||
m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;
|
||||
if (paramNode.GetChild("BlockFoundation").ToBool())
|
||||
m_Flags |= ICmpObstructionManager::FLAG_BLOCK_FOUNDATION;
|
||||
m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_FOUNDATION;
|
||||
if (paramNode.GetChild("BlockConstruction").ToBool())
|
||||
m_Flags |= ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION;
|
||||
m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION;
|
||||
|
||||
m_Flags = m_TemplateFlags;
|
||||
if (paramNode.GetChild("DisableBlockMovement").ToBool())
|
||||
m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;
|
||||
if (paramNode.GetChild("DisableBlockPathfinding").ToBool())
|
||||
m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;
|
||||
|
||||
m_Active = paramNode.GetChild("Active").ToBool();
|
||||
|
||||
@ -136,6 +149,7 @@ public:
|
||||
serialize.Bool("moving", m_Moving);
|
||||
serialize.NumberU32_Unbounded("control group", m_ControlGroup);
|
||||
serialize.NumberU32_Unbounded("tag", m_Tag.n);
|
||||
serialize.NumberU8_Unbounded("flags", m_Flags);
|
||||
}
|
||||
|
||||
virtual void Serialize(ISerializer& serialize)
|
||||
@ -251,6 +265,30 @@ public:
|
||||
// else we didn't change the active status
|
||||
}
|
||||
|
||||
virtual void SetDisableBlockMovementPathfinding(bool disabled)
|
||||
{
|
||||
if (disabled)
|
||||
{
|
||||
// Remove the blocking flags
|
||||
m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;
|
||||
m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the blocking flags if the template had enabled them
|
||||
m_Flags |= (m_TemplateFlags & ICmpObstructionManager::FLAG_BLOCK_MOVEMENT);
|
||||
m_Flags |= (m_TemplateFlags & ICmpObstructionManager::FLAG_BLOCK_PATHFINDING);
|
||||
}
|
||||
|
||||
// Reset the shape with the new flags (kind of inefficiently - we
|
||||
// should have a ICmpObstructionManager::SetFlags function or something)
|
||||
if (m_Active)
|
||||
{
|
||||
SetActive(false);
|
||||
SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ICmpObstructionManager::tag_t GetObstruction()
|
||||
{
|
||||
return m_Tag;
|
||||
|
@ -518,9 +518,9 @@ void CCmpTemplateManager::CopyFoundationSubset(CParamNode& out, const CParamNode
|
||||
// Initialise health to 1
|
||||
CParamNode::LoadXMLString(out, "<Entity><Health><Initial>1</Initial></Health></Entity>");
|
||||
|
||||
// Disable the default obstruction status
|
||||
// Foundations shouldn't initially block unit movement
|
||||
if (out.GetChild("Entity").GetChild("Obstruction").IsOk())
|
||||
CParamNode::LoadXMLString(out, "<Entity><Obstruction><Active>false</Active></Obstruction></Entity>");
|
||||
CParamNode::LoadXMLString(out, "<Entity><Obstruction><DisableBlockMovement>true</DisableBlockMovement><DisableBlockPathfinding>true</DisableBlockPathfinding></Obstruction></Entity>");
|
||||
|
||||
// Don't provide population bonuses yet (but still do take up population cost)
|
||||
if (out.GetChild("Entity").GetChild("Cost").IsOk())
|
||||
|
@ -26,5 +26,6 @@ DEFINE_INTERFACE_METHOD_0("GetUnitRadius", entity_pos_t, ICmpObstruction, GetUni
|
||||
DEFINE_INTERFACE_METHOD_0("CheckFoundationCollisions", bool, ICmpObstruction, CheckFoundationCollisions)
|
||||
DEFINE_INTERFACE_METHOD_0("GetConstructionCollisions", std::vector<entity_id_t>, ICmpObstruction, GetConstructionCollisions)
|
||||
DEFINE_INTERFACE_METHOD_1("SetActive", void, ICmpObstruction, SetActive, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("SetDisableBlockMovementPathfinding", void, ICmpObstruction, SetDisableBlockMovementPathfinding, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("SetControlGroup", void, ICmpObstruction, SetControlGroup, entity_id_t)
|
||||
END_INTERFACE_WRAPPER(Obstruction)
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
|
||||
virtual void SetMovingFlag(bool enabled) = 0;
|
||||
|
||||
virtual void SetDisableBlockMovementPathfinding(bool disabled) = 0;
|
||||
|
||||
/**
|
||||
* Change the control group that the entity belongs to.
|
||||
* Control groups are used to let units ignore collisions with other units from
|
||||
|
@ -92,7 +92,9 @@ public:
|
||||
L"<Footprint><Circle radius=\"4\"></Circle><Height>1.0</Height></Footprint>"
|
||||
L"<Obstruction>"
|
||||
L"<Active>false</Active><BlockConstruction>true</BlockConstruction><BlockFoundation>false</BlockFoundation>"
|
||||
L"<BlockMovement>true</BlockMovement><BlockPathfinding>false</BlockPathfinding><Unit radius=\"4\"></Unit>"
|
||||
L"<BlockMovement>true</BlockMovement><BlockPathfinding>false</BlockPathfinding>"
|
||||
L"<DisableBlockMovement>false</DisableBlockMovement><DisableBlockPathfinding>false</DisableBlockPathfinding>"
|
||||
L"<Unit radius=\"4\"></Unit>"
|
||||
L"</Obstruction>"
|
||||
L"<Position><Altitude>0</Altitude><Anchor>upright</Anchor><Floating>false</Floating></Position>"
|
||||
L"<Vision><AlwaysVisible>true</AlwaysVisible><Range>0</Range><RetainInFog>false</RetainInFog></Vision>"
|
||||
|
Loading…
Reference in New Issue
Block a user