Remove legacy editor actor properties plumbing.
This commit is contained in:
@@ -147,20 +147,6 @@ namespace OpenRA
|
||||
.Select(t => t.GetGenericArguments()[0]);
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<string, Type>> GetInitKeys()
|
||||
{
|
||||
var inits = traits.WithInterface<ITraitInfo>().SelectMany(
|
||||
t => t.GetType().GetInterfaces()
|
||||
.Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(UsesInit<>))
|
||||
.Select(i => i.GetGenericArguments()[0])).ToList();
|
||||
|
||||
inits.Add(typeof(OwnerInit)); /* not exposed by a trait; this is used by the Actor itself */
|
||||
|
||||
return inits.Select(
|
||||
i => Pair.New(
|
||||
i.Name.Replace("Init", ""), i));
|
||||
}
|
||||
|
||||
public bool HasTraitInfo<T>() where T : ITraitInfoInterface { return traits.Contains<T>(); }
|
||||
public T TraitInfo<T>() where T : ITraitInfoInterface { return traits.Get<T>(); }
|
||||
public T TraitInfoOrDefault<T>() where T : ITraitInfoInterface { return traits.GetOrDefault<T>(); }
|
||||
|
||||
@@ -343,8 +343,6 @@ namespace OpenRA.Traits
|
||||
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:InterfaceNamesMustBeginWithI", Justification = "Not a real interface, but more like a tag.")]
|
||||
public interface Requires<T> where T : class, ITraitInfoInterface { }
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:InterfaceNamesMustBeginWithI", Justification = "Not a real interface, but more like a tag.")]
|
||||
public interface UsesInit<T> : ITraitInfo where T : IActorInit { }
|
||||
|
||||
[RequireExplicitImplementation]
|
||||
public interface INotifySelected { void Selected(Actor self); }
|
||||
|
||||
@@ -19,8 +19,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
public class TDGunboatInfo : ITraitInfo, IPositionableInfo, IFacingInfo, IMoveInfo,
|
||||
UsesInit<LocationInit>, UsesInit<FacingInit>, IActorPreviewInitInfo
|
||||
public class TDGunboatInfo : ITraitInfo, IPositionableInfo, IFacingInfo, IMoveInfo, IActorPreviewInitInfo
|
||||
{
|
||||
public readonly int Speed = 28;
|
||||
|
||||
|
||||
@@ -102,24 +102,6 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (mapResources.Contains(cell) && mapResources[cell].Type != 0)
|
||||
mapResources[cell] = new ResourceTile();
|
||||
}
|
||||
else if (mi.Event == MouseInputEvent.Scroll)
|
||||
{
|
||||
if (underCursor != null)
|
||||
{
|
||||
// Test case / demonstration of how to edit an existing actor
|
||||
var facing = underCursor.Init<FacingInit>();
|
||||
if (facing != null)
|
||||
underCursor.ReplaceInit(new FacingInit((facing.Value(world) + mi.ScrollDelta) % 256));
|
||||
else if (underCursor.Info.HasTraitInfo<UsesInit<FacingInit>>())
|
||||
underCursor.ReplaceInit(new FacingInit(mi.ScrollDelta));
|
||||
|
||||
var turret = underCursor.Init<TurretFacingInit>();
|
||||
if (turret != null)
|
||||
underCursor.ReplaceInit(new TurretFacingInit((turret.Value(world) + mi.ScrollDelta) % 256));
|
||||
else if (underCursor.Info.HasTraitInfo<UsesInit<TurretFacingInit>>())
|
||||
underCursor.ReplaceInit(new TurretFacingInit(mi.ScrollDelta));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class AircraftInfo : ITraitInfo, IPositionableInfo, IFacingInfo, IMoveInfo, ICruiseAltitudeInfo,
|
||||
UsesInit<LocationInit>, UsesInit<FacingInit>, IActorPreviewInitInfo
|
||||
IActorPreviewInitInfo
|
||||
{
|
||||
public readonly WDist CruiseAltitude = new WDist(1280);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("The actor will automatically engage the enemy when it is in range.")]
|
||||
public class AutoTargetInfo : ConditionalTraitInfo, IRulesetLoaded, Requires<AttackBaseInfo>, UsesInit<StanceInit>
|
||||
public class AutoTargetInfo : ConditionalTraitInfo, IRulesetLoaded, Requires<AttackBaseInfo>
|
||||
{
|
||||
[Desc("It will try to hunt down the enemy if it is set to AttackAnything.")]
|
||||
public readonly bool AllowMovement = true;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
OccupiedUntargetable = 'X'
|
||||
}
|
||||
|
||||
public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, IPlaceBuildingDecorationInfo, UsesInit<LocationInit>
|
||||
public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, IPlaceBuildingDecorationInfo
|
||||
{
|
||||
[Desc("Where you are allowed to place the building (Water, Clear, ...)")]
|
||||
public readonly HashSet<string> TerrainTypes = new HashSet<string>();
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class HealthInfo : IHealthInfo, UsesInit<HealthInit>, IRulesetLoaded
|
||||
public class HealthInfo : IHealthInfo, IRulesetLoaded
|
||||
{
|
||||
[Desc("HitPoints")]
|
||||
public readonly int HP = 0;
|
||||
|
||||
@@ -22,8 +22,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Unit is able to move.")]
|
||||
public class MobileInfo : ConditionalTraitInfo, IMoveInfo, IPositionableInfo, IFacingInfo,
|
||||
UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>, IActorPreviewInitInfo
|
||||
public class MobileInfo : ConditionalTraitInfo, IMoveInfo, IPositionableInfo, IFacingInfo, IActorPreviewInitInfo
|
||||
{
|
||||
[Desc("Which Locomotor does this trait use. Must be defined on the World actor.")]
|
||||
[LocomotorReference, FieldLoader.Require]
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class PluggableInfo : ITraitInfo, UsesInit<PlugsInit>
|
||||
public class PluggableInfo : ITraitInfo
|
||||
{
|
||||
[Desc("Footprint cell offset where a plug can be placed.")]
|
||||
public readonly CVec Offset = CVec.Zero;
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Produce a unit on the closest map edge cell and move into the world.")]
|
||||
class ProductionFromMapEdgeInfo : ProductionInfo, UsesInit<ProductionSpawnLocationInit>
|
||||
class ProductionFromMapEdgeInfo : ProductionInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new ProductionFromMapEdge(init, this); }
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Allows this actor to be 'tagged' with arbitrary strings. Tags must be unique or they will be rejected.")]
|
||||
public class ScriptTagsInfo : UsesInit<ScriptTagsInit>
|
||||
public class ScriptTagsInfo : ITraitInfo
|
||||
{
|
||||
object ITraitInfo.Create(ActorInitializer init) { return new ScriptTags(init, this); }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class TurretedInfo : PausableConditionalTraitInfo, UsesInit<TurretFacingInit>, Requires<BodyOrientationInfo>, IActorPreviewInitInfo
|
||||
public class TurretedInfo : PausableConditionalTraitInfo, Requires<BodyOrientationInfo>, IActorPreviewInitInfo
|
||||
{
|
||||
public readonly string Turret = "primary";
|
||||
[Desc("Speed at which the turret turns.")]
|
||||
|
||||
Reference in New Issue
Block a user