Added simple construction-site-blocking check

rope
Bernhard Bonigl 2012-04-14 23:37:12 +02:00
parent 219bceefcd
commit a687b0f85c
2 changed files with 15 additions and 1 deletions

View File

@ -4,4 +4,4 @@ Version=4,10,0,0
Category=C4D_StaticBack
Width=16
Height=16
Offset=-8,-16
Offset=-8,-16

View File

@ -217,6 +217,20 @@ func CreateConstructionSite(object clonk, id structure_id, int x, int y)
//if(!(site = CreateConstruction(structure_id, x, y, Contained()->GetOwner(), 1, 1, 1)))
//return false;
// intersection-check with all other construction sites... bah
for(var other_site in FindObjects(Find_ID(ConstructionSite), Find_Exclude(site)))
{
if(!(other_site->GetLeftEdge() > site->GetRightEdge() ||
other_site->GetRightEdge() < site->GetLeftEdge() ||
other_site->GetTopEdge() > site->GetBottomEdge() ||
other_site->GetBottomEdge() < site->GetTopEdge() ))
{
CustomMessage(Format("Construction blocked by %s",other_site->GetName()), this, clonk->GetOwner()); // todo: stringtable
site->RemoveObject();
return false;
}
}
// check for material
var comp, index = 0;
var mat;