Don't stomp over other building's influence.
This commit is contained in:
@@ -31,23 +31,24 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
world.ActorAdded += a =>
|
world.ActorAdded += a =>
|
||||||
{
|
{
|
||||||
var b = a.TraitOrDefault<Building>();
|
var b = a.TraitOrDefault<Building>();
|
||||||
if (b != null)
|
if (b == null)
|
||||||
ChangeInfluence(a, b, true);
|
return;
|
||||||
|
|
||||||
|
foreach (var u in FootprintUtils.Tiles(a.Info.Name, b.Info, a.Location))
|
||||||
|
if (map.IsInMap(u) && influence[u.X, u.Y] == null)
|
||||||
|
influence[u.X, u.Y] = a;
|
||||||
};
|
};
|
||||||
|
|
||||||
world.ActorRemoved += a =>
|
world.ActorRemoved += a =>
|
||||||
{
|
{
|
||||||
var b = a.TraitOrDefault<Building>();
|
var b = a.TraitOrDefault<Building>();
|
||||||
if (b != null)
|
if (b == null)
|
||||||
ChangeInfluence(a, b, false);
|
return;
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChangeInfluence(Actor a, Building building, bool isAdd)
|
foreach (var u in FootprintUtils.Tiles(a.Info.Name, b.Info, a.Location))
|
||||||
{
|
if (map.IsInMap(u) && influence[u.X, u.Y] == a)
|
||||||
foreach (var u in FootprintUtils.Tiles(a.Info.Name, building.Info, a.Location))
|
influence[u.X, u.Y] = null;
|
||||||
if (map.IsInMap(u))
|
};
|
||||||
influence[u.X, u.Y] = isAdd ? a : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor GetBuildingAt(CPos cell)
|
public Actor GetBuildingAt(CPos cell)
|
||||||
|
|||||||
Reference in New Issue
Block a user