Remove BuildingInfluence from Plug placement.

This commit is contained in:
Paul Chote
2020-10-25 20:01:35 +00:00
committed by Matthias Mailänder
parent 90b25be1b6
commit 79019b06ca
2 changed files with 20 additions and 22 deletions

View File

@@ -81,9 +81,9 @@ namespace OpenRA.Mods.Common.Orders
}
}
readonly World world;
readonly ProductionQueue queue;
readonly PlaceBuildingInfo placeBuildingInfo;
readonly BuildingInfluence buildingInfluence;
readonly ResourceLayer resourceLayer;
readonly Viewport viewport;
readonly VariantWrapper[] variants;
@@ -91,10 +91,9 @@ namespace OpenRA.Mods.Common.Orders
public PlaceBuildingOrderGenerator(ProductionQueue queue, string name, WorldRenderer worldRenderer)
{
var world = queue.Actor.World;
this.queue = queue;
world = queue.Actor.World;
placeBuildingInfo = queue.Actor.Owner.PlayerActor.Info.TraitInfo<PlaceBuildingInfo>();
buildingInfluence = world.WorldActor.Trait<BuildingInfluence>();
resourceLayer = world.WorldActor.TraitOrDefault<ResourceLayer>();
viewport = worldRenderer.Viewport;
@@ -225,12 +224,12 @@ namespace OpenRA.Mods.Common.Orders
bool AcceptsPlug(CPos cell, PlugInfo plug)
{
var host = buildingInfluence.GetBuildingAt(cell);
if (host == null)
return false;
foreach (var a in world.ActorMap.GetActorsAt(cell))
foreach (var p in a.TraitsImplementing<Pluggable>())
if (p.AcceptsPlug(a, plug.Type))
return true;
var location = host.Location;
return host.TraitsImplementing<Pluggable>().Any(p => p.AcceptsPlug(host, plug.Type));
return false;
}
IEnumerable<IRenderable> IOrderGenerator.Render(WorldRenderer wr, World world) { yield break; }

View File

@@ -135,27 +135,26 @@ namespace OpenRA.Mods.Common.Traits
}
else if (os == "PlacePlug")
{
var host = self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(targetLocation);
if (host == null)
return;
var plugInfo = actorInfo.TraitInfoOrDefault<PlugInfo>();
if (plugInfo == null)
return;
var location = host.Location;
var pluggableLocations = host.TraitsImplementing<Pluggable>()
.Where(p => p.AcceptsPlug(host, plugInfo.Type));
foreach (var a in self.World.ActorMap.GetActorsAt(targetLocation))
{
var pluggables = a.TraitsImplementing<Pluggable>()
.Where(p => p.AcceptsPlug(a, plugInfo.Type))
.ToList();
var pluggable = pluggableLocations.FirstOrDefault(p => location + p.Info.Offset == targetLocation)
?? pluggableLocations.FirstOrDefault();
var pluggable = pluggables.FirstOrDefault(p => a.Location + p.Info.Offset == targetLocation)
?? pluggables.FirstOrDefault();
if (pluggable == null)
return;
pluggable.EnablePlug(host, plugInfo.Type);
pluggable.EnablePlug(a, plugInfo.Type);
foreach (var s in buildingInfo.BuildSounds)
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, host.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, a.CenterPosition);
}
}
else
{