Revert "Remove BuildingInfluence trait."
This reverts commit 34bf14332887267e206d217956aab143720fc87d.
This commit is contained in:
@@ -263,6 +263,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly CPos topLeft;
|
readonly CPos topLeft;
|
||||||
|
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
readonly BuildingInfluence influence;
|
||||||
|
|
||||||
(CPos, SubCell)[] occupiedCells;
|
(CPos, SubCell)[] occupiedCells;
|
||||||
(CPos, SubCell)[] targetableCells;
|
(CPos, SubCell)[] targetableCells;
|
||||||
@@ -276,6 +277,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self = init.Self;
|
self = init.Self;
|
||||||
topLeft = init.GetValue<LocationInit, CPos>();
|
topLeft = init.GetValue<LocationInit, CPos>();
|
||||||
Info = info;
|
Info = info;
|
||||||
|
influence = self.World.WorldActor.Trait<BuildingInfluence>();
|
||||||
|
|
||||||
occupiedCells = Info.OccupiedTiles(TopLeft)
|
occupiedCells = Info.OccupiedTiles(TopLeft)
|
||||||
.Select(c => (c, SubCell.FullCell)).ToArray();
|
.Select(c => (c, SubCell.FullCell)).ToArray();
|
||||||
@@ -305,11 +307,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
RemoveSmudges();
|
RemoveSmudges();
|
||||||
|
|
||||||
self.World.AddToMaps(self, this);
|
self.World.AddToMaps(self, this);
|
||||||
|
influence.AddInfluence(self, Info.Tiles(self.Location));
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.RemoveFromMaps(self, this);
|
self.World.RemoveFromMaps(self, this);
|
||||||
|
influence.RemoveInfluence(self, Info.Tiles(self.Location));
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifySold.Selling(Actor self)
|
void INotifySold.Selling(Actor self)
|
||||||
|
|||||||
54
OpenRA.Mods.Common/Traits/Buildings/BuildingInfluence.cs
Normal file
54
OpenRA.Mods.Common/Traits/Buildings/BuildingInfluence.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("A dictionary of buildings placed on the map. Attach this to the world actor.")]
|
||||||
|
public class BuildingInfluenceInfo : TraitInfo
|
||||||
|
{
|
||||||
|
public override object Create(ActorInitializer init) { return new BuildingInfluence(init.World); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BuildingInfluence
|
||||||
|
{
|
||||||
|
readonly Map map;
|
||||||
|
readonly CellLayer<Actor> influence;
|
||||||
|
|
||||||
|
public BuildingInfluence(World world)
|
||||||
|
{
|
||||||
|
map = world.Map;
|
||||||
|
|
||||||
|
influence = new CellLayer<Actor>(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void AddInfluence(Actor a, IEnumerable<CPos> tiles)
|
||||||
|
{
|
||||||
|
foreach (var u in tiles)
|
||||||
|
if (influence.Contains(u) && influence[u] == null)
|
||||||
|
influence[u] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RemoveInfluence(Actor a, IEnumerable<CPos> tiles)
|
||||||
|
{
|
||||||
|
foreach (var u in tiles)
|
||||||
|
if (influence.Contains(u) && influence[u] == a)
|
||||||
|
influence[u] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Actor GetBuildingAt(CPos cell)
|
||||||
|
{
|
||||||
|
return influence.Contains(cell) ? influence[cell] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version. For more
|
|
||||||
* information, see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|
||||||
{
|
|
||||||
public class RemoveBuildingInfluence : UpdateRule
|
|
||||||
{
|
|
||||||
public override string Name { get { return "BuildingInfluence trait has been removed."; } }
|
|
||||||
|
|
||||||
public override string Description
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return "BuildingInfluence trait has been removed. Its functionality has been integrated into ActorMap.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
|
||||||
{
|
|
||||||
actorNode.RemoveNodes("BuildingInfluence");
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -78,7 +78,6 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new RenameCircleContrast(),
|
new RenameCircleContrast(),
|
||||||
new SplitDamagedByTerrain(),
|
new SplitDamagedByTerrain(),
|
||||||
new RemoveLaysTerrain(),
|
new RemoveLaysTerrain(),
|
||||||
new RemoveBuildingInfluence(),
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ World:
|
|||||||
PlayerCommands:
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
ScreenShaker:
|
ScreenShaker:
|
||||||
|
BuildingInfluence:
|
||||||
LegacyBridgeLayer:
|
LegacyBridgeLayer:
|
||||||
Bridges: bridge1, bridge2, bridge3, bridge4
|
Bridges: bridge1, bridge2, bridge3, bridge4
|
||||||
ProductionQueueFromSelection:
|
ProductionQueueFromSelection:
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ World:
|
|||||||
PlayerCommands:
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
ScreenShaker:
|
ScreenShaker:
|
||||||
|
BuildingInfluence:
|
||||||
ProductionQueueFromSelection:
|
ProductionQueueFromSelection:
|
||||||
ProductionPaletteWidget: PRODUCTION_PALETTE
|
ProductionPaletteWidget: PRODUCTION_PALETTE
|
||||||
ActorSpawnManager:
|
ActorSpawnManager:
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ World:
|
|||||||
PlayerCommands:
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
ScreenShaker:
|
ScreenShaker:
|
||||||
|
BuildingInfluence:
|
||||||
ProductionQueueFromSelection:
|
ProductionQueueFromSelection:
|
||||||
ProductionPaletteWidget: PRODUCTION_PALETTE
|
ProductionPaletteWidget: PRODUCTION_PALETTE
|
||||||
LegacyBridgeLayer:
|
LegacyBridgeLayer:
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ World:
|
|||||||
DebugVisualizationCommands:
|
DebugVisualizationCommands:
|
||||||
PlayerCommands:
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
|
BuildingInfluence:
|
||||||
ProductionQueueFromSelection:
|
ProductionQueueFromSelection:
|
||||||
ProductionPaletteWidget: PRODUCTION_PALETTE
|
ProductionPaletteWidget: PRODUCTION_PALETTE
|
||||||
DomainIndex:
|
DomainIndex:
|
||||||
|
|||||||
Reference in New Issue
Block a user