Split facing into its own interface; fix husks
This commit is contained in:
@@ -15,7 +15,6 @@ namespace OpenRA.Traits.Activities
|
||||
public class Turn : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
int desiredFacing;
|
||||
|
||||
public Turn( int desiredFacing )
|
||||
@@ -25,22 +24,18 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var mobile = self.traits.Get<IMove>();
|
||||
var ROT = self.traits.Get<IMove>().ROT;
|
||||
var facing = self.traits.Get<IFacing>();
|
||||
|
||||
if( desiredFacing == mobile.Facing )
|
||||
if( desiredFacing == facing.Facing )
|
||||
return NextActivity;
|
||||
|
||||
mobile.Facing = Util.TickFacing(mobile.Facing, desiredFacing, ROT);
|
||||
facing.Facing = Util.TickFacing(facing.Facing, desiredFacing, facing.ROT);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel( Actor self )
|
||||
{
|
||||
var mobile = self.traits.Get<IMove>();
|
||||
|
||||
desiredFacing = mobile.Facing;
|
||||
desiredFacing = self.traits.Get<IFacing>().Facing;
|
||||
NextActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Traits
|
||||
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
|
||||
}
|
||||
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice, IOccupySpace, IMove, INudge
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice, IOccupySpace, IMove, IFacing, INudge
|
||||
{
|
||||
public readonly Actor self;
|
||||
public readonly MobileInfo Info;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public virtual int CreationFacing( Actor self, Actor newUnit )
|
||||
{
|
||||
return newUnit.traits.Get<IMove>().InitialFacing;
|
||||
return newUnit.traits.Get<IFacing>().InitialFacing;
|
||||
}
|
||||
|
||||
public virtual bool Produce( Actor self, ActorInfo producee )
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Traits
|
||||
return false;
|
||||
|
||||
var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner );
|
||||
newUnit.traits.Get<IMove>().Facing = CreationFacing( self, newUnit ); ;
|
||||
newUnit.traits.Get<IFacing>().Facing = CreationFacing( self, newUnit ); ;
|
||||
|
||||
var pi = self.Info.Traits.Get<ProductionInfo>();
|
||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||
|
||||
@@ -110,8 +110,12 @@ namespace OpenRA.Traits
|
||||
float MovementCostForCell(Actor self, int2 cell);
|
||||
float MovementSpeedForCell(Actor self, int2 cell);
|
||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||
int ROT { get; }
|
||||
int Altitude { get; set; }
|
||||
}
|
||||
|
||||
public interface IFacing
|
||||
{
|
||||
int ROT { get; }
|
||||
int Facing { get; set; }
|
||||
int InitialFacing { get; }
|
||||
}
|
||||
|
||||
@@ -23,20 +23,20 @@ namespace OpenRA.Traits
|
||||
[Sync]
|
||||
public int turretFacing = 0;
|
||||
public int? desiredFacing;
|
||||
TurretedInfo Info;
|
||||
IMove Move;
|
||||
TurretedInfo info;
|
||||
IFacing facing;
|
||||
|
||||
public Turreted(Actor self, TurretedInfo info)
|
||||
{
|
||||
Info = info;
|
||||
this.info = info;
|
||||
turretFacing = info.InitialFacing;
|
||||
Move = self.traits.GetOrDefault<IMove>();
|
||||
facing = self.traits.GetOrDefault<IFacing>();
|
||||
}
|
||||
|
||||
public void Tick( Actor self )
|
||||
{
|
||||
var df = desiredFacing ?? ( Move != null ? Move.Facing : turretFacing );
|
||||
turretFacing = Util.TickFacing(turretFacing, df, Info.ROT);
|
||||
var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing );
|
||||
turretFacing = Util.TickFacing(turretFacing, df, info.ROT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user