moved BIM/UIM to World, and added World.CreateActor
This commit is contained in:
@@ -40,8 +40,6 @@ namespace OpenRa
|
|||||||
viewport.GoToStartLocation();
|
viewport.GoToStartLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static BuildingInfluenceMap BuildingInfluence;
|
|
||||||
public static UnitInfluenceMap UnitInfluence;
|
|
||||||
|
|
||||||
public static bool skipMakeAnims = true;
|
public static bool skipMakeAnims = true;
|
||||||
|
|
||||||
@@ -74,9 +72,6 @@ namespace OpenRa
|
|||||||
|
|
||||||
palette = new HardwarePalette(renderer, world.Map);
|
palette = new HardwarePalette(renderer, world.Map);
|
||||||
|
|
||||||
var worldActor = new Actor("World", new int2(int.MaxValue, int.MaxValue), null);
|
|
||||||
Game.world.Add(worldActor);
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
var race = players.ContainsKey(i) ? players[i].Race : Race.Allies;
|
var race = players.ContainsKey(i) ? players[i].Race : Race.Allies;
|
||||||
@@ -92,12 +87,9 @@ namespace OpenRa
|
|||||||
|
|
||||||
minimap = new Minimap(renderer);
|
minimap = new Minimap(renderer);
|
||||||
|
|
||||||
BuildingInfluence = new BuildingInfluenceMap();
|
|
||||||
UnitInfluence = new UnitInfluenceMap();
|
|
||||||
|
|
||||||
skipMakeAnims = true;
|
skipMakeAnims = true;
|
||||||
foreach (var treeReference in Game.world.Map.Trees)
|
foreach (var treeReference in Game.world.Map.Trees)
|
||||||
world.Add(new Actor(treeReference.Image, new int2(treeReference.Location), null));
|
world.CreateActor(treeReference.Image, new int2(treeReference.Location), null);
|
||||||
|
|
||||||
LoadMapActors(Rules.AllRules);
|
LoadMapActors(Rules.AllRules);
|
||||||
skipMakeAnims = false;
|
skipMakeAnims = false;
|
||||||
@@ -154,8 +146,8 @@ namespace OpenRa
|
|||||||
//num=owner,type,health,location,facing,...
|
//num=owner,type,health,location,facing,...
|
||||||
var parts = s.Value.Split( ',' );
|
var parts = s.Value.Split( ',' );
|
||||||
var loc = int.Parse(parts[3]);
|
var loc = int.Parse(parts[3]);
|
||||||
world.Add(new Actor(parts[1].ToLowerInvariant(), new int2(loc % 128, loc / 128),
|
world.CreateActor(parts[1].ToLowerInvariant(), new int2(loc % 128, loc / 128),
|
||||||
players.Values.FirstOrDefault(p => p.InternalName == parts[0]) ?? players[0]));
|
players.Values.FirstOrDefault(p => p.InternalName == parts[0]) ?? players[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +201,7 @@ namespace OpenRa
|
|||||||
}
|
}
|
||||||
|
|
||||||
world.Tick();
|
world.Tick();
|
||||||
UnitInfluence.Tick();
|
Game.world.UnitInfluence.Tick();
|
||||||
foreach (var player in players.Values)
|
foreach (var player in players.Values)
|
||||||
player.Tick();
|
player.Tick();
|
||||||
}
|
}
|
||||||
@@ -248,8 +240,8 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static bool IsCellBuildable(int2 a, UnitMovementType umt, Actor toIgnore)
|
public static bool IsCellBuildable(int2 a, UnitMovementType umt, Actor toIgnore)
|
||||||
{
|
{
|
||||||
if (BuildingInfluence.GetBuildingAt(a) != null) return false;
|
if (Game.world.BuildingInfluence.GetBuildingAt(a) != null) return false;
|
||||||
if (UnitInfluence.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
if (Game.world.UnitInfluence.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||||
|
|
||||||
return Game.world.Map.IsInMap(a.X, a.Y) &&
|
return Game.world.Map.IsInMap(a.X, a.Y) &&
|
||||||
TerrainCosts.Cost(umt,
|
TerrainCosts.Cost(umt,
|
||||||
@@ -350,7 +342,7 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
heuristic = loc =>
|
heuristic = loc =>
|
||||||
{
|
{
|
||||||
var b = Game.BuildingInfluence.GetBuildingAt(loc);
|
var b = Game.world.BuildingInfluence.GetBuildingAt(loc);
|
||||||
if (b != null && b.Owner == p && b.Info.Traits.Get<BuildingInfo>().BaseNormal) return 0;
|
if (b != null && b.Owner == p && b.Info.Traits.Get<BuildingInfo>().BaseNormal) return 0;
|
||||||
if ((loc - position).Length > maxDistance)
|
if ((loc - position).Length > maxDistance)
|
||||||
return float.PositiveInfinity; /* not quite right */
|
return float.PositiveInfinity; /* not quite right */
|
||||||
@@ -416,7 +408,7 @@ namespace OpenRa
|
|||||||
// todo: spawn more than one unit, in most cases!
|
// todo: spawn more than one unit, in most cases!
|
||||||
|
|
||||||
var sp = ChooseSpawnPoint(available, taken);
|
var sp = ChooseSpawnPoint(available, taken);
|
||||||
world.Add(new Actor("mcv", sp, players[client.Index]));
|
world.CreateActor("mcv", sp, players[client.Index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.viewport.GoToStartLocation();
|
Game.viewport.GoToStartLocation();
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace OpenRa.Graphics
|
|||||||
for (var y = 0; y < 128; y++)
|
for (var y = 0; y < 128; y++)
|
||||||
for (var x = 0; x < 128; x++)
|
for (var x = 0; x < 128; x++)
|
||||||
{
|
{
|
||||||
var b = Game.BuildingInfluence.GetBuildingAt(new int2(x, y));
|
var b = Game.world.BuildingInfluence.GetBuildingAt(new int2(x, y));
|
||||||
if (b != null)
|
if (b != null)
|
||||||
*(c + (y * bitmapData.Stride >> 2) + x) =
|
*(c + (y * bitmapData.Stride >> 2) + x) =
|
||||||
(b.Owner != null ? playerColors[(int)b.Owner.Palette] : terrainTypeColors[4]).ToArgb();
|
(b.Owner != null ? playerColors[(int)b.Owner.Palette] : terrainTypeColors[4]).ToArgb();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRa.Orders
|
|||||||
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Game.world.Add( new Actor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( unit.Traits.Get<BuildingInfo>() ), order.Player ) );
|
Game.world.CreateActor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( unit.Traits.Get<BuildingInfo>() ), order.Player );
|
||||||
if (order.Player == Game.LocalPlayer)
|
if (order.Player == Game.LocalPlayer)
|
||||||
{
|
{
|
||||||
Sound.Play("placbldg.aud");
|
Sound.Play("placbldg.aud");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static bool CanSpreadInto(int i, int j)
|
public static bool CanSpreadInto(int i, int j)
|
||||||
{
|
{
|
||||||
if (Game.BuildingInfluence.GetBuildingAt(new int2(i, j)) != null)
|
if (Game.world.BuildingInfluence.GetBuildingAt(new int2(i, j)) != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return TerrainCosts.Cost(UnitMovementType.Wheel,
|
return TerrainCosts.Cost(UnitMovementType.Wheel,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenRa
|
|||||||
return q =>
|
return q =>
|
||||||
p != q &&
|
p != q &&
|
||||||
((p - q).LengthSquared < dist * dist) &&
|
((p - q).LengthSquared < dist * dist) &&
|
||||||
(Game.UnitInfluence.GetUnitsAt(q).Any());
|
(Game.world.UnitInfluence.GetUnitsAt(q).Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<int2> FindPath( PathSearch search )
|
public List<int2> FindPath( PathSearch search )
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity)
|
if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity)
|
||||||
continue;
|
continue;
|
||||||
if (!Game.BuildingInfluence.CanMoveHere(newHere) &&
|
if (!Game.world.BuildingInfluence.CanMoveHere(newHere) &&
|
||||||
Game.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
|
Game.world.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
|
||||||
continue;
|
continue;
|
||||||
if (Game.world.Map.IsOverlaySolid(newHere))
|
if (Game.world.Map.IsOverlaySolid(newHere))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replicate real-ra behavior of not being able to enter a cell if there is a mixture of crushable and uncrushable units
|
// Replicate real-ra behavior of not being able to enter a cell if there is a mixture of crushable and uncrushable units
|
||||||
if (checkForBlocked && (Game.UnitInfluence.GetUnitsAt(newHere).Any(a => !Game.IsActorPathableToCrush(a, umt))))
|
if (checkForBlocked && (Game.world.UnitInfluence.GetUnitsAt(newHere).Any(a => !Game.IsActorPathableToCrush(a, umt))))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (customBlock != null && customBlock(newHere))
|
if (customBlock != null && customBlock(newHere))
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRa
|
|||||||
public Player( int index, Session.Client client )
|
public Player( int index, Session.Client client )
|
||||||
{
|
{
|
||||||
Shroud = new Shroud(this);
|
Shroud = new Shroud(this);
|
||||||
Game.world.Add(this.PlayerActor = new Actor("Player", new int2(int.MaxValue, int.MaxValue), this));
|
this.PlayerActor = Game.world.CreateActor("Player", new int2(int.MaxValue, int.MaxValue), this);
|
||||||
this.Index = index;
|
this.Index = index;
|
||||||
this.InternalName = "Multi{0}".F(index);
|
this.InternalName = "Multi{0}".F(index);
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,11 @@ namespace OpenRa.Traits
|
|||||||
Game.world.AddFrameEndTask(
|
Game.world.AddFrameEndTask(
|
||||||
w =>
|
w =>
|
||||||
{ /* create the free harvester! */
|
{ /* create the free harvester! */
|
||||||
var harvester = new Actor("harv", self.Location + new int2(1, 2), self.Owner);
|
var harvester = w.CreateActor("harv", self.Location + new int2(1, 2), self.Owner);
|
||||||
var unit = harvester.traits.Get<Unit>();
|
var unit = harvester.traits.Get<Unit>();
|
||||||
var mobile = harvester.traits.Get<Mobile>();
|
var mobile = harvester.traits.Get<Mobile>();
|
||||||
unit.Facing = 64;
|
unit.Facing = 64;
|
||||||
harvester.QueueActivity(new Harvest());
|
harvester.QueueActivity(new Harvest());
|
||||||
w.Add(harvester);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
Sound.Play("placbldg.aud");
|
Sound.Play("placbldg.aud");
|
||||||
Sound.Play("build5.aud");
|
Sound.Play("build5.aud");
|
||||||
}
|
}
|
||||||
Game.world.Add( new Actor( "fact", self.Location - new int2( 1, 1 ), self.Owner ) );
|
Game.world.CreateActor( "fact", self.Location - new int2( 1, 1 ), self.Owner );
|
||||||
} );
|
} );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ namespace OpenRa.Traits.Activities
|
|||||||
|
|
||||||
bool CanEnterCell( int2 c, Actor self )
|
bool CanEnterCell( int2 c, Actor self )
|
||||||
{
|
{
|
||||||
if (!Game.BuildingInfluence.CanMoveHere(c)
|
if (!Game.world.BuildingInfluence.CanMoveHere(c)
|
||||||
&& Game.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding)
|
&& Game.world.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Cannot enter a cell if any unit inside is uncrushable
|
// Cannot enter a cell if any unit inside is uncrushable
|
||||||
// This will need to be updated for multiple-infantry-in-a-cell
|
// This will need to be updated for multiple-infantry-in-a-cell
|
||||||
return (!Game.UnitInfluence.GetUnitsAt(c).Any(a => a != self && !Game.IsActorCrushableByActor(a, self)));
|
return (!Game.world.UnitInfluence.GetUnitsAt(c).Any(a => a != self && !Game.IsActorCrushableByActor(a, self)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActivity Tick( Actor self )
|
public IActivity Tick( Actor self )
|
||||||
@@ -144,10 +144,10 @@ namespace OpenRa.Traits.Activities
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.UnitInfluence.Remove( self, mobile );
|
Game.world.UnitInfluence.Remove( self, mobile );
|
||||||
var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList();
|
var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList();
|
||||||
|
|
||||||
Game.UnitInfluence.Add( self, mobile );
|
Game.world.UnitInfluence.Add( self, mobile );
|
||||||
if (newPath.Count != 0)
|
if (newPath.Count != 0)
|
||||||
path = newPath;
|
path = newPath;
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ namespace OpenRa.Traits.Activities
|
|||||||
ns.Sold(self);
|
ns.Sold(self);
|
||||||
w.Remove(self);
|
w.Remove(self);
|
||||||
|
|
||||||
var mcv = new Actor("mcv", self.Location + new int2(1, 1), self.Owner);
|
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
||||||
mcv.traits.Get<Unit>().Facing = 96;
|
mcv.traits.Get<Unit>().Facing = 96;
|
||||||
w.Add(mcv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
int2? ChooseExitTile(Actor self)
|
int2? ChooseExitTile(Actor self)
|
||||||
{
|
{
|
||||||
// is anyone still hogging this tile?
|
// is anyone still hogging this tile?
|
||||||
if (Game.UnitInfluence.GetUnitsAt(self.Location).Count() > 1)
|
if (Game.world.UnitInfluence.GetUnitsAt(self.Location).Count() > 1)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (var i = -1; i < 2; i++)
|
for (var i = -1; i < 2; i++)
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public bool CanEnterCell(int2 a)
|
public bool CanEnterCell(int2 a)
|
||||||
{
|
{
|
||||||
if (!Game.BuildingInfluence.CanMoveHere(a)) return false;
|
if (!Game.world.BuildingInfluence.CanMoveHere(a)) return false;
|
||||||
|
|
||||||
var crushable = true;
|
var crushable = true;
|
||||||
foreach (Actor actor in Game.UnitInfluence.GetUnitsAt(a))
|
foreach (Actor actor in Game.world.UnitInfluence.GetUnitsAt(a))
|
||||||
{
|
{
|
||||||
if (actor == self) continue;
|
if (actor == self) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRa.Traits
|
|||||||
public int2 fromCell
|
public int2 fromCell
|
||||||
{
|
{
|
||||||
get { return __fromCell; }
|
get { return __fromCell; }
|
||||||
set { Game.UnitInfluence.Remove(self, this); __fromCell = value; Game.UnitInfluence.Add(self, this); }
|
set { Game.world.UnitInfluence.Remove(self, this); __fromCell = value; Game.world.UnitInfluence.Add(self, this); }
|
||||||
}
|
}
|
||||||
public int2 toCell
|
public int2 toCell
|
||||||
{
|
{
|
||||||
@@ -30,11 +30,11 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
if (self.Location != value)
|
if (self.Location != value)
|
||||||
{
|
{
|
||||||
Game.UnitInfluence.Remove(self, this);
|
Game.world.UnitInfluence.Remove(self, this);
|
||||||
self.Location = value;
|
self.Location = value;
|
||||||
self.Owner.Shroud.Explore(self);
|
self.Owner.Shroud.Explore(self);
|
||||||
}
|
}
|
||||||
Game.UnitInfluence.Add(self, this);
|
Game.world.UnitInfluence.Add(self, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
__fromCell = toCell;
|
__fromCell = toCell;
|
||||||
Game.UnitInfluence.Add(self, this);
|
Game.world.UnitInfluence.Add(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TeleportTo(Actor self, int2 xy)
|
public void TeleportTo(Actor self, int2 xy)
|
||||||
@@ -90,10 +90,10 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public bool CanEnterCell(int2 a)
|
public bool CanEnterCell(int2 a)
|
||||||
{
|
{
|
||||||
if (!Game.BuildingInfluence.CanMoveHere(a)) return false;
|
if (!Game.world.BuildingInfluence.CanMoveHere(a)) return false;
|
||||||
|
|
||||||
var crushable = true;
|
var crushable = true;
|
||||||
foreach (Actor actor in Game.UnitInfluence.GetUnitsAt(a))
|
foreach (Actor actor in Game.world.UnitInfluence.GetUnitsAt(a))
|
||||||
{
|
{
|
||||||
if (actor == self) continue;
|
if (actor == self) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ namespace OpenRa.Traits
|
|||||||
public bool Produce( Actor self, ActorInfo producee )
|
public bool Produce( Actor self, ActorInfo producee )
|
||||||
{
|
{
|
||||||
var location = CreationLocation( self, producee );
|
var location = CreationLocation( self, producee );
|
||||||
if( location == null || Game.UnitInfluence.GetUnitsAt( location.Value ).Any() )
|
if( location == null || Game.world.UnitInfluence.GetUnitsAt( location.Value ).Any() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var newUnit = new Actor( producee.Name, location.Value, self.Owner );
|
var newUnit = Game.world.CreateActor( producee.Name, location.Value, self.Owner );
|
||||||
newUnit.traits.Get<Unit>().Facing = CreationFacing( self, newUnit ); ;
|
newUnit.traits.Get<Unit>().Facing = CreationFacing( self, newUnit ); ;
|
||||||
|
|
||||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||||
@@ -51,8 +51,6 @@ namespace OpenRa.Traits
|
|||||||
newUnit.CenterLocation = self.CenterLocation
|
newUnit.CenterLocation = self.CenterLocation
|
||||||
+ new float2(pi.SpawnOffset[0], pi.SpawnOffset[1]);
|
+ new float2(pi.SpawnOffset[0], pi.SpawnOffset[1]);
|
||||||
|
|
||||||
Game.world.Add( newUnit );
|
|
||||||
|
|
||||||
foreach (var t in self.traits.WithInterface<INotifyProduction>())
|
foreach (var t in self.traits.WithInterface<INotifyProduction>())
|
||||||
t.UnitProduced(self, newUnit);
|
t.UnitProduced(self, newUnit);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRa.Traits
|
|||||||
if (doneBuilding) roof.Tick();
|
if (doneBuilding) roof.Tick();
|
||||||
|
|
||||||
var b = self.GetBounds(false);
|
var b = self.GetBounds(false);
|
||||||
if (isOpen && !Game.UnitInfluence.GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any())
|
if (isOpen && !Game.world.UnitInfluence.GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any())
|
||||||
{
|
{
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
roof.PlayBackwardsThen(GetPrefix(self) + "build-top", () => roof.Play(GetPrefix(self) + "idle-top"));
|
roof.PlayBackwardsThen(GetPrefix(self) + "build-top", () => roof.Play(GetPrefix(self) + "idle-top"));
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRa
|
|||||||
if (ShowUnitDebug)
|
if (ShowUnitDebug)
|
||||||
for (var j = 0; j < 128; j++)
|
for (var j = 0; j < 128; j++)
|
||||||
for (var i = 0; i < 128; i++)
|
for (var i = 0; i < 128; i++)
|
||||||
if (Game.UnitInfluence.GetUnitsAt(new int2(i, j)).Any())
|
if (Game.world.UnitInfluence.GetUnitsAt(new int2(i, j)).Any())
|
||||||
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0);
|
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ namespace OpenRa
|
|||||||
List<IEffect> effects = new List<IEffect>();
|
List<IEffect> effects = new List<IEffect>();
|
||||||
List<Action<World>> frameEndActions = new List<Action<World>>();
|
List<Action<World>> frameEndActions = new List<Action<World>>();
|
||||||
|
|
||||||
|
public readonly BuildingInfluenceMap BuildingInfluence;
|
||||||
|
public readonly UnitInfluenceMap UnitInfluence;
|
||||||
|
|
||||||
public readonly Map Map;
|
public readonly Map Map;
|
||||||
public readonly TileSet TileSet;
|
public readonly TileSet TileSet;
|
||||||
|
|
||||||
@@ -20,6 +23,18 @@ namespace OpenRa
|
|||||||
Map = new Map( Rules.AllRules );
|
Map = new Map( Rules.AllRules );
|
||||||
FileSystem.MountTemporary( new Package( Map.Theater + ".mix" ) );
|
FileSystem.MountTemporary( new Package( Map.Theater + ".mix" ) );
|
||||||
TileSet = new TileSet( Map.TileSuffix );
|
TileSet = new TileSet( Map.TileSuffix );
|
||||||
|
|
||||||
|
BuildingInfluence = new BuildingInfluenceMap();
|
||||||
|
UnitInfluence = new UnitInfluenceMap();
|
||||||
|
|
||||||
|
CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Actor CreateActor( string name, int2 location, Player owner )
|
||||||
|
{
|
||||||
|
var a = new Actor( name, location, owner );
|
||||||
|
Add( a );
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(Actor a)
|
public void Add(Actor a)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRa.Mods.RA
|
|||||||
public Mine(Actor self)
|
public Mine(Actor self)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
Game.UnitInfluence.Add(self, this);
|
Game.world.UnitInfluence.Add(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRa.Mods.RA
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Ensure that the cell is empty except for the minelayer
|
// Ensure that the cell is empty except for the minelayer
|
||||||
if (Game.UnitInfluence.GetUnitsAt(xy).Any(a => a != self))
|
if (Game.world.UnitInfluence.GetUnitsAt(xy).Any(a => a != self))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Right && underCursor == self)
|
if (mi.Button == MouseButton.Right && underCursor == self)
|
||||||
@@ -37,7 +37,7 @@ namespace OpenRa.Mods.RA
|
|||||||
// todo: delay a bit? (req making deploy-mine an activity)
|
// todo: delay a bit? (req making deploy-mine an activity)
|
||||||
|
|
||||||
Game.world.AddFrameEndTask(
|
Game.world.AddFrameEndTask(
|
||||||
w => w.Add(new Actor(self.Info.Traits.Get<MinelayerInfo>().Mine, self.Location, self.Owner)));
|
w => w.CreateActor(self.Info.Traits.Get<MinelayerInfo>().Mine, self.Location, self.Owner));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user