Move Facing and Altitude onto IMove impls, with associated pile of cleanups
This commit is contained in:
@@ -136,8 +136,8 @@ namespace OpenRA
|
||||
|
||||
if (useAltitude)
|
||||
{
|
||||
var unit = traits.GetOrDefault<Unit>();
|
||||
if (unit != null) loc -= new float2(0, unit.Altitude);
|
||||
var move = traits.GetOrDefault<IMove>();
|
||||
if (move != null) loc -= new float2(0, move.Altitude);
|
||||
}
|
||||
|
||||
return new RectangleF(loc.X, loc.Y, size.X, size.Y);
|
||||
|
||||
@@ -90,7 +90,6 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var mobile = self.traits.Get<Mobile>();
|
||||
|
||||
if( move != null )
|
||||
@@ -127,8 +126,8 @@ namespace OpenRA.Traits.Activities
|
||||
return this;
|
||||
|
||||
int2 dir = nextCell.Value - mobile.fromCell;
|
||||
var firstFacing = Util.GetFacing( dir, unit.Facing );
|
||||
if( firstFacing != unit.Facing )
|
||||
var firstFacing = Util.GetFacing( dir, mobile.Facing );
|
||||
if( firstFacing != mobile.Facing )
|
||||
{
|
||||
path.Add( nextCell.Value );
|
||||
|
||||
@@ -140,8 +139,8 @@ namespace OpenRA.Traits.Activities
|
||||
move = new MoveFirstHalf(
|
||||
Util.CenterOfCell( mobile.fromCell ),
|
||||
Util.BetweenCells( mobile.fromCell, mobile.toCell ),
|
||||
unit.Facing,
|
||||
unit.Facing,
|
||||
mobile.Facing,
|
||||
mobile.Facing,
|
||||
0 );
|
||||
|
||||
move.TickMove( self, mobile, this );
|
||||
@@ -262,9 +261,9 @@ namespace OpenRA.Traits.Activities
|
||||
self.CenterLocation = float2.Lerp( from, to, frac );
|
||||
|
||||
if( moveFraction >= moveFractionTotal )
|
||||
unit.Facing = toFacing & 0xFF;
|
||||
mobile.Facing = toFacing & 0xFF;
|
||||
else
|
||||
unit.Facing = ( fromFacing + ( toFacing - fromFacing ) * moveFraction / moveFractionTotal ) & 0xFF;
|
||||
mobile.Facing = ( fromFacing + ( toFacing - fromFacing ) * moveFraction / moveFractionTotal ) & 0xFF;
|
||||
}
|
||||
|
||||
protected abstract MovePart OnComplete( Actor self, Mobile mobile, Move parent );
|
||||
@@ -289,8 +288,8 @@ namespace OpenRA.Traits.Activities
|
||||
var ret = new MoveFirstHalf(
|
||||
Util.BetweenCells( mobile.fromCell, mobile.toCell ),
|
||||
Util.BetweenCells( mobile.toCell, nextCell.Value ),
|
||||
unit.Facing,
|
||||
Util.GetNearestFacing( unit.Facing, Util.GetFacing( nextCell.Value - mobile.toCell, unit.Facing ) ),
|
||||
mobile.Facing,
|
||||
Util.GetNearestFacing( mobile.Facing, Util.GetFacing( nextCell.Value - mobile.toCell, mobile.Facing ) ),
|
||||
moveFraction - moveFractionTotal );
|
||||
mobile.fromCell = mobile.toCell;
|
||||
mobile.toCell = nextCell.Value;
|
||||
@@ -302,8 +301,8 @@ namespace OpenRA.Traits.Activities
|
||||
var ret2 = new MoveSecondHalf(
|
||||
Util.BetweenCells( mobile.fromCell, mobile.toCell ),
|
||||
Util.CenterOfCell( mobile.toCell ),
|
||||
unit.Facing,
|
||||
unit.Facing,
|
||||
mobile.Facing,
|
||||
mobile.Facing,
|
||||
moveFraction - moveFractionTotal );
|
||||
mobile.fromCell = mobile.toCell;
|
||||
return ret2;
|
||||
|
||||
@@ -25,22 +25,22 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var mobile = self.traits.Get<IMove>();
|
||||
var ROT = self.traits.Get<IMove>().ROT;
|
||||
|
||||
if( desiredFacing == unit.Facing )
|
||||
if( desiredFacing == mobile.Facing )
|
||||
return NextActivity;
|
||||
|
||||
Util.TickFacing(ref unit.Facing, desiredFacing, ROT);
|
||||
mobile.Facing = Util.TickFacing(mobile.Facing, desiredFacing, ROT);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel( Actor self )
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var mobile = self.traits.Get<IMove>();
|
||||
|
||||
desiredFacing = unit.Facing;
|
||||
desiredFacing = mobile.Facing;
|
||||
NextActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,13 @@ namespace OpenRA.Traits
|
||||
public readonly Dictionary<string,float> TerrainSpeed;
|
||||
|
||||
[Sync]
|
||||
public int Facing { get; set; }
|
||||
[Sync]
|
||||
public int Altitude { get; set; }
|
||||
[Sync]
|
||||
public int ROT { get { return Info.ROT; } }
|
||||
public int InitialFacing { get { return Info.InitialFacing; } }
|
||||
|
||||
int2 __fromCell, __toCell;
|
||||
public int2 fromCell
|
||||
{
|
||||
@@ -90,9 +97,6 @@ namespace OpenRA.Traits
|
||||
TerrainSpeed.Add(info.TerrainTypes[i], info.TerrainSpeeds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public int ROT { get { return Info.ROT; } }
|
||||
public int InitialFacing { get { return Info.InitialFacing; } }
|
||||
|
||||
public void SetPosition(Actor self, int2 cell)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Traits
|
||||
return false;
|
||||
|
||||
var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner );
|
||||
newUnit.traits.Get<Unit>().Facing = CreationFacing( self, newUnit ); ;
|
||||
newUnit.traits.Get<IMove>().Facing = CreationFacing( self, newUnit ); ;
|
||||
|
||||
var pi = self.Info.Traits.Get<ProductionInfo>();
|
||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||
|
||||
@@ -156,11 +156,10 @@ namespace OpenRA.Traits
|
||||
{
|
||||
if (!Game.world.LocalPlayer.PlayerActor.traits.Get<DeveloperMode>().PathDebug) return;
|
||||
|
||||
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
var mobile = self.traits.GetOrDefault<IMove>();
|
||||
if (mobile != null)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var alt = (unit != null)? new float2(0, -unit.Altitude) : float2.Zero;
|
||||
var alt = new float2(0, -mobile.Altitude);
|
||||
var path = mobile.GetCurrentPath(self);
|
||||
var start = self.CenterLocation + alt;
|
||||
|
||||
|
||||
@@ -111,6 +111,8 @@ namespace OpenRA.Traits
|
||||
float MovementSpeedForCell(Actor self, int2 cell);
|
||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||
int ROT { get; }
|
||||
int Altitude { get; set; }
|
||||
int Facing { get; set; }
|
||||
int InitialFacing { get; }
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class TurretedInfo : ITraitInfo
|
||||
public class TurretedInfo : ITraitInfo
|
||||
{
|
||||
public readonly int ROT = 255;
|
||||
public readonly int InitialFacing = 128;
|
||||
|
||||
public object Create(ActorInitializer init) { return new Turreted(init.self); }
|
||||
public object Create(ActorInitializer init) { return new Turreted(init.self, this); }
|
||||
}
|
||||
|
||||
public class Turreted : ITick
|
||||
@@ -23,16 +23,20 @@ namespace OpenRA.Traits
|
||||
[Sync]
|
||||
public int turretFacing = 0;
|
||||
public int? desiredFacing;
|
||||
|
||||
public Turreted(Actor self)
|
||||
TurretedInfo Info;
|
||||
IMove Move;
|
||||
|
||||
public Turreted(Actor self, TurretedInfo info)
|
||||
{
|
||||
turretFacing = self.Info.Traits.Get<TurretedInfo>().InitialFacing;
|
||||
Info = info;
|
||||
turretFacing = info.InitialFacing;
|
||||
Move = self.traits.GetOrDefault<IMove>();
|
||||
}
|
||||
|
||||
public void Tick( Actor self )
|
||||
{
|
||||
var df = desiredFacing ?? ( self.traits.Contains<Unit>() ? self.traits.Get<Unit>().Facing : turretFacing );
|
||||
Util.TickFacing(ref turretFacing, df, self.Info.Traits.Get<TurretedInfo>().ROT);
|
||||
var df = desiredFacing ?? ( Move != null ? Move.Facing : turretFacing );
|
||||
turretFacing = Util.TickFacing(turretFacing, df, Info.ROT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,7 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
public class Unit : INotifyDamage, IRadarSignature
|
||||
{
|
||||
[Sync]
|
||||
public int Facing;
|
||||
[Sync]
|
||||
public int Altitude;
|
||||
|
||||
{
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
|
||||
@@ -17,16 +17,16 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public static class Util
|
||||
{
|
||||
public static void TickFacing( ref int facing, int desiredFacing, int rot )
|
||||
public static int TickFacing( int facing, int desiredFacing, int rot )
|
||||
{
|
||||
var leftTurn = ( facing - desiredFacing ) & 0xFF;
|
||||
var rightTurn = ( desiredFacing - facing ) & 0xFF;
|
||||
if( Math.Min( leftTurn, rightTurn ) < rot )
|
||||
facing = desiredFacing & 0xFF;
|
||||
return desiredFacing & 0xFF;
|
||||
else if( rightTurn < leftTurn )
|
||||
facing = ( facing + rot ) & 0xFF;
|
||||
return ( facing + rot ) & 0xFF;
|
||||
else
|
||||
facing = ( facing - rot ) & 0xFF;
|
||||
return ( facing - rot ) & 0xFF;
|
||||
}
|
||||
|
||||
static float2[] fvecs = Graphics.Util.MakeArray<float2>( 32,
|
||||
|
||||
@@ -84,17 +84,17 @@ namespace OpenRA.Traits
|
||||
int offsetTicks = 0;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var move = self.traits.Get<IMove>();
|
||||
//if (unit.Altitude <= 0)
|
||||
// return;
|
||||
|
||||
if (unit.Altitude < AirInfo.CruiseAltitude)
|
||||
unit.Altitude++;
|
||||
if (move.Altitude < AirInfo.CruiseAltitude)
|
||||
move.Altitude++;
|
||||
|
||||
if (--offsetTicks <= 0)
|
||||
{
|
||||
self.CenterLocation += AirInfo.InstabilityMagnitude * self.World.SharedRandom.Gauss2D(5);
|
||||
unit.Altitude += (int)(AirInfo.InstabilityMagnitude * self.World.SharedRandom.Gauss1D(5));
|
||||
move.Altitude += (int)(AirInfo.InstabilityMagnitude * self.World.SharedRandom.Gauss1D(5));
|
||||
offsetTicks = AirInfo.InstabilityTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,9 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
var a = w.CreateActor("C17", startPos, owner);
|
||||
var cargo = a.traits.Get<Cargo>();
|
||||
a.traits.Get<Unit>().Facing = 64;
|
||||
a.traits.Get<Unit>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
var aMove = a.traits.Get<IMove>();
|
||||
aMove.Facing = 64;
|
||||
aMove.Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
|
||||
var newUnit = new Actor(self.World, producee.Name, new int2(0, 0), self.Owner);
|
||||
cargo.Load(a, newUnit);
|
||||
@@ -58,8 +59,8 @@ namespace OpenRA.Mods.Cnc
|
||||
self.World.AddFrameEndTask(ww =>
|
||||
{
|
||||
ww.Add(actor);
|
||||
actor.traits.WithInterface<IMove>().FirstOrDefault().SetPosition(actor, self.Location + unloadOffset);
|
||||
newUnit.traits.Get<Unit>().Facing = 192;
|
||||
actor.traits.Get<IMove>().SetPosition(actor, self.Location + unloadOffset);
|
||||
newUnit.traits.Get<IMove>().Facing = 192;
|
||||
actor.CancelActivity();
|
||||
actor.QueueActivity(new Move(self.Location + exitOffset, self));
|
||||
actor.QueueActivity(new Move(rp.rallyPoint, 0));
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var move = self.traits.Get<IMove>();
|
||||
|
||||
if (!Target.IsValid)
|
||||
return NextActivity;
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var numDirs = (renderUnit != null)
|
||||
? renderUnit.anim.CurrentSequence.Facings : 8;
|
||||
|
||||
if (Util.QuantizeFacing(unit.Facing, numDirs)
|
||||
if (Util.QuantizeFacing(move.Facing, numDirs)
|
||||
!= Util.QuantizeFacing(desiredFacing, numDirs))
|
||||
{
|
||||
return new Turn( desiredFacing ) { NextActivity = this };
|
||||
|
||||
@@ -34,15 +34,14 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (d.LengthSquared < 50) /* close enough */
|
||||
return NextActivity;
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
var desiredFacing = Util.GetFacing(d, unit.Facing);
|
||||
if (unit.Altitude == cruiseAltitude)
|
||||
Util.TickFacing(ref unit.Facing, desiredFacing,
|
||||
self.Info.Traits.Get<AircraftInfo>().ROT);
|
||||
var desiredFacing = Util.GetFacing(d, aircraft.Facing);
|
||||
if (aircraft.Altitude == cruiseAltitude)
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
|
||||
|
||||
if (unit.Altitude < cruiseAltitude)
|
||||
++unit.Altitude;
|
||||
if (aircraft.Altitude < cruiseAltitude)
|
||||
++aircraft.Altitude;
|
||||
|
||||
FlyUtil.Fly(self, cruiseAltitude);
|
||||
return this;
|
||||
@@ -55,16 +54,12 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public static void Fly(Actor self, int desiredAltitude )
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
var speed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||
var angle = unit.Facing / 128f * Math.PI;
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
var angle = aircraft.Facing / 128f * Math.PI;
|
||||
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||
|
||||
unit.Altitude += Math.Sign(desiredAltitude - unit.Altitude);
|
||||
aircraft.Altitude += Math.Sign(desiredAltitude - aircraft.Altitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,22 +32,21 @@ namespace OpenRA.Mods.RA.Activities
|
||||
self.QueueActivity(new HeliReturn());
|
||||
return NextActivity;
|
||||
}
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||
if (unit.Altitude != info.CruiseAltitude)
|
||||
if (aircraft.Altitude != info.CruiseAltitude)
|
||||
{
|
||||
unit.Altitude += Math.Sign(info.CruiseAltitude - unit.Altitude);
|
||||
aircraft.Altitude += Math.Sign(info.CruiseAltitude - aircraft.Altitude);
|
||||
return this;
|
||||
}
|
||||
|
||||
var range = self.traits.Get<AttackBase>().GetMaximumRange() - 1;
|
||||
var dist = target.CenterLocation - self.CenterLocation;
|
||||
|
||||
var desiredFacing = Util.GetFacing(dist, unit.Facing);
|
||||
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get<AircraftInfo>().ROT);
|
||||
|
||||
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
var rawSpeed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||
var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
|
||||
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
|
||||
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||
|
||||
@@ -30,13 +30,12 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (isCanceled)
|
||||
return NextActivity;
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
if (unit.Altitude != info.CruiseAltitude)
|
||||
if (aircraft.Altitude != info.CruiseAltitude)
|
||||
{
|
||||
unit.Altitude += Math.Sign(info.CruiseAltitude - unit.Altitude);
|
||||
aircraft.Altitude += Math.Sign(info.CruiseAltitude - aircraft.Altitude);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -48,12 +47,11 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
var desiredFacing = Util.GetFacing(dist, unit.Facing);
|
||||
Util.TickFacing(ref unit.Facing, desiredFacing,
|
||||
self.Info.Traits.Get<AircraftInfo>().ROT);
|
||||
var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing,
|
||||
aircraft.ROT);
|
||||
|
||||
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
var rawSpeed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (isCanceled) return NextActivity;
|
||||
var unit = self.traits.Get<Unit>();
|
||||
if (unit.Altitude == 0)
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
if (aircraft.Altitude == 0)
|
||||
return NextActivity;
|
||||
|
||||
if (requireSpace && !self.traits.Get<IMove>().CanEnterCell(self.Location))
|
||||
if (requireSpace && !aircraft.CanEnterCell(self.Location))
|
||||
return this;
|
||||
|
||||
--unit.Altitude;
|
||||
--aircraft.Altitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,15 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (d.LengthSquared < 50) /* close enough */
|
||||
return NextActivity;
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
if (unit.Altitude > 0)
|
||||
--unit.Altitude;
|
||||
if (aircraft.Altitude > 0)
|
||||
--aircraft.Altitude;
|
||||
|
||||
var desiredFacing = Util.GetFacing(d, unit.Facing);
|
||||
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get<AircraftInfo>().ROT);
|
||||
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
var speed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||
var angle = unit.Facing / 128f * Math.PI;
|
||||
var desiredFacing = Util.GetFacing(d, aircraft.Facing);
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
|
||||
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
var angle = aircraft.Facing / 128f * Math.PI;
|
||||
|
||||
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||
|
||||
@@ -41,15 +41,15 @@ namespace OpenRA.Mods.RA.Activities
|
||||
self.traits.Get<Plane>().reservation = res.Reserve(self);
|
||||
|
||||
var landPos = dest.CenterLocation;
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
var speed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
|
||||
var approachStart = landPos - new float2(unit.Altitude * speed, 0);
|
||||
var approachStart = landPos - new float2(aircraft.Altitude * speed, 0);
|
||||
var turnRadius = (128f / self.Info.Traits.Get<AircraftInfo>().ROT) * speed / (float)Math.PI;
|
||||
|
||||
/* work out the center points */
|
||||
var fwd = -float2.FromAngle(unit.Facing / 128f * (float)Math.PI);
|
||||
var fwd = -float2.FromAngle(aircraft.Facing / 128f * (float)Math.PI);
|
||||
var side = new float2(-fwd.Y, fwd.X); /* rotate */
|
||||
var sideTowardBase = new[] { side, -side }
|
||||
.OrderBy(a => float2.Dot(a, self.CenterLocation - approachStart))
|
||||
|
||||
@@ -58,9 +58,9 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (oldHealth != null && newHealth != null)
|
||||
newHealth.HPFraction = oldHealth.HPFraction;
|
||||
|
||||
var unit = a.traits.GetOrDefault<Unit>();
|
||||
if (unit != null)
|
||||
unit.Facing = facing;
|
||||
var move = a.traits.GetOrDefault<IMove>();
|
||||
if (move != null)
|
||||
move.Facing = facing;
|
||||
|
||||
if (selected)
|
||||
w.Selection.Add(w, a);
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
// if we're a thing that can turn, turn to the
|
||||
// right facing for the unload animation
|
||||
var unit = self.traits.GetOrDefault<Unit>();
|
||||
var move = self.traits.GetOrDefault<IMove>();
|
||||
var unloadFacing = self.Info.Traits.Get<CargoInfo>().UnloadFacing;
|
||||
if (unit != null && unit.Facing != unloadFacing)
|
||||
if (move != null && move.Facing != unloadFacing)
|
||||
return new Turn(unloadFacing) { NextActivity = this };
|
||||
|
||||
// todo: handle the BS of open/close sequences, which are inconsistent,
|
||||
|
||||
@@ -32,6 +32,11 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Sync]
|
||||
public int2 Location;
|
||||
[Sync]
|
||||
public int Facing { get; set; }
|
||||
[Sync]
|
||||
public int Altitude { get; set; }
|
||||
|
||||
AircraftInfo Info;
|
||||
|
||||
public Aircraft( ActorInitializer init , AircraftInfo info)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
@@ -102,15 +102,13 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
if( !CanAttack( self ) ) return;
|
||||
|
||||
var unit = self.traits.GetOrDefault<Unit>();
|
||||
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
||||
|
||||
var move = self.traits.GetOrDefault<IMove>();
|
||||
foreach (var w in Weapons)
|
||||
if (CheckFire(self, unit, w))
|
||||
if (CheckFire(self, move, w))
|
||||
w.FiredShot();
|
||||
}
|
||||
|
||||
bool CheckFire(Actor self, Unit unit, Weapon w)
|
||||
bool CheckFire(Actor self, IMove move, Weapon w)
|
||||
{
|
||||
if (w.FireDelay > 0) return false;
|
||||
|
||||
@@ -124,8 +122,7 @@ namespace OpenRA.Mods.RA
|
||||
if (!w.IsValidAgainst(target)) return false;
|
||||
|
||||
var barrel = w.Barrels[w.Burst % w.Barrels.Length];
|
||||
|
||||
var destUnit = target.IsActor ? target.Actor.traits.GetOrDefault<Unit>() : null;
|
||||
var destMove = target.IsActor ? target.Actor.traits.GetOrDefault<IMove>() : null;
|
||||
|
||||
var args = new ProjectileArgs
|
||||
{
|
||||
@@ -135,15 +132,15 @@ namespace OpenRA.Mods.RA
|
||||
target = this.target,
|
||||
|
||||
src = (self.CenterLocation
|
||||
+ Combat.GetTurretPosition(self, unit, w.Turret)
|
||||
+ Combat.GetBarrelPosition(self, unit, w.Turret, barrel)).ToInt2(),
|
||||
srcAltitude = unit != null ? unit.Altitude : 0,
|
||||
+ Combat.GetTurretPosition(self, move, w.Turret)
|
||||
+ Combat.GetBarrelPosition(self, move, w.Turret, barrel)).ToInt2(),
|
||||
srcAltitude = move != null ? move.Altitude : 0,
|
||||
dest = target.CenterLocation.ToInt2(),
|
||||
destAltitude = destUnit != null ? destUnit.Altitude : 0,
|
||||
destAltitude = destMove != null ? destMove.Altitude : 0,
|
||||
|
||||
facing = barrel.Facing +
|
||||
(self.traits.Contains<Turreted>() ? self.traits.Get<Turreted>().turretFacing :
|
||||
unit != null ? unit.Facing : Util.GetFacing(target.CenterLocation - self.CenterLocation, 0)),
|
||||
move != null ? move.Facing : Util.GetFacing(target.CenterLocation - self.CenterLocation, 0)),
|
||||
};
|
||||
|
||||
ScheduleDelayedAction( FireDelay( self, self.Info.Traits.Get<AttackBaseInfo>() ), () =>
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
if (!target.IsValid) return;
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var facingToTarget = Util.GetFacing(target.CenterLocation - self.CenterLocation, unit.Facing);
|
||||
var move = self.traits.Get<IMove>();
|
||||
var facingToTarget = Util.GetFacing(target.CenterLocation - self.CenterLocation, move.Facing);
|
||||
|
||||
if (Math.Abs(facingToTarget - unit.Facing) % 256 < FacingTolerance)
|
||||
if (Math.Abs(facingToTarget - move.Facing) % 256 < FacingTolerance)
|
||||
DoAttack(self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ namespace OpenRA.Mods.RA
|
||||
return false;
|
||||
|
||||
// Cannot unload mid-air
|
||||
var unit = self.traits.GetOrDefault<Unit>();
|
||||
if (unit != null && unit.Altitude > 0)
|
||||
var move = self.traits.GetOrDefault<IMove>();
|
||||
if (move != null && move.Altitude > 0)
|
||||
return false;
|
||||
|
||||
// Todo: Check if there is a free tile to unload to
|
||||
|
||||
@@ -43,13 +43,14 @@ namespace OpenRA.Mods.RA
|
||||
var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
||||
dropDelay = weapon.ROF;
|
||||
|
||||
var move = self.traits.Get<IMove>();
|
||||
var args = new ProjectileArgs
|
||||
{
|
||||
srcAltitude = self.traits.Get<Unit>().Altitude,
|
||||
srcAltitude = move.Altitude,
|
||||
destAltitude = 0,
|
||||
src = self.CenterLocation.ToInt2(),
|
||||
dest = self.CenterLocation.ToInt2(),
|
||||
facing = self.traits.Get<Unit>().Facing,
|
||||
facing = move.Facing,
|
||||
firedBy = self,
|
||||
weapon = weapon
|
||||
};
|
||||
|
||||
@@ -193,13 +193,13 @@ namespace OpenRA.Mods.RA
|
||||
return Util.RotateVectorByFacing(localRecoil, facing, .7f);
|
||||
}
|
||||
|
||||
public static float2 GetTurretPosition(Actor self, Unit unit, Turret turret)
|
||||
public static float2 GetTurretPosition(Actor self, IMove move, Turret turret)
|
||||
{
|
||||
if (unit == null) return turret.ScreenSpacePosition;
|
||||
if(move == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */
|
||||
|
||||
var ru = self.traits.GetOrDefault<RenderUnit>();
|
||||
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
|
||||
var bodyFacing = unit.Facing;
|
||||
var bodyFacing = move.Facing;
|
||||
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
||||
|
||||
return (Util.RotateVectorByFacing(turret.UnitSpacePosition, quantizedFacing, .7f)
|
||||
@@ -208,14 +208,14 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
// gets the screen-space position of a barrel.
|
||||
public static float2 GetBarrelPosition(Actor self, Unit unit, Turret turret, Barrel barrel)
|
||||
public static float2 GetBarrelPosition(Actor self, IMove move, Turret turret, Barrel barrel)
|
||||
{
|
||||
var turreted = self.traits.GetOrDefault<Turreted>();
|
||||
|
||||
if (turreted == null && unit == null)
|
||||
if (turreted == null && move == null)
|
||||
return float2.Zero;
|
||||
|
||||
var turretFacing = turreted != null ? turreted.turretFacing : unit.Facing;
|
||||
var turretFacing = turreted != null ? turreted.turretFacing : move.Facing;
|
||||
|
||||
return Util.RotateVectorByFacing(barrel.Position, turretFacing, .7f);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var startPos = w.ChooseRandomEdgeCell();
|
||||
var plane = w.CreateActor("BADR", startPos, w.WorldActor.Owner);
|
||||
plane.traits.Get<Unit>().Facing = Util.GetFacing(p - startPos, 0);
|
||||
var aircraft = plane.traits.Get<Aircraft>();
|
||||
aircraft.Facing = Util.GetFacing(p - startPos, 0);
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new FlyCircle(p));
|
||||
plane.traits.Get<ParaDrop>().SetLZ(p, null);
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Detonate(Actor self, Actor detonatedBy)
|
||||
{
|
||||
var unit = self.traits.GetOrDefault<Unit>();
|
||||
var move = self.traits.GetOrDefault<IMove>();
|
||||
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
||||
var altitude = unit != null ? unit.Altitude : 0;
|
||||
var altitude = move != null ? move.Altitude : 0;
|
||||
|
||||
self.World.AddFrameEndTask( w =>
|
||||
{
|
||||
|
||||
@@ -76,11 +76,11 @@ namespace OpenRA.Mods.RA.Effects
|
||||
var targetPosition = Args.target.CenterLocation + offset;
|
||||
|
||||
var targetAltitude = 0;
|
||||
if (Args.target.IsActor && Args.target.Actor.traits.Contains<Unit>())
|
||||
targetAltitude = Args.target.Actor.traits.Get<Unit>().Altitude;
|
||||
if (Args.target.IsActor && Args.target.Actor.traits.Contains<IMove>())
|
||||
targetAltitude = Args.target.Actor.traits.Get<IMove>().Altitude;
|
||||
Altitude += Math.Sign(targetAltitude - Altitude);
|
||||
|
||||
Traits.Util.TickFacing(ref Facing,
|
||||
Facing = Traits.Util.TickFacing(Facing,
|
||||
Traits.Util.GetFacing(targetPosition - Pos, Facing),
|
||||
Info.ROT);
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace OpenRA.Mods.RA
|
||||
var weapon = ChooseWeaponForExplosion(self);
|
||||
if (weapon != null)
|
||||
{
|
||||
var unit = self.traits.GetOrDefault<Unit>();
|
||||
var altitude = unit != null ? unit.Altitude : 0;
|
||||
var move = self.traits.GetOrDefault<IMove>();
|
||||
var altitude = move != null ? move.Altitude : 0;
|
||||
Combat.DoExplosion(e.Attacker, weapon, self.CenterLocation, altitude);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var a = w.CreateActor(info.Actor, self.Location
|
||||
+ info.SpawnOffset, self.Owner);
|
||||
var unit = a.traits.WithInterface<Unit>().FirstOrDefault();
|
||||
|
||||
if (unit != null)
|
||||
unit.Facing = info.Facing;
|
||||
|
||||
var move = a.traits.GetOrDefault<IMove>();
|
||||
if (move != null)
|
||||
move.Facing = info.Facing;
|
||||
|
||||
if (info.InitialActivity != null)
|
||||
a.QueueActivity(Game.CreateObject<IActivity>(info.InitialActivity));
|
||||
|
||||
@@ -129,12 +129,11 @@ namespace OpenRA.Mods.RA
|
||||
int offsetTicks = 0;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
if (unit.Altitude <= 0)
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
if (aircraft.Altitude <= 0)
|
||||
return;
|
||||
|
||||
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
var rawSpeed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, Info.IdealSeparation)
|
||||
.Where(a => a.traits.Contains<Helicopter>());
|
||||
|
||||
@@ -147,7 +146,7 @@ namespace OpenRA.Mods.RA
|
||||
if (--offsetTicks <= 0)
|
||||
{
|
||||
self.CenterLocation += Info.InstabilityMagnitude * self.World.SharedRandom.Gauss2D(5);
|
||||
unit.Altitude += (int)(Info.InstabilityMagnitude * self.World.SharedRandom.Gauss1D(5));
|
||||
aircraft.Altitude += (int)(Info.InstabilityMagnitude * self.World.SharedRandom.Gauss1D(5));
|
||||
offsetTicks = Info.InstabilityTicks;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@ namespace OpenRA.Mods.RA
|
||||
var info = self.Info.Traits.Get<LeavesHuskInfo>();
|
||||
var husk = w.CreateActor(info.HuskActor, self.Location, self.Owner);
|
||||
husk.CenterLocation = self.CenterLocation;
|
||||
husk.traits.Get<Unit>().Altitude = self.traits.Get<Unit>().Altitude;
|
||||
husk.traits.Get<Unit>().Facing = self.traits.Get<Unit>().Facing;
|
||||
var move = self.traits.Get<IMove>();
|
||||
var huskMove = husk.traits.Get<IMove>();
|
||||
huskMove.Altitude = move.Altitude;
|
||||
huskMove.Facing = move.Facing;
|
||||
|
||||
var turreted = self.traits.GetOrDefault<Turreted>();
|
||||
if (turreted != null)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace OpenRA.Mods.RA
|
||||
Actor dockedHarv = null;
|
||||
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
|
||||
{
|
||||
var unit = harv.traits.Get<Unit>();
|
||||
var move = harv.traits.Get<IMove>();
|
||||
var harvester = harv.traits.Get<Harvester>();
|
||||
|
||||
if (unit.Facing != 64)
|
||||
if (move.Facing != 64)
|
||||
harv.QueueActivity (new Turn (64));
|
||||
|
||||
harv.QueueActivity (new CallFunc (() =>
|
||||
|
||||
@@ -57,10 +57,11 @@ namespace OpenRA.Mods.RA
|
||||
var a = cargo.Unload(self);
|
||||
var rs = a.traits.Get<RenderSimple>();
|
||||
|
||||
var aircraft = self.traits.Get<IMove>();
|
||||
self.World.AddFrameEndTask(w => w.Add(
|
||||
new Parachute(self.Owner, rs.anim.Name,
|
||||
Util.CenterOfCell(Util.CellContaining(self.CenterLocation)),
|
||||
self.traits.Get<Unit>().Altitude, a)));
|
||||
aircraft.Altitude, a)));
|
||||
|
||||
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
|
||||
if (firstTick)
|
||||
{
|
||||
firstTick = false;
|
||||
if (self.traits.Get<Unit>().Altitude == 0)
|
||||
if (self.traits.Get<IMove>().Altitude == 0)
|
||||
{
|
||||
/* not spawning in the air, so try to assoc. with our afld. this is a hack. */
|
||||
var res = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
|
||||
return false;
|
||||
|
||||
var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner );
|
||||
newUnit.traits.Get<Unit>().Facing = CreationFacing( self, newUnit ); ;
|
||||
newUnit.traits.Get<IMove>().Facing = CreationFacing( self, newUnit ); ;
|
||||
|
||||
var pi = self.Info.Traits.Get<ProductionInfo>();
|
||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage
|
||||
{
|
||||
public RenderInfantry(Actor self)
|
||||
: base(self, () => self.traits.Get<Unit>().Facing)
|
||||
: base(self, () => self.traits.Get<IMove>().Facing)
|
||||
{
|
||||
anim.Play("stand");
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
public class RenderUnit : RenderSimple, INotifyDamage
|
||||
{
|
||||
public RenderUnit(Actor self)
|
||||
: base(self, () => self.traits.Get<Unit>().Facing)
|
||||
: base(self, () => self.traits.Contains<IMove>() ? self.traits.Get<IMove>().Facing : 0)
|
||||
{
|
||||
anim.Play("idle");
|
||||
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
|
||||
|
||||
@@ -24,19 +24,20 @@ namespace OpenRA.Mods.RA.Render
|
||||
class RenderUnitRotor : RenderUnit
|
||||
{
|
||||
public Animation rotorAnim, secondRotorAnim;
|
||||
IMove move;
|
||||
|
||||
public RenderUnitRotor(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
move = self.traits.Get<IMove>();
|
||||
var info = self.Info.Traits.Get<RenderUnitRotorInfo>();
|
||||
|
||||
rotorAnim = new Animation(GetImage(self));
|
||||
rotorAnim.PlayRepeating("rotor");
|
||||
anims.Add("rotor_1", new AnimationWithOffset(
|
||||
rotorAnim,
|
||||
() => Combat.GetTurretPosition(self, unit, new Turret(info.PrimaryOffset)),
|
||||
null) { ZOffset = 1 });
|
||||
() => Combat.GetTurretPosition( self, move, new Turret(info.PrimaryOffset)),
|
||||
null ) { ZOffset = 1 } );
|
||||
|
||||
if (info.SecondaryOffset == null) return;
|
||||
|
||||
@@ -44,18 +45,15 @@ namespace OpenRA.Mods.RA.Render
|
||||
secondRotorAnim.PlayRepeating("rotor2");
|
||||
anims.Add("rotor_2", new AnimationWithOffset(
|
||||
secondRotorAnim,
|
||||
() => Combat.GetTurretPosition(self, unit, new Turret(info.SecondaryOffset)),
|
||||
() => Combat.GetTurretPosition(self, move, new Turret(info.SecondaryOffset)),
|
||||
null) { ZOffset = 1 });
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
var isFlying = unit.Altitude > 0;
|
||||
|
||||
var isFlying = move.Altitude > 0;
|
||||
if (isFlying ^ (rotorAnim.CurrentSequence.Name != "rotor"))
|
||||
return;
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@ namespace OpenRA.Mods.RA.Render
|
||||
public RenderUnitSpinner(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var move = self.traits.Get<IMove>();
|
||||
var info = self.Info.Traits.Get<RenderUnitSpinnerInfo>();
|
||||
|
||||
var spinnerAnim = new Animation(GetImage(self));
|
||||
spinnerAnim.PlayRepeating("spinner");
|
||||
anims.Add("spinner", new AnimationWithOffset(
|
||||
spinnerAnim,
|
||||
() => Combat.GetTurretPosition(self, unit, new Turret(info.Offset)),
|
||||
() => Combat.GetTurretPosition(self, move, new Turret(info.Offset)),
|
||||
null) { ZOffset = 1 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
public RenderUnitTurreted(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var move = self.traits.Get<IMove>();
|
||||
var turreted = self.traits.Get<Turreted>();
|
||||
var attack = self.traits.GetOrDefault<AttackBase>();
|
||||
var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
var turret = attack.Turrets[i];
|
||||
anims.Add( "turret_{0}".F(i),
|
||||
new AnimationWithOffset( turretAnim,
|
||||
() => Combat.GetTurretPosition( self, unit, turret ),
|
||||
() => Combat.GetTurretPosition( self, move, turret ),
|
||||
null) { ZOffset = 1 });
|
||||
|
||||
if (attackInfo.MuzzleFlash)
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
() => (int)(turret.Recoil * 5.9f)); /* hack: dumb crap */
|
||||
anims.Add("muzzle_flash_{0}".F(i),
|
||||
new AnimationWithOffset(muzzleFlash,
|
||||
() => Combat.GetTurretPosition(self, unit, turret),
|
||||
() => Combat.GetTurretPosition(self, move, turret),
|
||||
() => turret.Recoil <= 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public void Idle(Actor self)
|
||||
{
|
||||
var altitude = self.traits.Get<Unit>().Altitude;
|
||||
var altitude = self.traits.Get<Aircraft>().Altitude;
|
||||
if (altitude == 0) return; // we're on the ground, let's stay there.
|
||||
|
||||
var airfield = ReturnToBase.ChooseAirfield(self);
|
||||
|
||||
@@ -48,8 +48,9 @@ namespace OpenRA.Mods.RA
|
||||
var flare = flareType != null ? w.CreateActor(flareType, order.TargetLocation, Owner) : null;
|
||||
|
||||
var a = w.CreateActor((Info as AirstrikePowerInfo).UnitType, startPos, Owner);
|
||||
a.traits.Get<Unit>().Facing = Util.GetFacing(order.TargetLocation - startPos, 0);
|
||||
a.traits.Get<Unit>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
var aMove = a.traits.Get<IMove>();
|
||||
aMove.Facing = Util.GetFacing(order.TargetLocation - startPos, 0);
|
||||
aMove.Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
a.traits.Get<CarpetBomb>().SetTarget(order.TargetLocation);
|
||||
|
||||
a.CancelActivity();
|
||||
|
||||
@@ -61,8 +61,9 @@ namespace OpenRA.Mods.RA
|
||||
var flare = flareType != null ? w.CreateActor(flareType, p, owner) : null;
|
||||
|
||||
var a = w.CreateActor((Info as ParatroopersPowerInfo).UnitType, startPos, owner);
|
||||
a.traits.Get<Unit>().Facing = Util.GetFacing(p - startPos, 0);
|
||||
a.traits.Get<Unit>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
var aMove = a.traits.Get<IMove>();
|
||||
aMove.Facing = Util.GetFacing(p - startPos, 0);
|
||||
aMove.Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
|
||||
a.CancelActivity();
|
||||
a.QueueActivity(new FlyCircle(p));
|
||||
|
||||
@@ -46,8 +46,9 @@ namespace OpenRA.Mods.RA
|
||||
var enterCell = self.World.ChooseRandomEdgeCell();
|
||||
|
||||
var plane = self.World.CreateActor("U2", enterCell, self.Owner);
|
||||
plane.traits.Get<Unit>().Altitude = plane.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
plane.traits.Get<Unit>().Facing = Util.GetFacing(order.TargetLocation - enterCell, 0);
|
||||
var planeMove = plane.traits.Get<IMove>();
|
||||
planeMove.Altitude = plane.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
planeMove.Facing = Util.GetFacing(order.TargetLocation - enterCell, 0);
|
||||
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
|
||||
|
||||
@@ -48,7 +48,8 @@ namespace OpenRA.Mods.RA
|
||||
if (info != null)
|
||||
{
|
||||
alt = 0;
|
||||
pos = Combat.GetTurretPosition(self, self.traits.Get<Unit>(), new Turret(info.Offset));
|
||||
var move = self.traits.Get<IMove>();
|
||||
pos = Combat.GetTurretPosition(self, move, new Turret(info.Offset));
|
||||
var ru = self.traits.Get<RenderUnit>();
|
||||
|
||||
v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();
|
||||
@@ -56,7 +57,7 @@ namespace OpenRA.Mods.RA
|
||||
va = info.Speed;
|
||||
|
||||
if (!info.UseTurretFacing) InitialFacing = null;
|
||||
facing = InitialFacing ?? self.traits.Get<Unit>().Facing;
|
||||
facing = InitialFacing ?? move.Facing;
|
||||
|
||||
var anim = new Animation(ru.GetImage(self), () => (int)facing);
|
||||
anim.PlayRepeating(info.Anim);
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public WithMuzzleFlash(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var move = self.traits.Get<IMove>();
|
||||
var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();
|
||||
var render = self.traits.Get<RenderSimple>();
|
||||
|
||||
muzzleFlash = new Animation(render.GetImage(self), () => unit.Facing);
|
||||
muzzleFlash = new Animation(render.GetImage(self), () => move.Facing);
|
||||
muzzleFlash.Play("muzzle");
|
||||
|
||||
render.anims.Add("muzzle", new RenderSimple.AnimationWithOffset(
|
||||
|
||||
@@ -20,11 +20,11 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var move = self.traits.Get<IMove>();
|
||||
|
||||
var shadowSprites = r.Select(a => a.WithPalette("shadow"));
|
||||
var flyingSprites = (unit.Altitude <= 0) ? r
|
||||
: r.Select(a => a.WithPos(a.Pos - new float2(0, unit.Altitude)).WithZOffset(3));
|
||||
var flyingSprites = (move.Altitude <= 0) ? r
|
||||
: r.Select(a => a.WithPos(a.Pos - new float2(0, move.Altitude)).WithZOffset(3));
|
||||
|
||||
return shadowSprites.Concat(flyingSprites);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user