move ROT, InitialFacing and Speed to Mobile and Aircraft.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
public class Turn : IActivity
|
||||
@@ -24,11 +26,13 @@ namespace OpenRA.Traits.Activities
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var ROT = self.traits.WithInterface<IMove>().FirstOrDefault().ROT(self);
|
||||
|
||||
if( desiredFacing == unit.Facing )
|
||||
return NextActivity;
|
||||
|
||||
Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.Traits.Get<UnitInfo>().ROT );
|
||||
Util.TickFacing(ref unit.Facing, desiredFacing, ROT);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace OpenRA.Traits
|
||||
public readonly string[] Crushes;
|
||||
public readonly int WaitAverage = 60;
|
||||
public readonly int WaitSpread = 20;
|
||||
public readonly int InitialFacing = 128;
|
||||
public readonly int ROT = 255;
|
||||
public readonly int Speed = 1;
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
|
||||
}
|
||||
@@ -59,7 +62,6 @@ namespace OpenRA.Traits
|
||||
|
||||
Shroud shroud;
|
||||
UnitInfluence uim;
|
||||
UnitInfo unitInfo;
|
||||
BuildingInfluence bim;
|
||||
bool canShareCell;
|
||||
|
||||
@@ -72,7 +74,6 @@ namespace OpenRA.Traits
|
||||
shroud = self.World.WorldActor.traits.Get<Shroud>();
|
||||
uim = self.World.WorldActor.traits.Get<UnitInfluence>();
|
||||
bim = self.World.WorldActor.traits.Get<BuildingInfluence>();
|
||||
unitInfo = self.Info.Traits.GetOrDefault<UnitInfo>();
|
||||
canShareCell = self.traits.Contains<SharesCell>();
|
||||
|
||||
AddInfluence();
|
||||
@@ -89,6 +90,10 @@ namespace OpenRA.Traits
|
||||
TerrainSpeed.Add(info.TerrainTypes[i], info.TerrainSpeeds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public int ROT(Actor self){ return Info.ROT; }
|
||||
|
||||
public int InitialFacing(Actor self){ return Info.InitialFacing; }
|
||||
|
||||
public void SetPosition(Actor self, int2 cell)
|
||||
{
|
||||
@@ -236,17 +241,14 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
public virtual float MovementSpeedForCell(Actor self, int2 cell)
|
||||
{
|
||||
if( unitInfo == null )
|
||||
return 0f;
|
||||
|
||||
{
|
||||
var type = self.World.GetTerrainType(cell);
|
||||
|
||||
var modifier = self.traits
|
||||
.WithInterface<ISpeedModifier>()
|
||||
.Select(t => t.GetSpeedModifier())
|
||||
.Product();
|
||||
return unitInfo.Speed * TerrainSpeed[type] * modifier;
|
||||
return Info.Speed * TerrainSpeed[type] * modifier;
|
||||
}
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath(Actor self)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public virtual int CreationFacing( Actor self, Actor newUnit )
|
||||
{
|
||||
return newUnit.Info.Traits.GetOrDefault<UnitInfo>().InitialFacing;
|
||||
return newUnit.traits.Get<IMove>().InitialFacing(newUnit);
|
||||
}
|
||||
|
||||
public virtual bool Produce( Actor self, ActorInfo producee )
|
||||
|
||||
@@ -110,6 +110,8 @@ namespace OpenRA.Traits
|
||||
float MovementCostForCell(Actor self, int2 cell);
|
||||
float MovementSpeedForCell(Actor self, int2 cell);
|
||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||
int ROT(Actor self);
|
||||
int InitialFacing(Actor self);
|
||||
}
|
||||
|
||||
public interface IOffsetCenterLocation { float2 CenterOffset { get; } }
|
||||
|
||||
@@ -16,10 +16,6 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public class UnitInfo : ITraitInfo
|
||||
{
|
||||
public readonly int InitialFacing = 128;
|
||||
public readonly int ROT = 255;
|
||||
public readonly int Speed = 1;
|
||||
|
||||
public object Create( ActorInitializer init ) { return new Unit(); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user