Merge pull request #10252 from penev92/removeToP
Remove obsolete TransformOnPassenger trait
This commit is contained in:
@@ -484,7 +484,6 @@
|
||||
<Compile Include="Traits\ThrowsParticle.cs" />
|
||||
<Compile Include="Traits\Tooltip.cs" />
|
||||
<Compile Include="Traits\TransformOnCapture.cs" />
|
||||
<Compile Include="Traits\TransformOnPassenger.cs" />
|
||||
<Compile Include="Traits\Transforms.cs" />
|
||||
<Compile Include="Traits\Turreted.cs" />
|
||||
<Compile Include="Traits\ProducibleWithLevel.cs" />
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class TransformOnPassengerInfo : ITraitInfo
|
||||
{
|
||||
[ActorReference, FieldLoader.Require] public readonly HashSet<string> PassengerTypes = new HashSet<string>();
|
||||
[ActorReference] public readonly string OnEnter = null;
|
||||
[ActorReference] public readonly string OnExit = null;
|
||||
public readonly bool SkipMakeAnims = false;
|
||||
public readonly bool BecomeNeutral = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new TransformOnPassenger(this); }
|
||||
}
|
||||
|
||||
public class TransformOnPassenger : INotifyPassengerEntered, INotifyPassengerExited
|
||||
{
|
||||
readonly TransformOnPassengerInfo info;
|
||||
|
||||
public TransformOnPassenger(TransformOnPassengerInfo info) { this.info = info; }
|
||||
|
||||
void MaybeTransform(Actor self, Actor passenger, string transformTo)
|
||||
{
|
||||
if (info.PassengerTypes.Contains(passenger.Info.Name) && transformTo != null)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var facing = self.TraitOrDefault<IFacing>();
|
||||
var transform = new Transform(self, transformTo) { SkipMakeAnims = info.SkipMakeAnims };
|
||||
if (facing != null) transform.Facing = facing.Facing;
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(transform);
|
||||
if (info.BecomeNeutral) self.ChangeOwner(self.World.WorldActor.Owner);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void PassengerEntered(Actor self, Actor passenger) { MaybeTransform(self, passenger, info.OnEnter); }
|
||||
public void PassengerExited(Actor self, Actor passenger) { MaybeTransform(self, passenger, info.OnExit); }
|
||||
}
|
||||
}
|
||||
@@ -2807,6 +2807,14 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
// Remove obsolete TransformOnPassenger trait.
|
||||
if (engineVersion < 20160102)
|
||||
{
|
||||
node.Value.Nodes.RemoveAll(x => x.Key.Contains("TransformOnPassenger"));
|
||||
Console.WriteLine("TransformOnPassenger has been removed.");
|
||||
Console.WriteLine("Use the upgrades system to apply modifiers to the transport actor instead.");
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user