Add Plug and Pluggable for building actor-specific upgrades.
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "PlaceBuilding" || order.OrderString == "LineBuild")
|
||||
if (order.OrderString == "PlaceBuilding" || order.OrderString == "LineBuild" || order.OrderString == "PlacePlug")
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
@@ -69,6 +69,27 @@ namespace OpenRA.Mods.Common.Traits
|
||||
playSounds = false;
|
||||
}
|
||||
}
|
||||
else if (order.OrderString == "PlacePlug")
|
||||
{
|
||||
var host = self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(order.TargetLocation);
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
var plugInfo = unit.Traits.GetOrDefault<PlugInfo>();
|
||||
if (plugInfo == null)
|
||||
return;
|
||||
|
||||
var location = host.Location;
|
||||
var pluggable = host.TraitsImplementing<Pluggable>()
|
||||
.FirstOrDefault(p => location + p.Info.Offset == order.TargetLocation && p.AcceptsPlug(host, plugInfo.Type));
|
||||
|
||||
if (pluggable == null)
|
||||
return;
|
||||
|
||||
pluggable.EnablePlug(host, plugInfo.Type);
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Sound.PlayToPlayer(order.Player, s, host.CenterPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!self.World.CanPlaceBuilding(order.TargetString, buildingInfo, order.TargetLocation, null)
|
||||
|
||||
Reference in New Issue
Block a user