Actor stores a ref to World
This commit is contained in:
@@ -14,7 +14,10 @@ namespace OpenRa
|
|||||||
[Sync]
|
[Sync]
|
||||||
public readonly TypeDictionary traits = new TypeDictionary();
|
public readonly TypeDictionary traits = new TypeDictionary();
|
||||||
public readonly ActorInfo Info;
|
public readonly ActorInfo Info;
|
||||||
|
|
||||||
|
public readonly World World;
|
||||||
public readonly uint ActorID;
|
public readonly uint ActorID;
|
||||||
|
|
||||||
[Sync]
|
[Sync]
|
||||||
public int2 Location;
|
public int2 Location;
|
||||||
[Sync]
|
[Sync]
|
||||||
@@ -25,6 +28,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
public Actor( World world, string name, int2 location, Player owner )
|
public Actor( World world, string name, int2 location, Player owner )
|
||||||
{
|
{
|
||||||
|
World = world;
|
||||||
ActorID = world.NextAID();
|
ActorID = world.NextAID();
|
||||||
Location = location;
|
Location = location;
|
||||||
CenterLocation = Traits.Util.CenterOfCell(Location);
|
CenterLocation = Traits.Util.CenterOfCell(Location);
|
||||||
@@ -82,14 +86,14 @@ namespace OpenRa
|
|||||||
|
|
||||||
public Order Order( int2 xy, MouseInput mi )
|
public Order Order( int2 xy, MouseInput mi )
|
||||||
{
|
{
|
||||||
if (Owner != Game.world.LocalPlayer)
|
if (Owner != World.LocalPlayer)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!Game.world.Map.IsInMap(xy.X, xy.Y))
|
if (!World.Map.IsInMap(xy.X, xy.Y))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var loc = mi.Location + Game.viewport.Location;
|
var loc = mi.Location + Game.viewport.Location;
|
||||||
var underCursor = Game.world.FindUnits(loc, loc).FirstOrDefault();
|
var underCursor = World.FindUnits(loc, loc).FirstOrDefault();
|
||||||
|
|
||||||
if (underCursor != null && !underCursor.traits.Contains<Selectable>())
|
if (underCursor != null && !underCursor.traits.Contains<Selectable>())
|
||||||
underCursor = null;
|
underCursor = null;
|
||||||
@@ -147,7 +151,7 @@ namespace OpenRa
|
|||||||
attacker.Owner.Kills++;
|
attacker.Owner.Kills++;
|
||||||
|
|
||||||
if (RemoveOnDeath)
|
if (RemoveOnDeath)
|
||||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
World.AddFrameEndTask(w => w.Remove(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxHP = this.GetMaxHP();
|
var maxHP = this.GetMaxHP();
|
||||||
|
|||||||
Reference in New Issue
Block a user