Skip to content

Commit 34cd717

Browse files
committed
Merge pull request OpenRA#8071 from pchote/remove-trait-test-plumbing
Remove plumbing for trait unit tests.
2 parents 0cfa1d3 + b1e285f commit 34cd717

File tree

16 files changed

+29
-584
lines changed

16 files changed

+29
-584
lines changed

OpenRA.Game/Actor.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,13 @@
2222

2323
namespace OpenRA
2424
{
25-
public interface IActor
26-
{
27-
ActorInfo Info { get; }
28-
IWorld World { get; }
29-
uint ActorID { get; }
30-
Player Owner { get; set; }
31-
32-
T TraitOrDefault<T>();
33-
T Trait<T>();
34-
IEnumerable<T> TraitsImplementing<T>();
35-
36-
IEnumerable<IRenderable> Render(WorldRenderer wr);
37-
}
38-
39-
public class Actor : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding, IEquatable<Actor>, IActor
25+
public class Actor : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding, IEquatable<Actor>
4026
{
4127
public readonly ActorInfo Info;
42-
ActorInfo IActor.Info { get { return this.Info; } }
4328

4429
public readonly World World;
45-
IWorld IActor.World { get { return World; } }
4630

4731
public readonly uint ActorID;
48-
uint IActor.ActorID { get { return this.ActorID; } }
4932

5033
[Sync] public Player Owner { get; set; }
5134

OpenRA.Game/Map/CellLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class CellLayer<T> : IEnumerable<T>
2424

2525
readonly T[] entries;
2626

27-
public CellLayer(IMap map)
27+
public CellLayer(Map map)
2828
: this(map.TileShape, new Size(map.MapSize.X, map.MapSize.Y)) { }
2929

3030
public CellLayer(TileShape shape, Size size)

OpenRA.Game/Map/Map.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,7 @@ public enum MapVisibility
111111
MissionSelector = 4
112112
}
113113

114-
public interface IMap
115-
{
116-
TileShape TileShape { get; }
117-
118-
int2 MapSize { get; set; }
119-
bool Contains(CPos cell);
120-
CPos CellContaining(WPos pos);
121-
WVec OffsetOfSubCell(SubCell subCell);
122-
IEnumerable<CPos> FindTilesInCircle(CPos center, int maxRange);
123-
WPos CenterOfCell(CPos cell);
124-
}
125-
126-
public class Map : IMap
114+
public class Map
127115
{
128116
static readonly int[][] CellCornerHalfHeights = new int[][]
129117
{
@@ -163,10 +151,6 @@ public class Map : IMap
163151

164152
public const int MaxTilesInCircleRange = 50;
165153
public readonly TileShape TileShape;
166-
TileShape IMap.TileShape
167-
{
168-
get { return TileShape; }
169-
}
170154

171155
[FieldLoader.Ignore] public readonly WVec[] SubCellOffsets;
172156
public readonly SubCell DefaultSubCell;
@@ -243,12 +227,6 @@ static object LoadVideos(MiniYaml y)
243227

244228
public int2 MapSize;
245229

246-
int2 IMap.MapSize
247-
{
248-
get { return MapSize; }
249-
set { MapSize = value; }
250-
}
251-
252230
[FieldLoader.Ignore] public Lazy<CellLayer<TerrainTile>> MapTiles;
253231
[FieldLoader.Ignore] public Lazy<CellLayer<ResourceTile>> MapResources;
254232
[FieldLoader.Ignore] public Lazy<CellLayer<byte>> MapHeight;

OpenRA.Game/World.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,7 @@ namespace OpenRA
2424
{
2525
public enum WorldType { Regular, Shellmap }
2626

27-
public interface IWorld
28-
{
29-
IActor WorldActor { get; }
30-
int WorldTick { get; }
31-
IMap Map { get; }
32-
TileSet TileSet { get; }
33-
}
34-
35-
public class World : IWorld
27+
public class World
3628
{
3729
class ActorIDComparer : IComparer<Actor>
3830
{
@@ -122,13 +114,10 @@ public void SetLocalPlayer(string pr)
122114
}
123115

124116
public readonly Actor WorldActor;
125-
IActor IWorld.WorldActor { get { return WorldActor; } }
126117

127118
public readonly Map Map;
128-
IMap IWorld.Map { get { return Map; } }
129119

130120
public readonly TileSet TileSet;
131-
TileSet IWorld.TileSet { get { return TileSet; } }
132121

133122
public readonly ActorMap ActorMap;
134123
public readonly ScreenMap ScreenMap;

OpenRA.Mods.Common/Pathfinder/CellInfoLayerManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface ICellInfoLayerManager
2929
/// <summary>
3030
/// Creates (or obtains from the pool) a CellLayer given a map
3131
/// </summary>
32-
CellLayer<CellInfo> NewLayer(IMap map);
32+
CellLayer<CellInfo> NewLayer(Map map);
3333
}
3434

3535
public sealed class CellInfoLayerManager : ICellInfoLayerManager
@@ -65,7 +65,7 @@ public void PutBackIntoPool(CellLayer<CellInfo> ci)
6565
cellInfoPool.Enqueue(ci);
6666
}
6767

68-
public CellLayer<CellInfo> NewLayer(IMap map)
68+
public CellLayer<CellInfo> NewLayer(Map map)
6969
{
7070
CellLayer<CellInfo> result = null;
7171
var mapSize = new Size(map.MapSize.X, map.MapSize.Y);

OpenRA.Mods.Common/Pathfinder/PathCacheStorage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class CachedPath
2222
}
2323

2424
const int MaxPathAge = 50;
25-
readonly IWorld world;
25+
readonly World world;
2626
Dictionary<string, CachedPath> cachedPaths = new Dictionary<string, CachedPath>(100);
2727

28-
public PathCacheStorage(IWorld world)
28+
public PathCacheStorage(World world)
2929
{
3030
this.world = world;
3131
}

OpenRA.Mods.Common/Pathfinder/PathFinderCacheDecorator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public PathFinderCacheDecorator(IPathFinder pathFinder, ICacheStorage<List<CPos>
2929
this.cacheStorage = cacheStorage;
3030
}
3131

32-
public List<CPos> FindUnitPath(CPos source, CPos target, IActor self)
32+
public List<CPos> FindUnitPath(CPos source, CPos target, Actor self)
3333
{
3434
using (new PerfSample("Pathfinder"))
3535
{
@@ -47,7 +47,7 @@ public List<CPos> FindUnitPath(CPos source, CPos target, IActor self)
4747
}
4848
}
4949

50-
public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, IActor self)
50+
public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, Actor self)
5151
{
5252
using (new PerfSample("Pathfinder"))
5353
{

OpenRA.Mods.Common/Pathfinder/PathGraph.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public interface IGraph<T> : IDisposable
3838

3939
bool InReverse { get; set; }
4040

41-
IActor IgnoredActor { get; set; }
41+
Actor IgnoredActor { get; set; }
4242

43-
IWorld World { get; }
43+
World World { get; }
4444

45-
IActor Actor { get; }
45+
Actor Actor { get; }
4646
}
4747

4848
public struct GraphConnection
@@ -61,21 +61,21 @@ public GraphConnection(CPos source, CPos destination, int cost)
6161

6262
public class PathGraph : IGraph<CellInfo>
6363
{
64-
public IActor Actor { get; private set; }
65-
public IWorld World { get; private set; }
64+
public Actor Actor { get; private set; }
65+
public World World { get; private set; }
6666
public Func<CPos, bool> CustomBlock { get; set; }
6767
public Func<CPos, int> CustomCost { get; set; }
6868
public int LaneBias { get; set; }
6969
public bool InReverse { get; set; }
70-
public IActor IgnoredActor { get; set; }
70+
public Actor IgnoredActor { get; set; }
7171

7272
readonly CellConditions checkConditions;
73-
readonly IMobileInfo mobileInfo;
73+
readonly MobileInfo mobileInfo;
7474
CellLayer<CellInfo> cellInfo;
7575

7676
public const int InvalidNode = int.MaxValue;
7777

78-
public PathGraph(CellLayer<CellInfo> cellInfo, IMobileInfo mobileInfo, IActor actor, IWorld world, bool checkForBlocked)
78+
public PathGraph(CellLayer<CellInfo> cellInfo, MobileInfo mobileInfo, Actor actor, World world, bool checkForBlocked)
7979
{
8080
this.cellInfo = cellInfo;
8181
World = world;

OpenRA.Mods.Common/Pathfinder/PathSearch.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ private PathSearch(IGraph<CellInfo> graph)
3232
considered = new LinkedList<Pair<CPos, int>>();
3333
}
3434

35-
public static IPathSearch Search(IWorld world, IMobileInfo mi, IActor self, bool checkForBlocked)
35+
public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked)
3636
{
3737
var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
3838
return new PathSearch(graph);
3939
}
4040

41-
public static IPathSearch FromPoint(IWorld world, IMobileInfo mi, IActor self, CPos from, CPos target, bool checkForBlocked)
41+
public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
4242
{
4343
var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
4444
var search = new PathSearch(graph)
@@ -52,7 +52,7 @@ public static IPathSearch FromPoint(IWorld world, IMobileInfo mi, IActor self, C
5252
return search;
5353
}
5454

55-
public static IPathSearch FromPoints(IWorld world, IMobileInfo mi, IActor self, IEnumerable<CPos> froms, CPos target, bool checkForBlocked)
55+
public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable<CPos> froms, CPos target, bool checkForBlocked)
5656
{
5757
var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
5858
var search = new PathSearch(graph)

OpenRA.Mods.Common/Traits/Mobile.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@ public enum CellConditions
2929
All = TransientActors | BlockedByMovers
3030
}
3131

32-
public interface IMobileInfo : IMoveInfo
33-
{
34-
int MovementCostForCell(World world, CPos cell);
35-
bool CanEnterCell(World world, Actor self, CPos cell, out int movementCost, Actor ignoreActor = null, CellConditions check = CellConditions.All);
36-
bool CanEnterCell(World world, Actor self, CPos cell, Actor ignoreActor = null, CellConditions check = CellConditions.All);
37-
int GetMovementClass(TileSet tileset);
38-
}
39-
4032
[Desc("Unit is able to move.")]
41-
public class MobileInfo : IMobileInfo, IOccupySpaceInfo, IFacingInfo, UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>
33+
public class MobileInfo : IMoveInfo, IOccupySpaceInfo, IFacingInfo, UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>
4234
{
4335
[FieldLoader.LoadUsing("LoadSpeeds")]
4436
[Desc("Set Water: 0 for ground units and lower the value on rough terrain.")]

OpenRA.Mods.Common/Traits/World/PathFinder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public interface IPathFinder
3232
/// Calculates a path for the actor from source to destination
3333
/// </summary>
3434
/// <returns>A path from start to target</returns>
35-
List<CPos> FindUnitPath(CPos source, CPos target, IActor self);
35+
List<CPos> FindUnitPath(CPos source, CPos target, Actor self);
3636

37-
List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, IActor self);
37+
List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, Actor self);
3838

3939
/// <summary>
4040
/// Calculates a path given a search specification
@@ -52,16 +52,16 @@ public interface IPathFinder
5252
public class PathFinder : IPathFinder
5353
{
5454
static readonly List<CPos> EmptyPath = new List<CPos>(0);
55-
readonly IWorld world;
55+
readonly World world;
5656

57-
public PathFinder(IWorld world)
57+
public PathFinder(World world)
5858
{
5959
this.world = world;
6060
}
6161

62-
public List<CPos> FindUnitPath(CPos source, CPos target, IActor self)
62+
public List<CPos> FindUnitPath(CPos source, CPos target, Actor self)
6363
{
64-
var mi = self.Info.Traits.Get<IMobileInfo>();
64+
var mi = self.Info.Traits.Get<MobileInfo>();
6565

6666
// If a water-land transition is required, bail early
6767
var domainIndex = world.WorldActor.TraitOrDefault<DomainIndex>();
@@ -81,7 +81,7 @@ public List<CPos> FindUnitPath(CPos source, CPos target, IActor self)
8181
return pb;
8282
}
8383

84-
public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, IActor self)
84+
public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, Actor self)
8585
{
8686
var mi = self.Info.Traits.Get<MobileInfo>();
8787
var targetCell = world.Map.CellContaining(target);

0 commit comments

Comments
 (0)