Shift movement cost/speed into IMove; regressions in a few areas
This commit is contained in:
@@ -52,15 +52,16 @@ namespace OpenRA
|
|||||||
|
|
||||||
public List<int2> FindUnitPath(int2 from, int2 target, Actor self)
|
public List<int2> FindUnitPath(int2 from, int2 target, Actor self)
|
||||||
{
|
{
|
||||||
var umt = self.traits.Get<Mobile>().GetMovementType();
|
// Todo: Reenable cache on something that isn't umt
|
||||||
|
//var umt = self.traits.Get<Mobile>().GetMovementType();
|
||||||
using (new PerfSample("find_unit_path"))
|
using (new PerfSample("find_unit_path"))
|
||||||
{
|
{
|
||||||
var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.umt == umt);
|
//var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.umt == umt);
|
||||||
if (cached != null)
|
//if (cached != null)
|
||||||
{
|
//{
|
||||||
cached.tick = Game.LocalTick;
|
// cached.tick = Game.LocalTick;
|
||||||
return new List<int2>(cached.result);
|
// return new List<int2>(cached.result);
|
||||||
}
|
//}
|
||||||
|
|
||||||
var pb = FindBidiPath(
|
var pb = FindBidiPath(
|
||||||
PathSearch.FromPoint(self, target, from, true)
|
PathSearch.FromPoint(self, target, from, true)
|
||||||
@@ -71,8 +72,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
CheckSanePath2(pb, from, target);
|
CheckSanePath2(pb, from, target);
|
||||||
|
|
||||||
CachedPaths.RemoveAll(p => Game.LocalTick - p.tick > MaxPathAge);
|
//CachedPaths.RemoveAll(p => Game.LocalTick - p.tick > MaxPathAge);
|
||||||
CachedPaths.Add(new CachedPath { from = from, to = target, umt = umt, result = pb, tick = Game.LocalTick });
|
//CachedPaths.Add(new CachedPath { from = from, to = target, umt = umt, result = pb, tick = Game.LocalTick });
|
||||||
return new List<int2>(pb);
|
return new List<int2>(pb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
public int2 Expand( World world )
|
public int2 Expand( World world )
|
||||||
{
|
{
|
||||||
var umt = self.traits.Get<Mobile>().GetMovementType();
|
|
||||||
|
|
||||||
var p = queue.Pop();
|
var p = queue.Pop();
|
||||||
cellInfo[ p.Location.X, p.Location.Y ].Seen = true;
|
cellInfo[ p.Location.X, p.Location.Y ].Seen = true;
|
||||||
|
|
||||||
|
|||||||
@@ -227,8 +227,7 @@ namespace OpenRA.Traits.Activities
|
|||||||
|
|
||||||
public void TickMove( Actor self, Mobile mobile, Move parent )
|
public void TickMove( Actor self, Mobile mobile, Move parent )
|
||||||
{
|
{
|
||||||
var umt = self.Info.Traits.Get<MobileInfo>().MovementType;
|
moveFraction += (int)mobile.MovementSpeedForCell(self, self.Location);
|
||||||
moveFraction += (int)Util.GetEffectiveSpeed(self, umt);
|
|
||||||
if( moveFraction >= moveFractionTotal )
|
if( moveFraction >= moveFractionTotal )
|
||||||
moveFraction = moveFractionTotal;
|
moveFraction = moveFractionTotal;
|
||||||
UpdateCenterLocation( self, mobile );
|
UpdateCenterLocation( self, mobile );
|
||||||
|
|||||||
@@ -20,22 +20,27 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
public class MobileInfo : ITraitInfo, ITraitPrerequisite<UnitInfo>
|
public class MobileInfo : ITraitInfo, ITraitPrerequisite<UnitInfo>
|
||||||
{
|
{
|
||||||
public readonly UnitMovementType MovementType = UnitMovementType.Wheel;
|
public readonly TerrainType[] TerrainTypes;
|
||||||
|
public readonly float[] TerrainSpeeds;
|
||||||
public readonly int WaitAverage = 60;
|
public readonly int WaitAverage = 60;
|
||||||
public readonly int WaitSpread = 20;
|
public readonly int WaitSpread = 20;
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init) { return new Mobile(init); }
|
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove
|
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove
|
||||||
{
|
{
|
||||||
public readonly Actor self;
|
public readonly Actor self;
|
||||||
|
public readonly Dictionary<TerrainType,float> TerrainCost;
|
||||||
|
public readonly Dictionary<TerrainType,float> TerrainSpeed;
|
||||||
|
|
||||||
[Sync]
|
[Sync]
|
||||||
int2 __fromCell, __toCell;
|
int2 __fromCell, __toCell;
|
||||||
@@ -59,11 +64,23 @@ namespace OpenRA.Traits
|
|||||||
AddInfluence();
|
AddInfluence();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mobile(ActorInitializer init)
|
public Mobile(ActorInitializer init, MobileInfo info)
|
||||||
{
|
{
|
||||||
this.self = init.self;
|
this.self = init.self;
|
||||||
this.__fromCell = this.__toCell = init.location;
|
this.__fromCell = this.__toCell = init.location;
|
||||||
AddInfluence();
|
AddInfluence();
|
||||||
|
|
||||||
|
TerrainCost = new Dictionary<TerrainType, float>();
|
||||||
|
TerrainSpeed = new Dictionary<TerrainType, float>();
|
||||||
|
|
||||||
|
if (info.TerrainTypes.Count() != info.TerrainSpeeds.Count())
|
||||||
|
throw new InvalidOperationException("Mobile TerrainType/TerrainSpeed length missmatch");
|
||||||
|
|
||||||
|
for (int i = 0; i < info.TerrainTypes.Count(); i++)
|
||||||
|
{
|
||||||
|
TerrainCost.Add(info.TerrainTypes[i], 1f/info.TerrainSpeeds[i]);
|
||||||
|
TerrainSpeed.Add(info.TerrainTypes[i], info.TerrainSpeeds[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPosition(Actor self, int2 cell)
|
public void SetPosition(Actor self, int2 cell)
|
||||||
@@ -85,8 +102,7 @@ namespace OpenRA.Traits
|
|||||||
if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null;
|
if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null;
|
||||||
if (!CanEnterCell(underCursor.Location, null, true)) return null;
|
if (!CanEnterCell(underCursor.Location, null, true)) return null;
|
||||||
}
|
}
|
||||||
var umt = self.Info.Traits.Get<MobileInfo>().MovementType;
|
if (MovementSpeedForCell(self, self.Location) == 0) return null; /* allow disabling move orders from modifiers */
|
||||||
if (Util.GetEffectiveSpeed(self,umt) == 0) return null; /* allow disabling move orders from modifiers */
|
|
||||||
if (xy == toCell) return null;
|
if (xy == toCell) return null;
|
||||||
return new Order("Move", self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
return new Order("Move", self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
}
|
}
|
||||||
@@ -114,11 +130,6 @@ namespace OpenRA.Traits
|
|||||||
: new[] { fromCell, toCell };
|
: new[] { fromCell, toCell };
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitMovementType GetMovementType()
|
|
||||||
{
|
|
||||||
return self.Info.Traits.Get<MobileInfo>().MovementType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanEnterCell(int2 p)
|
public bool CanEnterCell(int2 p)
|
||||||
{
|
{
|
||||||
return CanEnterCell(p, null, true);
|
return CanEnterCell(p, null, true);
|
||||||
@@ -149,19 +160,37 @@ namespace OpenRA.Traits
|
|||||||
return MovementCostForCell(self, cell) < float.PositiveInfinity;
|
return MovementCostForCell(self, cell) < float.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float MovementCostForCell(Actor self, int2 cell)
|
public virtual float MovementCostForCell(Actor self, int2 cell)
|
||||||
{
|
{
|
||||||
if (!self.World.Map.IsInMap(cell.X,cell.Y))
|
if (!self.World.Map.IsInMap(cell.X,cell.Y))
|
||||||
return float.PositiveInfinity;
|
return float.PositiveInfinity;
|
||||||
|
|
||||||
var type = self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[cell.X, cell.Y]);
|
var type = self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[cell.X, cell.Y]);
|
||||||
var umt = self.Info.Traits.Get<MobileInfo>().MovementType;
|
return (float)TerrainCost[type]*
|
||||||
|
self.World.WorldActor.traits.WithInterface<ICustomTerrain>()
|
||||||
// Todo: Cache cost for each terraintype
|
.Select(t => t.GetCost(cell, self))
|
||||||
return (float)Rules.TerrainTypes[type].GetCost(umt)*
|
.Product();
|
||||||
self.World.WorldActor.traits.WithInterface<ICustomTerrain>().Aggregate(1f, (a, x) => a * x.GetCost(cell,self));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual float MovementSpeedForCell(Actor self, int2 cell)
|
||||||
|
{
|
||||||
|
var unitInfo = self.Info.Traits.GetOrDefault<UnitInfo>();
|
||||||
|
if( unitInfo == null || !self.World.Map.IsInMap(cell.X,cell.Y))
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
var type = self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[cell.X, cell.Y]);
|
||||||
|
var terrain = TerrainSpeed[type]*self.World.WorldActor.traits
|
||||||
|
.WithInterface<ICustomTerrain>()
|
||||||
|
.Select(t => t.GetSpeedModifier(self.Location, self))
|
||||||
|
.Product();
|
||||||
|
|
||||||
|
var modifier = self.traits
|
||||||
|
.WithInterface<ISpeedModifier>()
|
||||||
|
.Select(t => t.GetSpeedModifier())
|
||||||
|
.Product();
|
||||||
|
return unitInfo.Speed * terrain * modifier;
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<float2> GetCurrentPath(Actor self)
|
public IEnumerable<float2> GetCurrentPath(Actor self)
|
||||||
{
|
{
|
||||||
var move = self.GetCurrentActivity() as Activities.Move;
|
var move = self.GetCurrentActivity() as Activities.Move;
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ namespace OpenRA.Traits
|
|||||||
public interface ITags { IEnumerable<TagType> GetTags(); }
|
public interface ITags { IEnumerable<TagType> GetTags(); }
|
||||||
public interface IMove
|
public interface IMove
|
||||||
{
|
{
|
||||||
UnitMovementType GetMovementType();
|
|
||||||
bool CanEnterCell(int2 location);
|
bool CanEnterCell(int2 location);
|
||||||
float MovementCostForCell(Actor self, int2 cell);
|
float MovementCostForCell(Actor self, int2 cell);
|
||||||
|
float MovementSpeedForCell(Actor self, int2 cell);
|
||||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||||
void SetPosition(Actor self, int2 cell);
|
void SetPosition(Actor self, int2 cell);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,27 +138,6 @@ namespace OpenRA.Traits
|
|||||||
return new Renderable(s, loc.Round(), pal);
|
return new Renderable(s, loc.Round(), pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float GetEffectiveSpeed(Actor self, UnitMovementType umt)
|
|
||||||
{
|
|
||||||
var unitInfo = self.Info.Traits.GetOrDefault<UnitInfo>();
|
|
||||||
if( unitInfo == null ) return 0f;
|
|
||||||
|
|
||||||
var terrain = 1f;
|
|
||||||
if (umt != UnitMovementType.Fly)
|
|
||||||
{
|
|
||||||
var tt = self.World.GetTerrainType(self.Location);
|
|
||||||
terrain = Rules.TerrainTypes[tt].GetSpeedModifier(umt)*self.World.WorldActor.traits
|
|
||||||
.WithInterface<ICustomTerrain>()
|
|
||||||
.Select(t => t.GetSpeedModifier(self.Location, self))
|
|
||||||
.Product();
|
|
||||||
}
|
|
||||||
var modifier = self.traits
|
|
||||||
.WithInterface<ISpeedModifier>()
|
|
||||||
.Select(t => t.GetSpeedModifier())
|
|
||||||
.Product();
|
|
||||||
return unitInfo.Speed * terrain * modifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IActivity SequenceActivities(params IActivity[] acts)
|
public static IActivity SequenceActivities(params IActivity[] acts)
|
||||||
{
|
{
|
||||||
return acts.Reverse().Aggregate(
|
return acts.Reverse().Aggregate(
|
||||||
|
|||||||
@@ -98,8 +98,10 @@ namespace OpenRA.Traits
|
|||||||
if (content[p.X,p.Y].type == null)
|
if (content[p.X,p.Y].type == null)
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
// Todo: Reenable based off something that isn't umt
|
||||||
return content[p.X,p.Y].type.GetSpeedModifier(umt);
|
return 1f;
|
||||||
|
//var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
||||||
|
//return content[p.X,p.Y].type.GetSpeedModifier(umt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetCost(int2 p, Actor forActor)
|
public float GetCost(int2 p, Actor forActor)
|
||||||
@@ -107,8 +109,10 @@ namespace OpenRA.Traits
|
|||||||
if (content[p.X,p.Y].type == null)
|
if (content[p.X,p.Y].type == null)
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
// Todo: Reenable based off something that isn't umt
|
||||||
return content[p.X,p.Y].type.GetCost(umt);
|
return 1f;
|
||||||
|
//var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
||||||
|
//return content[p.X,p.Y].type.GetCost(umt);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite[] ChooseContent(ResourceType t)
|
Sprite[] ChooseContent(ResourceType t)
|
||||||
|
|||||||
@@ -48,13 +48,16 @@ namespace OpenRA
|
|||||||
Rules.TerrainTypes[world.TileSet.GetTerrainType(world.Map.MapTiles[a.X, a.Y])]
|
Rules.TerrainTypes[world.TileSet.GetTerrainType(world.Map.MapTiles[a.X, a.Y])]
|
||||||
.Buildable;
|
.Buildable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsActorCrushableByActor(this World world, Actor a, Actor b)
|
public static bool IsActorCrushableByActor(this World world, Actor a, Actor b)
|
||||||
{
|
{
|
||||||
var movement = b.traits.GetOrDefault<IMove>();
|
return false;
|
||||||
return movement != null && world.IsActorCrushableByMovementType(a, movement.GetMovementType());
|
//var movement = b.traits.GetOrDefault<IMove>();
|
||||||
|
//return movement != null && world.IsActorCrushableByMovementType(a, movement.GetMovementType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo: Reenable crushing based on actor, not umt
|
||||||
|
/*
|
||||||
public static bool IsActorPathableToCrush(this World world, Actor a, UnitMovementType umt)
|
public static bool IsActorPathableToCrush(this World world, Actor a, UnitMovementType umt)
|
||||||
{
|
{
|
||||||
return a != null &&
|
return a != null &&
|
||||||
@@ -68,7 +71,7 @@ namespace OpenRA
|
|||||||
a.traits.WithInterface<ICrushable>()
|
a.traits.WithInterface<ICrushable>()
|
||||||
.Any(c => c.IsCrushableBy(umt, a.Owner));
|
.Any(c => c.IsCrushableBy(umt, a.Owner));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public static IEnumerable<Actor> FindUnitsAtMouse(this World world, int2 mouseLocation)
|
public static IEnumerable<Actor> FindUnitsAtMouse(this World world, int2 mouseLocation)
|
||||||
{
|
{
|
||||||
var loc = mouseLocation + Game.viewport.Location;
|
var loc = mouseLocation + Game.viewport.Location;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
MobileAirInfo Info;
|
MobileAirInfo Info;
|
||||||
public MobileAir (ActorInitializer init, MobileAirInfo info)
|
public MobileAir (ActorInitializer init, MobileAirInfo info)
|
||||||
: base(init)
|
: base(init, info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
@@ -62,13 +62,26 @@ namespace OpenRA.Traits
|
|||||||
return self.World.WorldActor.traits.Get<AircraftInfluence>().GetUnitsAt(p).Count() == 0;
|
return self.World.WorldActor.traits.Get<AircraftInfluence>().GetUnitsAt(p).Count() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float MovementCostForCell(Actor self, int2 cell)
|
public override float MovementCostForCell(Actor self, int2 cell)
|
||||||
{
|
{
|
||||||
if (!self.World.Map.IsInMap(cell.X,cell.Y))
|
if (!self.World.Map.IsInMap(cell.X,cell.Y))
|
||||||
return float.PositiveInfinity;
|
return float.PositiveInfinity;
|
||||||
|
|
||||||
return self.World.WorldActor.traits.WithInterface<ICustomTerrain>().Aggregate(1f, (a, x) => a * x.GetCost(cell,self));
|
return self.World.WorldActor.traits.WithInterface<ICustomTerrain>().Aggregate(1f, (a, x) => a * x.GetCost(cell,self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override float MovementSpeedForCell(Actor self, int2 cell)
|
||||||
|
{
|
||||||
|
var unitInfo = self.Info.Traits.GetOrDefault<UnitInfo>();
|
||||||
|
if( unitInfo == null || !self.World.Map.IsInMap(cell.X,cell.Y))
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
var modifier = self.traits
|
||||||
|
.WithInterface<ISpeedModifier>()
|
||||||
|
.Select(t => t.GetSpeedModifier())
|
||||||
|
.Product();
|
||||||
|
return unitInfo.Speed * modifier;
|
||||||
|
}
|
||||||
|
|
||||||
public override IEnumerable<int2> OccupiedCells()
|
public override IEnumerable<int2> OccupiedCells()
|
||||||
{
|
{
|
||||||
@@ -76,8 +89,6 @@ namespace OpenRA.Traits
|
|||||||
return new int2[] {};
|
return new int2[] {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 TopLeft { get { return toCell; } }
|
|
||||||
|
|
||||||
public IEnumerable<int2> OccupiedAirCells()
|
public IEnumerable<int2> OccupiedAirCells()
|
||||||
{
|
{
|
||||||
return (fromCell == toCell)
|
return (fromCell == toCell)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -66,7 +67,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public static void Fly(Actor self, int desiredAltitude )
|
public static void Fly(Actor self, int desiredAltitude )
|
||||||
{
|
{
|
||||||
var unit = self.traits.Get<Unit>();
|
var unit = self.traits.Get<Unit>();
|
||||||
var speed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly);
|
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||||
|
var speed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||||
var angle = unit.Facing / 128f * Math.PI;
|
var angle = unit.Facing / 128f * Math.PI;
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.traits.Get<Aircraft>();
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,9 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
var desiredFacing = Util.GetFacing(dist, unit.Facing);
|
var desiredFacing = Util.GetFacing(dist, unit.Facing);
|
||||||
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get<UnitInfo>().ROT);
|
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get<UnitInfo>().ROT);
|
||||||
|
|
||||||
var rawSpeed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly);
|
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||||
|
var rawSpeed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||||
|
|
||||||
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
||||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
Util.TickFacing(ref unit.Facing, desiredFacing,
|
Util.TickFacing(ref unit.Facing, desiredFacing,
|
||||||
self.Info.Traits.Get<UnitInfo>().ROT);
|
self.Info.Traits.Get<UnitInfo>().ROT);
|
||||||
|
|
||||||
var rawSpeed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly);
|
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||||
|
var rawSpeed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -57,7 +58,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
var desiredFacing = Util.GetFacing(d, unit.Facing);
|
var desiredFacing = Util.GetFacing(d, unit.Facing);
|
||||||
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get<UnitInfo>().ROT);
|
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get<UnitInfo>().ROT);
|
||||||
var speed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly);
|
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||||
|
var speed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||||
var angle = unit.Facing / 128f * Math.PI;
|
var angle = unit.Facing / 128f * Math.PI;
|
||||||
|
|
||||||
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
var landPos = dest.CenterLocation;
|
var landPos = dest.CenterLocation;
|
||||||
var unit = self.traits.Get<Unit>();
|
var unit = self.traits.Get<Unit>();
|
||||||
var speed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly);
|
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||||
|
var speed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||||
|
|
||||||
var approachStart = landPos - new float2(unit.Altitude * speed, 0);
|
var approachStart = landPos - new float2(unit.Altitude * speed, 0);
|
||||||
var turnRadius = (128f / self.Info.Traits.Get<UnitInfo>().ROT) * speed / (float)Math.PI;
|
var turnRadius = (128f / self.Info.Traits.Get<UnitInfo>().ROT) * speed / (float)Math.PI;
|
||||||
|
|
||||||
|
|||||||
@@ -70,11 +70,23 @@ namespace OpenRA.Mods.RA
|
|||||||
return new float2[] { move.Pos };
|
return new float2[] { move.Pos };
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitMovementType GetMovementType() { return UnitMovementType.Fly; }
|
|
||||||
public bool CanEnterCell(int2 location) { return true; }
|
public bool CanEnterCell(int2 location) { return true; }
|
||||||
|
|
||||||
public float MovementCostForCell(Actor self, int2 cell) { return 1f; }
|
public float MovementCostForCell(Actor self, int2 cell) { return 1f; }
|
||||||
|
|
||||||
|
public float MovementSpeedForCell(Actor self, int2 cell)
|
||||||
|
{
|
||||||
|
var unitInfo = self.Info.Traits.GetOrDefault<UnitInfo>();
|
||||||
|
if( unitInfo == null)
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
var modifier = self.traits
|
||||||
|
.WithInterface<ISpeedModifier>()
|
||||||
|
.Select(t => t.GetSpeedModifier())
|
||||||
|
.Product();
|
||||||
|
return unitInfo.Speed * modifier;
|
||||||
|
}
|
||||||
|
|
||||||
int2[] noCells = new int2[] { };
|
int2[] noCells = new int2[] { };
|
||||||
public IEnumerable<int2> OccupiedCells() { return noCells; }
|
public IEnumerable<int2> OccupiedCells() { return noCells; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,17 +92,19 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public float GetCost(int2 p, Actor forActor)
|
public float GetCost(int2 p, Actor forActor)
|
||||||
{
|
{
|
||||||
var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
// Todo: Do we even need to reenable this since cost = 100% for everything?
|
||||||
if (customTerrain[p.X, p.Y] != null)
|
//var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
||||||
return customTerrain[p.X,p.Y].GetCost(p,umt);
|
//if (customTerrain[p.X, p.Y] != null)
|
||||||
|
// return customTerrain[p.X,p.Y].GetCost(p,umt);
|
||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetSpeedModifier(int2 p, Actor forActor)
|
public float GetSpeedModifier(int2 p, Actor forActor)
|
||||||
{
|
{
|
||||||
var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
// Todo: Do we even need to reenable this since cost = 100% for everything?
|
||||||
if (customTerrain[p.X, p.Y] != null)
|
//var umt = forActor.traits.Get<Mobile>().GetMovementType();
|
||||||
return customTerrain[p.X,p.Y].GetSpeedModifier(p,umt);
|
//if (customTerrain[p.X, p.Y] != null)
|
||||||
|
// return customTerrain[p.X,p.Y].GetSpeedModifier(p,umt);
|
||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var Info = self.Info.Traits.Get<HelicopterInfo>();
|
var Info = self.Info.Traits.Get<HelicopterInfo>();
|
||||||
var rawSpeed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly);
|
var mobile = self.traits.WithInterface<IMove>().FirstOrDefault();
|
||||||
|
var rawSpeed = .2f * mobile.MovementSpeedForCell(self, self.Location);
|
||||||
var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, Info.IdealSeparation)
|
var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, Info.IdealSeparation)
|
||||||
.Where(a => a.traits.Contains<Helicopter>());
|
.Where(a => a.traits.Contains<Helicopter>());
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ namespace OpenRA.Mods.RA
|
|||||||
if (cargo == null || cargo.IsFull(underCursor))
|
if (cargo == null || cargo.IsFull(underCursor))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var umt = self.traits.Get<IMove>().GetMovementType();
|
// Todo: Use something better for cargo management
|
||||||
if (!underCursor.Info.Traits.Get<CargoInfo>().PassengerTypes.Contains(umt))
|
//var umt = self.traits.Get<IMove>().GetMovementType();
|
||||||
|
//if (!underCursor.Info.Traits.Get<CargoInfo>().PassengerTypes.Contains(umt))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new Order("EnterTransport", self, underCursor);
|
return new Order("EnterTransport", self, underCursor);
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
|
||||||
|
### Todo: Need a ^Tank default for MovementType: Track
|
||||||
^Vehicle:
|
^Vehicle:
|
||||||
Category: Vehicle
|
Category: Vehicle
|
||||||
Unit:
|
Unit:
|
||||||
ROT: 5
|
ROT: 5
|
||||||
Mobile:
|
Mobile:
|
||||||
MovementType: Wheel
|
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River, Special
|
||||||
|
TerrainSpeeds: 60%, 40%, 100%, 0%, 0%, 0%, 0%, 50%, 40%, 0%, 100%
|
||||||
Selectable:
|
Selectable:
|
||||||
Voice: VehicleVoice
|
Voice: VehicleVoice
|
||||||
Repairable:
|
Repairable:
|
||||||
@@ -15,13 +18,47 @@
|
|||||||
GainsExperience:
|
GainsExperience:
|
||||||
GivesExperience:
|
GivesExperience:
|
||||||
|
|
||||||
|
^Tank:
|
||||||
|
Category: Vehicle
|
||||||
|
Unit:
|
||||||
|
ROT: 5
|
||||||
|
Mobile:
|
||||||
|
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River, Special
|
||||||
|
TerrainSpeeds: 80%, 70%, 100%, 0%, 0%, 0%, 0%, 70%, 70%, 0%, 100%
|
||||||
|
Selectable:
|
||||||
|
Voice: VehicleVoice
|
||||||
|
Repairable:
|
||||||
|
Chronoshiftable:
|
||||||
|
Passenger:
|
||||||
|
IronCurtainable:
|
||||||
|
HiddenUnderFog:
|
||||||
|
RevealsShroud:
|
||||||
|
GainsExperience:
|
||||||
|
GivesExperience:
|
||||||
|
|
||||||
|
^Helicopter:
|
||||||
|
Category: Plane
|
||||||
|
Unit:
|
||||||
|
TargetType: Air
|
||||||
|
Selectable:
|
||||||
|
Voice: VehicleVoice
|
||||||
|
HiddenUnderFog:
|
||||||
|
RevealsShroud:
|
||||||
|
GainsExperience:
|
||||||
|
GivesExperience:
|
||||||
|
MobileAir:
|
||||||
|
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River, Special
|
||||||
|
TerrainSpeeds: 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%
|
||||||
|
AvoidsAA:
|
||||||
|
|
||||||
^Infantry:
|
^Infantry:
|
||||||
Category: Infantry
|
Category: Infantry
|
||||||
Unit:
|
Unit:
|
||||||
Armor: none
|
Armor: none
|
||||||
Sight: 4
|
Sight: 4
|
||||||
Mobile:
|
Mobile:
|
||||||
MovementType: Foot
|
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River, Special
|
||||||
|
TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 90%, 80%, 0%, 100%
|
||||||
Selectable:
|
Selectable:
|
||||||
RenderInfantry:
|
RenderInfantry:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -33,17 +70,6 @@
|
|||||||
GivesExperience:
|
GivesExperience:
|
||||||
SharesCell:
|
SharesCell:
|
||||||
|
|
||||||
^Ship:
|
|
||||||
Category: Ship
|
|
||||||
Unit:
|
|
||||||
Mobile:
|
|
||||||
MovementType: Float
|
|
||||||
Selectable:
|
|
||||||
HiddenUnderFog:
|
|
||||||
RevealsShroud:
|
|
||||||
GainsExperience:
|
|
||||||
GivesExperience:
|
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
Category: Plane
|
Category: Plane
|
||||||
Unit:
|
Unit:
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ MCV:
|
|||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
|
|
||||||
HARV:
|
HARV:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: harvicnh
|
Icon: harvicnh
|
||||||
BuildPaletteOrder: 10
|
BuildPaletteOrder: 10
|
||||||
@@ -48,12 +48,10 @@ HARV:
|
|||||||
Crewed: yes
|
Crewed: yes
|
||||||
Sight: 4
|
Sight: 4
|
||||||
Speed: 6
|
Speed: 6
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
|
|
||||||
APC:
|
APC:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: apcicnh
|
Icon: apcicnh
|
||||||
BuildPaletteOrder: 30
|
BuildPaletteOrder: 30
|
||||||
@@ -68,8 +66,6 @@ APC:
|
|||||||
ROT: 5
|
ROT: 5
|
||||||
Sight: 5
|
Sight: 5
|
||||||
Speed: 15
|
Speed: 15
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
AttackBase:
|
AttackBase:
|
||||||
PrimaryWeapon: MachineGun
|
PrimaryWeapon: MachineGun
|
||||||
PrimaryOffset: 0,0,0,-4
|
PrimaryOffset: 0,0,0,-4
|
||||||
@@ -83,7 +79,7 @@ APC:
|
|||||||
UnloadFacing: 220
|
UnloadFacing: 220
|
||||||
|
|
||||||
ARTY:
|
ARTY:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon:artyicnh
|
Icon:artyicnh
|
||||||
BuildPaletteOrder: 40
|
BuildPaletteOrder: 40
|
||||||
@@ -99,8 +95,6 @@ ARTY:
|
|||||||
ROT: 2
|
ROT: 2
|
||||||
Sight: 6
|
Sight: 6
|
||||||
Speed: 6
|
Speed: 6
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
AttackBase:
|
AttackBase:
|
||||||
PrimaryWeapon: Ballistic
|
PrimaryWeapon: Ballistic
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
@@ -108,7 +102,7 @@ ARTY:
|
|||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|
||||||
FTNK:
|
FTNK:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: ftnkicnh
|
Icon: ftnkicnh
|
||||||
BuildPaletteOrder: 50
|
BuildPaletteOrder: 50
|
||||||
@@ -211,7 +205,7 @@ JEEP:
|
|||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|
||||||
LTNK:
|
LTNK:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: ltnkicnh
|
Icon: ltnkicnh
|
||||||
BuildPaletteOrder: 30
|
BuildPaletteOrder: 30
|
||||||
@@ -226,8 +220,6 @@ LTNK:
|
|||||||
Crewed: yes
|
Crewed: yes
|
||||||
Sight: 4
|
Sight: 4
|
||||||
Speed: 9
|
Speed: 9
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
Turreted:
|
Turreted:
|
||||||
ROT: 5
|
ROT: 5
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
@@ -242,7 +234,7 @@ LTNK:
|
|||||||
EmptyWeapon: UnitExplodeSmall
|
EmptyWeapon: UnitExplodeSmall
|
||||||
|
|
||||||
MTNK:
|
MTNK:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: mtnkicnh
|
Icon: mtnkicnh
|
||||||
BuildPaletteOrder: 30
|
BuildPaletteOrder: 30
|
||||||
@@ -257,8 +249,6 @@ MTNK:
|
|||||||
Crewed: yes
|
Crewed: yes
|
||||||
Sight: 5
|
Sight: 5
|
||||||
Speed: 9
|
Speed: 9
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
Turreted:
|
Turreted:
|
||||||
ROT: 5
|
ROT: 5
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
@@ -273,7 +263,7 @@ MTNK:
|
|||||||
EmptyWeapon: UnitExplodeSmall
|
EmptyWeapon: UnitExplodeSmall
|
||||||
|
|
||||||
HTNK:
|
HTNK:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: htnkicnh
|
Icon: htnkicnh
|
||||||
BuildPaletteOrder: 60
|
BuildPaletteOrder: 60
|
||||||
@@ -288,8 +278,6 @@ HTNK:
|
|||||||
Crewed: yes
|
Crewed: yes
|
||||||
Sight: 6
|
Sight: 6
|
||||||
Speed: 3
|
Speed: 3
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
Turreted:
|
Turreted:
|
||||||
ROT: 2
|
ROT: 2
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
@@ -308,7 +296,7 @@ HTNK:
|
|||||||
EmptyWeapon: UnitExplodeSmall
|
EmptyWeapon: UnitExplodeSmall
|
||||||
|
|
||||||
MSAM:
|
MSAM:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: msamicnh
|
Icon: msamicnh
|
||||||
BuildPaletteOrder: 50
|
BuildPaletteOrder: 50
|
||||||
@@ -323,8 +311,6 @@ MSAM:
|
|||||||
Crewed: yes
|
Crewed: yes
|
||||||
Sight: 6
|
Sight: 6
|
||||||
Speed: 6
|
Speed: 6
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
Turreted:
|
Turreted:
|
||||||
ROT: 5
|
ROT: 5
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
@@ -335,7 +321,7 @@ MSAM:
|
|||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|
||||||
MLRS:
|
MLRS:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Tank
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: mlrsicnh
|
Icon: mlrsicnh
|
||||||
BuildPaletteOrder: 60
|
BuildPaletteOrder: 60
|
||||||
@@ -350,8 +336,6 @@ MLRS:
|
|||||||
Crewed: yes
|
Crewed: yes
|
||||||
Sight: 10
|
Sight: 10
|
||||||
Speed: 6
|
Speed: 6
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
Turreted:
|
Turreted:
|
||||||
ROT: 5
|
ROT: 5
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
@@ -381,15 +365,13 @@ STNK:
|
|||||||
CloakDelay: 2.0
|
CloakDelay: 2.0
|
||||||
CloakSound: appear1.aud
|
CloakSound: appear1.aud
|
||||||
UncloakSound: appear1.aud
|
UncloakSound: appear1.aud
|
||||||
Mobile:
|
|
||||||
MovementType: Track
|
|
||||||
AttackBase:
|
AttackBase:
|
||||||
PrimaryWeapon: 227mm
|
PrimaryWeapon: 227mm
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|
||||||
TRAN:
|
TRAN:
|
||||||
Inherits: ^Plane
|
Inherits: ^Helicopter
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon:tranicnh
|
Icon:tranicnh
|
||||||
BuildPaletteOrder: 10
|
BuildPaletteOrder: 10
|
||||||
@@ -406,10 +388,6 @@ TRAN:
|
|||||||
ROT: 5
|
ROT: 5
|
||||||
Sight: 8
|
Sight: 8
|
||||||
Speed: 15
|
Speed: 15
|
||||||
# Helicopter:
|
|
||||||
AvoidsAA:
|
|
||||||
MobileAir:
|
|
||||||
MovementType: Fly
|
|
||||||
RenderUnitRotor:
|
RenderUnitRotor:
|
||||||
PrimaryOffset: 0,14,0,-4
|
PrimaryOffset: 0,14,0,-4
|
||||||
SecondaryOffset: 0,-14,0,-2
|
SecondaryOffset: 0,-14,0,-2
|
||||||
@@ -419,7 +397,7 @@ TRAN:
|
|||||||
Passengers: 5
|
Passengers: 5
|
||||||
|
|
||||||
HELI:
|
HELI:
|
||||||
Inherits: ^Plane
|
Inherits: ^Helicopter
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: heliicnh
|
Icon: heliicnh
|
||||||
BuildPaletteOrder: 20
|
BuildPaletteOrder: 20
|
||||||
@@ -442,15 +420,12 @@ HELI:
|
|||||||
SecondaryWeapon: HighV
|
SecondaryWeapon: HighV
|
||||||
PrimaryOffset: -5,0,0,2
|
PrimaryOffset: -5,0,0,2
|
||||||
SecondaryOffset: 5,0,0,2
|
SecondaryOffset: 5,0,0,2
|
||||||
# Helicopter:
|
|
||||||
MobileAir:
|
|
||||||
MovementType: Fly
|
|
||||||
RenderUnitRotor:
|
RenderUnitRotor:
|
||||||
PrimaryOffset: 0,0,0,-2
|
PrimaryOffset: 0,0,0,-2
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
|
||||||
ORCA:
|
ORCA:
|
||||||
Inherits: ^Plane
|
Inherits: ^Helicopter
|
||||||
Buildable:
|
Buildable:
|
||||||
Icon: orcaicnh
|
Icon: orcaicnh
|
||||||
BuildPaletteOrder: 20
|
BuildPaletteOrder: 20
|
||||||
@@ -473,9 +448,6 @@ ORCA:
|
|||||||
SecondaryWeapon: Rockets.Orca
|
SecondaryWeapon: Rockets.Orca
|
||||||
PrimaryOffset: -5,0,0,2
|
PrimaryOffset: -5,0,0,2
|
||||||
SecondaryOffset: 5,0,0,2
|
SecondaryOffset: 5,0,0,2
|
||||||
# Helicopter:
|
|
||||||
MobileAir:
|
|
||||||
MovementType: Fly
|
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user