Remove redundant IBodyOrientation[Info] & replace with BodyOrientation[Info]

This commit is contained in:
atlimit8
2015-09-15 22:57:08 -05:00
parent 59edf85513
commit 45112cfa76
34 changed files with 65 additions and 79 deletions

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits namespace OpenRA.Mods.Cnc.Traits
{ {
[Desc("Renders the cargo loaded into the unit.")] [Desc("Renders the cargo loaded into the unit.")]
public class WithCargoInfo : ITraitInfo, Requires<CargoInfo>, Requires<IBodyOrientationInfo> public class WithCargoInfo : ITraitInfo, Requires<CargoInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Cargo position relative to turret or body in (forward, right, up) triples. The default offset should be in the middle of the list.")] [Desc("Cargo position relative to turret or body in (forward, right, up) triples. The default offset should be in the middle of the list.")]
public readonly WVec[] LocalOffset = { WVec.Zero }; public readonly WVec[] LocalOffset = { WVec.Zero };
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly Cargo cargo; readonly Cargo cargo;
readonly IFacing facing; readonly IFacing facing;
readonly WithCargoInfo cargoInfo; readonly WithCargoInfo cargoInfo;
readonly IBodyOrientation body; readonly BodyOrientation body;
public WithCargo(Actor self, WithCargoInfo info) public WithCargo(Actor self, WithCargoInfo info)
{ {
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
facing = self.TraitOrDefault<IFacing>(); facing = self.TraitOrDefault<IFacing>();
cargoInfo = info; cargoInfo = info;
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
} }
public void Tick(Actor self) public void Tick(Actor self)

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits namespace OpenRA.Mods.Cnc.Traits
{ {
class WithGunboatBodyInfo : WithSpriteBodyInfo, Requires<IBodyOrientationInfo>, Requires<IFacingInfo>, Requires<TurretedInfo> class WithGunboatBodyInfo : WithSpriteBodyInfo, Requires<BodyOrientationInfo>, Requires<IFacingInfo>, Requires<TurretedInfo>
{ {
[Desc("Turreted 'Turret' key to display")] [Desc("Turreted 'Turret' key to display")]
public readonly string Turret = "primary"; public readonly string Turret = "primary";

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Effects namespace OpenRA.Mods.Common.Effects
{ {
[Desc("Draw a colored contrail behind this actor when they move.")] [Desc("Draw a colored contrail behind this actor when they move.")]
class ContrailInfo : ITraitInfo, Requires<IBodyOrientationInfo> class ContrailInfo : ITraitInfo, Requires<BodyOrientationInfo>
{ {
[Desc("Position relative to body")] [Desc("Position relative to body")]
public readonly WVec Offset = WVec.Zero; public readonly WVec Offset = WVec.Zero;
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Effects
class Contrail : ITick, IRender class Contrail : ITick, IRender
{ {
readonly ContrailInfo info; readonly ContrailInfo info;
readonly IBodyOrientation body; readonly BodyOrientation body;
// This is a mutable struct, so it can't be readonly. // This is a mutable struct, so it can't be readonly.
ContrailRenderable trail; ContrailRenderable trail;
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Effects
var color = info.UsePlayerColor ? ContrailRenderable.ChooseColor(self) : info.Color; var color = info.UsePlayerColor ? ContrailRenderable.ChooseColor(self) : info.Color;
trail = new ContrailRenderable(self.World, color, info.TrailLength, 0, 0); trail = new ContrailRenderable(self.World, color, info.TrailLength, 0, 0);
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
} }
public void Tick(Actor self) public void Tick(Actor self)

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Actor self; readonly Actor self;
Lazy<Turreted> turret; Lazy<Turreted> turret;
Lazy<IBodyOrientation> coords; Lazy<BodyOrientation> coords;
Lazy<AmmoPool> ammoPool; Lazy<AmmoPool> ammoPool;
List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>(); List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>();
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
// We can't resolve these until runtime // We can't resolve these until runtime
turret = Exts.Lazy(() => self.TraitsImplementing<Turreted>().FirstOrDefault(t => t.Name == info.Turret)); turret = Exts.Lazy(() => self.TraitsImplementing<Turreted>().FirstOrDefault(t => t.Name == info.Turret));
coords = Exts.Lazy(() => self.Trait<IBodyOrientation>()); coords = Exts.Lazy(() => self.Trait<BodyOrientation>());
ammoPool = Exts.Lazy(() => self.TraitsImplementing<AmmoPool>().FirstOrDefault(la => la.Info.Name == info.AmmoPoolName)); ammoPool = Exts.Lazy(() => self.TraitsImplementing<AmmoPool>().FirstOrDefault(la => la.Info.Name == info.AmmoPoolName));
Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()]; Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()];

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly FirePort[] Ports; public readonly FirePort[] Ports;
AttackGarrisonedInfo info; AttackGarrisonedInfo info;
Lazy<IBodyOrientation> coords; Lazy<BodyOrientation> coords;
List<Armament> armaments; List<Armament> armaments;
List<AnimationWithOffset> muzzles; List<AnimationWithOffset> muzzles;
Dictionary<Actor, IFacing> paxFacing; Dictionary<Actor, IFacing> paxFacing;
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
: base(self, info) : base(self, info)
{ {
this.info = info; this.info = info;
coords = Exts.Lazy(() => self.Trait<IBodyOrientation>()); coords = Exts.Lazy(() => self.Trait<BodyOrientation>());
armaments = new List<Armament>(); armaments = new List<Armament>();
muzzles = new List<AnimationWithOffset>(); muzzles = new List<AnimationWithOffset>();
paxFacing = new Dictionary<Actor, IFacing>(); paxFacing = new Dictionary<Actor, IFacing>();

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public class BodyOrientationInfo : ITraitInfo, IBodyOrientationInfo public class BodyOrientationInfo : ITraitInfo
{ {
[Desc("Number of facings for gameplay calculations. -1 indicates auto-detection from another trait")] [Desc("Number of facings for gameplay calculations. -1 indicates auto-detection from another trait")]
public readonly int QuantizedFacings = -1; public readonly int QuantizedFacings = -1;
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new BodyOrientation(init, this); } public object Create(ActorInitializer init) { return new BodyOrientation(init, this); }
} }
public class BodyOrientation : IBodyOrientation, ISync public class BodyOrientation : ISync
{ {
readonly BodyOrientationInfo info; readonly BodyOrientationInfo info;
readonly Lazy<int> quantizedFacings; readonly Lazy<int> quantizedFacings;

View File

@@ -27,13 +27,13 @@ namespace OpenRA.Mods.Common.Traits
readonly DeveloperMode devMode; readonly DeveloperMode devMode;
Lazy<AttackBase> attack; Lazy<AttackBase> attack;
Lazy<IBodyOrientation> coords; Lazy<BodyOrientation> coords;
Lazy<Health> health; Lazy<Health> health;
public CombatDebugOverlay(Actor self) public CombatDebugOverlay(Actor self)
{ {
attack = Exts.Lazy(() => self.TraitOrDefault<AttackBase>()); attack = Exts.Lazy(() => self.TraitOrDefault<AttackBase>());
coords = Exts.Lazy(() => self.Trait<IBodyOrientation>()); coords = Exts.Lazy(() => self.Trait<BodyOrientation>());
health = Exts.Lazy(() => self.TraitOrDefault<Health>()); health = Exts.Lazy(() => self.TraitOrDefault<Health>());
var localPlayer = self.World.LocalPlayer; var localPlayer = self.World.LocalPlayer;

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p); ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p);
} }
public class RenderVoxelsInfo : ITraitInfo, IRenderActorPreviewInfo, Requires<IBodyOrientationInfo> public class RenderVoxelsInfo : ITraitInfo, IRenderActorPreviewInfo, Requires<BodyOrientationInfo>
{ {
[Desc("Defaults to the actor name.")] [Desc("Defaults to the actor name.")]
public readonly string Image = null; public readonly string Image = null;
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits
readonly List<VoxelAnimation> components = new List<VoxelAnimation>(); readonly List<VoxelAnimation> components = new List<VoxelAnimation>();
readonly Actor self; readonly Actor self;
readonly RenderVoxelsInfo info; readonly RenderVoxelsInfo info;
readonly IBodyOrientation body; readonly BodyOrientation body;
readonly WRot camera; readonly WRot camera;
readonly WRot lightSource; readonly WRot lightSource;
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
this.self = self; this.self = self;
this.info = info; this.info = info;
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
camera = new WRot(WAngle.Zero, body.CameraPitch - new WAngle(256), new WAngle(256)); camera = new WRot(WAngle.Zero, body.CameraPitch - new WAngle(256), new WAngle(256));
lightSource = new WRot(WAngle.Zero, new WAngle(256) - info.LightPitch, info.LightYaw); lightSource = new WRot(WAngle.Zero, new WAngle(256) - info.LightPitch, info.LightYaw);
} }

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Renders barrels for units with the Turreted trait.")] [Desc("Renders barrels for units with the Turreted trait.")]
public class WithBarrelInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<TurretedInfo>, public class WithBarrelInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<TurretedInfo>,
Requires<ArmamentInfo>, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> Requires<ArmamentInfo>, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use.")] [Desc("Sequence name to use.")]
[SequenceReference] public readonly string Sequence = "barrel"; [SequenceReference] public readonly string Sequence = "barrel";
@@ -59,13 +59,13 @@ namespace OpenRA.Mods.Common.Traits
readonly Actor self; readonly Actor self;
readonly Armament armament; readonly Armament armament;
readonly Turreted turreted; readonly Turreted turreted;
readonly IBodyOrientation body; readonly BodyOrientation body;
public WithBarrel(Actor self, WithBarrelInfo info) public WithBarrel(Actor self, WithBarrelInfo info)
: base(info) : base(info)
{ {
this.self = self; this.self = self;
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
armament = self.TraitsImplementing<Armament>() armament = self.TraitsImplementing<Armament>()
.First(a => a.Info.Name == Info.Armament); .First(a => a.Info.Name == Info.Armament);
turreted = self.TraitsImplementing<Turreted>() turreted = self.TraitsImplementing<Turreted>()

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Rendered when the actor constructed a building.")] [Desc("Rendered when the actor constructed a building.")]
public class WithBuildingPlacedOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> public class WithBuildingPlacedOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "crane-overlay"; [SequenceReference] public readonly string Sequence = "crane-overlay";
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
public WithBuildingPlacedOverlay(Actor self, WithBuildingPlacedOverlayInfo info) public WithBuildingPlacedOverlay(Actor self, WithBuildingPlacedOverlayInfo info)
{ {
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
buildComplete = !self.HasTrait<Building>(); // always render instantly for units buildComplete = !self.HasTrait<Building>(); // always render instantly for units

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Rendered when a harvester is docked.")] [Desc("Rendered when a harvester is docked.")]
public class WithDockingOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> public class WithDockingOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "docking-overlay"; [SequenceReference] public readonly string Sequence = "docking-overlay";
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
this.info = info; this.info = info;
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
buildComplete = !self.HasTrait<Building>(); // always render instantly for units buildComplete = !self.HasTrait<Building>(); // always render instantly for units

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public class WithFacingSpriteBodyInfo : WithSpriteBodyInfo, Requires<IBodyOrientationInfo>, Requires<IFacingInfo> public class WithFacingSpriteBodyInfo : WithSpriteBodyInfo, Requires<BodyOrientationInfo>, Requires<IFacingInfo>
{ {
public override object Create(ActorInitializer init) { return new WithFacingSpriteBody(init, this); } public override object Create(ActorInitializer init) { return new WithFacingSpriteBody(init, this); }

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Displays an overlay whenever resources are harvested by the actor.")] [Desc("Displays an overlay whenever resources are harvested by the actor.")]
class WithHarvestOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> class WithHarvestOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "harvest"; [SequenceReference] public readonly string Sequence = "harvest";
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
this.info = info; this.info = info;
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
anim = new Animation(self.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self)); anim = new Animation(self.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self));
anim.IsDecoration = true; anim.IsDecoration = true;

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Renders a decorative animation on units and buildings.")] [Desc("Renders a decorative animation on units and buildings.")]
public class WithIdleOverlayInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> public class WithIdleOverlayInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Animation to play when the actor is created.")] [Desc("Animation to play when the actor is created.")]
[SequenceReference] public readonly string StartSequence = null; [SequenceReference] public readonly string StartSequence = null;
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
: base(info) : base(info)
{ {
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
buildComplete = !self.HasTrait<Building>(); // always render instantly for units buildComplete = !self.HasTrait<Building>(); // always render instantly for units
overlay = new Animation(self.World, rs.GetImage(self)); overlay = new Animation(self.World, rs.GetImage(self));

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Renders a parachute on units.")] [Desc("Renders a parachute on units.")]
public class WithParachuteInfo : UpgradableTraitInfo, ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> public class WithParachuteInfo : UpgradableTraitInfo, ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("The image that contains the parachute sequences.")] [Desc("The image that contains the parachute sequences.")]
public readonly string Image = null; public readonly string Image = null;
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
// For this, info.Image must not be null // For this, info.Image must not be null
var overlay = new Animation(self.World, info.Image); var overlay = new Animation(self.World, info.Image);
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
anim = new AnimationWithOffset(overlay, anim = new AnimationWithOffset(overlay,
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
() => IsTraitDisabled && !renderProlonged, () => IsTraitDisabled && !renderProlonged,

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Play an animation when a unit exits or blocks the exit after production finished.")] [Desc("Play an animation when a unit exits or blocks the exit after production finished.")]
class WithProductionDoorOverlayInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>, Requires<BuildingInfo> class WithProductionDoorOverlayInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>, Requires<BuildingInfo>
{ {
public readonly string Sequence = "build-door"; public readonly string Sequence = "build-door";

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Renders an animation when the Production trait of the actor is activated.", [Desc("Renders an animation when the Production trait of the actor is activated.",
"Works both with per player ClassicProductionQueue and per building ProductionQueue, but needs any of these.")] "Works both with per player ClassicProductionQueue and per building ProductionQueue, but needs any of these.")]
public class WithProductionOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>, Requires<ProductionInfo> public class WithProductionOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>, Requires<ProductionInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "production-overlay"; [SequenceReference] public readonly string Sequence = "production-overlay";
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
public WithProductionOverlay(Actor self, WithProductionOverlayInfo info) public WithProductionOverlay(Actor self, WithProductionOverlayInfo info)
{ {
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
buildComplete = !self.Info.Traits.Contains<BuildingInfo>(); // always render instantly for units buildComplete = !self.Info.Traits.Contains<BuildingInfo>(); // always render instantly for units
production = self.Info.Traits.Get<ProductionInfo>(); production = self.Info.Traits.Get<ProductionInfo>();

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Displays an overlay when the building is being repaired by the player.")] [Desc("Displays an overlay when the building is being repaired by the player.")]
public class WithRepairOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> public class WithRepairOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "active"; [SequenceReference] public readonly string Sequence = "active";
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
public WithRepairOverlay(Actor self, WithRepairOverlayInfo info) public WithRepairOverlay(Actor self, WithRepairOverlayInfo info)
{ {
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
buildComplete = !self.HasTrait<Building>(); // always render instantly for units buildComplete = !self.HasTrait<Building>(); // always render instantly for units
overlay = new Animation(self.World, rs.GetImage(self)); overlay = new Animation(self.World, rs.GetImage(self));

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Displays a helicopter rotor overlay.")] [Desc("Displays a helicopter rotor overlay.")]
public class WithRotorInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> public class WithRotorInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use when flying")] [Desc("Sequence name to use when flying")]
[SequenceReference] public readonly string Sequence = "rotor"; [SequenceReference] public readonly string Sequence = "rotor";
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
this.info = info; this.info = info;
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
movement = self.Trait<IMove>(); movement = self.Trait<IMove>();
rotorAnim = new Animation(self.World, rs.GetImage(self)); rotorAnim = new Animation(self.World, rs.GetImage(self));

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Renders turrets for units with the Turreted trait.")] [Desc("Renders turrets for units with the Turreted trait.")]
public class WithTurretInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, public class WithTurretInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo,
Requires<RenderSpritesInfo>, Requires<TurretedInfo>, Requires<IBodyOrientationInfo> Requires<RenderSpritesInfo>, Requires<TurretedInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "turret"; [SequenceReference] public readonly string Sequence = "turret";
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly Animation DefaultAnimation; public readonly Animation DefaultAnimation;
protected readonly AttackBase Attack; protected readonly AttackBase Attack;
readonly RenderSprites rs; readonly RenderSprites rs;
readonly IBodyOrientation body; readonly BodyOrientation body;
readonly Turreted t; readonly Turreted t;
readonly Armament[] arms; readonly Armament[] arms;
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
: base(info) : base(info)
{ {
rs = self.Trait<RenderSprites>(); rs = self.Trait<RenderSprites>();
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
Attack = self.TraitOrDefault<AttackBase>(); Attack = self.TraitOrDefault<AttackBase>();
t = self.TraitsImplementing<Turreted>() t = self.TraitsImplementing<Turreted>()
.First(tt => tt.Name == info.Turret); .First(tt => tt.Name == info.Turret);

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("This actor has turret art with facings baked into the sprite.")] [Desc("This actor has turret art with facings baked into the sprite.")]
public class WithTurretedSpriteBodyInfo : WithSpriteBodyInfo, Requires<TurretedInfo>, Requires<IBodyOrientationInfo> public class WithTurretedSpriteBodyInfo : WithSpriteBodyInfo, Requires<TurretedInfo>, Requires<BodyOrientationInfo>
{ {
public override object Create(ActorInitializer init) { return new WithTurretedSpriteBody(init, this); } public override object Create(ActorInitializer init) { return new WithTurretedSpriteBody(init, this); }

View File

@@ -56,13 +56,13 @@ namespace OpenRA.Mods.Common.Traits
readonly Actor self; readonly Actor self;
readonly Armament armament; readonly Armament armament;
readonly Turreted turreted; readonly Turreted turreted;
readonly IBodyOrientation body; readonly BodyOrientation body;
public WithVoxelBarrel(Actor self, WithVoxelBarrelInfo info) public WithVoxelBarrel(Actor self, WithVoxelBarrelInfo info)
: base(info) : base(info)
{ {
this.self = self; this.self = self;
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
armament = self.TraitsImplementing<Armament>() armament = self.TraitsImplementing<Armament>()
.First(a => a.Info.Name == Info.Armament); .First(a => a.Info.Name == Info.Armament);
turreted = self.TraitsImplementing<Turreted>() turreted = self.TraitsImplementing<Turreted>()

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
public WithVoxelBody(Actor self, WithVoxelBodyInfo info) public WithVoxelBody(Actor self, WithVoxelBodyInfo info)
: base(info) : base(info)
{ {
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
var rv = self.Trait<RenderVoxels>(); var rv = self.Trait<RenderVoxels>();
var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence); var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence);

View File

@@ -49,13 +49,13 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly Actor self; readonly Actor self;
readonly Turreted turreted; readonly Turreted turreted;
readonly IBodyOrientation body; readonly BodyOrientation body;
public WithVoxelTurret(Actor self, WithVoxelTurretInfo info) public WithVoxelTurret(Actor self, WithVoxelTurretInfo info)
: base(info) : base(info)
{ {
this.self = self; this.self = self;
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
turreted = self.TraitsImplementing<Turreted>() turreted = self.TraitsImplementing<Turreted>()
.First(tt => tt.Name == Info.Turret); .First(tt => tt.Name == Info.Turret);

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
class SmokeTrailWhenDamagedInfo : ITraitInfo, Requires<IBodyOrientationInfo> class SmokeTrailWhenDamagedInfo : ITraitInfo, Requires<BodyOrientationInfo>
{ {
[Desc("Position relative to body")] [Desc("Position relative to body")]
public readonly WVec Offset = WVec.Zero; public readonly WVec Offset = WVec.Zero;
@@ -29,13 +29,13 @@ namespace OpenRA.Mods.Common.Traits
class SmokeTrailWhenDamaged : ITick class SmokeTrailWhenDamaged : ITick
{ {
readonly SmokeTrailWhenDamagedInfo info; readonly SmokeTrailWhenDamagedInfo info;
readonly IBodyOrientation body; readonly BodyOrientation body;
int ticks; int ticks;
public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info) public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
{ {
this.info = info; this.info = info;
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
} }
public void Tick(Actor self) public void Tick(Actor self)

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
class NukePowerInfo : SupportPowerInfo, Requires<IBodyOrientationInfo> class NukePowerInfo : SupportPowerInfo, Requires<BodyOrientationInfo>
{ {
[WeaponReference] [WeaponReference]
public readonly string MissileWeapon = ""; public readonly string MissileWeapon = "";
@@ -57,12 +57,12 @@ namespace OpenRA.Mods.Common.Traits
class NukePower : SupportPower class NukePower : SupportPower
{ {
readonly NukePowerInfo info; readonly NukePowerInfo info;
readonly IBodyOrientation body; readonly BodyOrientation body;
public NukePower(Actor self, NukePowerInfo info) public NukePower(Actor self, NukePowerInfo info)
: base(self, info) : base(self, info)
{ {
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
this.info = info; this.info = info;
} }

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
class ThrowsParticleInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<IBodyOrientationInfo> class ThrowsParticleInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<BodyOrientationInfo>
{ {
[FieldLoader.Require] [FieldLoader.Require]
public readonly string Anim = null; public readonly string Anim = null;
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
var self = init.Self; var self = init.Self;
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
// TODO: Carry orientation over from the parent instead of just facing // TODO: Carry orientation over from the parent instead of just facing
var bodyFacing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : 0; var bodyFacing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : 0;

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public class TurretedInfo : ITraitInfo, UsesInit<TurretFacingInit>, Requires<IBodyOrientationInfo> public class TurretedInfo : ITraitInfo, UsesInit<TurretFacingInit>, Requires<BodyOrientationInfo>
{ {
public readonly string Turret = "primary"; public readonly string Turret = "primary";
[Desc("Rate of Turning")] [Desc("Rate of Turning")]
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
readonly TurretedInfo info; readonly TurretedInfo info;
AttackTurreted attack; AttackTurreted attack;
IFacing facing; IFacing facing;
IBodyOrientation body; BodyOrientation body;
[Sync] public int QuantizedFacings = 0; [Sync] public int QuantizedFacings = 0;
[Sync] public int TurretFacing = 0; [Sync] public int TurretFacing = 0;
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
attack = self.TraitOrDefault<AttackTurreted>(); attack = self.TraitOrDefault<AttackTurreted>();
facing = self.TraitOrDefault<IFacing>(); facing = self.TraitOrDefault<IFacing>();
body = self.Trait<IBodyOrientation>(); body = self.Trait<BodyOrientation>();
} }
public virtual void Tick(Actor self) public virtual void Tick(Actor self)

View File

@@ -25,20 +25,6 @@ namespace OpenRA.Mods.Common.Traits
void PlayCustomAnimationBackwards(Actor self, string name, Action after); void PlayCustomAnimationBackwards(Actor self, string name, Action after);
} }
public interface IBodyOrientation
{
WAngle CameraPitch { get; }
int QuantizedFacings { get; }
WVec LocalToWorld(WVec vec);
WRot QuantizeOrientation(Actor self, WRot orientation);
}
public interface IBodyOrientationInfo : ITraitInfo
{
WVec LocalToWorld(WVec vec);
WRot QuantizeOrientation(WRot orientation, int facings);
}
public interface IQuantizeBodyOrientationInfo : ITraitInfo public interface IQuantizeBodyOrientationInfo : ITraitInfo
{ {
int QuantizedBodyFacings(ActorInfo ai, SequenceProvider sequenceProvider, string race); int QuantizedBodyFacings(ActorInfo ai, SequenceProvider sequenceProvider, string race);

View File

@@ -20,7 +20,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.D2k.Traits namespace OpenRA.Mods.D2k.Traits
{ {
[Desc("Automatically transports harvesters with the Carryable trait between resource fields and refineries.")] [Desc("Automatically transports harvesters with the Carryable trait between resource fields and refineries.")]
public class CarryallInfo : ITraitInfo, Requires<IBodyOrientationInfo> public class CarryallInfo : ITraitInfo, Requires<BodyOrientationInfo>
{ {
[Desc("Set to false when the carryall should not automatically get new jobs.")] [Desc("Set to false when the carryall should not automatically get new jobs.")]
public readonly bool Automatic = true; public readonly bool Automatic = true;

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.D2k.Traits namespace OpenRA.Mods.D2k.Traits
{ {
[Desc("Rendered when ProductionAirdrop is in progress.")] [Desc("Rendered when ProductionAirdrop is in progress.")]
public class WithDeliveryOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo> public class WithDeliveryOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "active"; [SequenceReference] public readonly string Sequence = "active";
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.D2k.Traits
this.info = info; this.info = info;
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
// always render instantly for units // always render instantly for units
buildComplete = !self.HasTrait<Building>(); buildComplete = !self.HasTrait<Building>();

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.TS.Traits
public WithVoxelUnloadBody(Actor self, WithVoxelUnloadBodyInfo info) public WithVoxelUnloadBody(Actor self, WithVoxelUnloadBodyInfo info)
{ {
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
var rv = self.Trait<RenderVoxels>(); var rv = self.Trait<RenderVoxels>();
var idleVoxel = VoxelProvider.GetVoxel(rv.Image, info.IdleSequence); var idleVoxel = VoxelProvider.GetVoxel(rv.Image, info.IdleSequence);

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.TS.Traits
this.info = info; this.info = info;
movement = self.Trait<IMove>(); movement = self.Trait<IMove>();
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
var rv = self.Trait<RenderVoxels>(); var rv = self.Trait<RenderVoxels>();
var voxel = VoxelProvider.GetVoxel(rv.Image, "idle"); var voxel = VoxelProvider.GetVoxel(rv.Image, "idle");

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.TS.Traits
{ {
this.self = self; this.self = self;
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<BodyOrientation>();
var rv = self.Trait<RenderVoxels>(); var rv = self.Trait<RenderVoxels>();
var landVoxel = VoxelProvider.GetVoxel(rv.Image, info.LandSequence); var landVoxel = VoxelProvider.GetVoxel(rv.Image, info.LandSequence);