find/replace "Game.world." -> "self.World." in all traits and activities.

This commit is contained in:
Bob
2010-01-21 13:15:05 +13:00
parent dd93ee014a
commit 6688716aa5
49 changed files with 106 additions and 106 deletions

View File

@@ -11,7 +11,7 @@ namespace OpenRa.Traits
{ {
public AcceptsOre(Actor self) public AcceptsOre(Actor self)
{ {
Game.world.AddFrameEndTask( self.World.AddFrameEndTask(
w => w =>
{ /* create the free harvester! */ { /* create the free harvester! */
var harvester = w.CreateActor("harv", self.Location + new int2(1, 2), self.Owner); var harvester = w.CreateActor("harv", self.Location + new int2(1, 2), self.Owner);

View File

@@ -42,7 +42,7 @@ namespace OpenRa.Traits.Activities
umt = mobile.GetMovementType(), umt = mobile.GetMovementType(),
checkForBlocked = false, checkForBlocked = false,
}; };
var refineries = Game.world.Actors.Where( x => x.traits.Contains<AcceptsOre>() var refineries = self.World.Actors.Where( x => x.traits.Contains<AcceptsOre>()
&& x.Owner == self.Owner ).ToList(); && x.Owner == self.Owner ).ToList();
if( refinery != null ) if( refinery != null )
search.AddInitialCell( refinery.Location + refineryDeliverOffset ); search.AddInitialCell( refinery.Location + refineryDeliverOffset );
@@ -50,7 +50,7 @@ namespace OpenRa.Traits.Activities
foreach( var r in refineries ) foreach( var r in refineries )
search.AddInitialCell( r.Location + refineryDeliverOffset ); search.AddInitialCell( r.Location + refineryDeliverOffset );
var path = Game.world.PathFinder.FindPath( search ); var path = self.World.PathFinder.FindPath( search );
path.Reverse(); path.Reverse();
if( path.Count != 0 ) if( path.Count != 0 )
{ {

View File

@@ -8,16 +8,16 @@ namespace OpenRa.Traits.Activities
public IActivity Tick( Actor self ) public IActivity Tick( Actor self )
{ {
Game.world.AddFrameEndTask( _ => self.World.AddFrameEndTask( _ =>
{ {
self.Health = 0; self.Health = 0;
Game.world.Remove( self ); self.World.Remove( self );
if (self.Owner == Game.world.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
{ {
Sound.Play("placbldg.aud"); Sound.Play("placbldg.aud");
Sound.Play("build5.aud"); Sound.Play("build5.aud");
} }
Game.world.CreateActor( "fact", self.Location - new int2( 1, 1 ), self.Owner ); self.World.CreateActor( "fact", self.Location - new int2( 1, 1 ), self.Owner );
} ); } );
return this; return this;
} }

View File

@@ -26,7 +26,7 @@ namespace OpenRa.Traits.Activities
return NextActivity; return NextActivity;
cargo.Load(transport, self); cargo.Load(transport, self);
Game.world.AddFrameEndTask(w => w.Remove(self)); self.World.AddFrameEndTask(w => w.Remove(self));
return this; return this;
} }

View File

@@ -36,8 +36,8 @@ namespace OpenRa.Traits.Activities
var renderUnit = self.traits.Get<RenderUnit>(); /* better have one of these! */ var renderUnit = self.traits.Get<RenderUnit>(); /* better have one of these! */
var isGem = false; var isGem = false;
if (!Game.world.Map.ContainsResource(self.Location) || if (!self.World.Map.ContainsResource(self.Location) ||
!Game.world.Map.Harvest(self.Location, out isGem)) !self.World.Map.Harvest(self.Location, out isGem))
return false; return false;
var harvestAnim = "harvest" + Util.QuantizeFacing(unit.Facing, 8); var harvestAnim = "harvest" + Util.QuantizeFacing(unit.Facing, 8);
@@ -58,12 +58,12 @@ namespace OpenRa.Traits.Activities
{ {
var search = new PathSearch var search = new PathSearch
{ {
heuristic = loc => (Game.world.Map.ContainsResource(loc) ? 0 : 1), heuristic = loc => (self.World.Map.ContainsResource(loc) ? 0 : 1),
umt = UnitMovementType.Wheel, umt = UnitMovementType.Wheel,
checkForBlocked = true checkForBlocked = true
}; };
search.AddInitialCell(self.Location); search.AddInitialCell(self.Location);
return Game.world.PathFinder.FindPath(search); return self.World.PathFinder.FindPath(search);
})); }));
self.QueueActivity(new Harvest()); self.QueueActivity(new Harvest());
} }

View File

@@ -16,7 +16,7 @@ namespace OpenRa.Traits.Activities
if (unit.Altitude == 0) if (unit.Altitude == 0)
return NextActivity; return NextActivity;
if (requireSpace && !Game.world.IsCellBuildable(self.Location, UnitMovementType.Foot)) if (requireSpace && !self.World.IsCellBuildable(self.Location, UnitMovementType.Foot))
return this; // fail to land if no space return this; // fail to land if no space
--unit.Altitude; --unit.Altitude;

View File

@@ -9,7 +9,7 @@ namespace OpenRa.Traits.Activities
static Actor ChooseHelipad(Actor self) static Actor ChooseHelipad(Actor self)
{ {
return Game.world.Actors.FirstOrDefault( return self.World.Actors.FirstOrDefault(
a => a.Info.Name == "hpad" && a => a.Info.Name == "hpad" &&
a.Owner == self.Owner && a.Owner == self.Owner &&
!Reservable.IsReserved(a)); !Reservable.IsReserved(a));

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Traits.Activities
public Move( int2 destination, int nearEnough ) public Move( int2 destination, int nearEnough )
{ {
this.getPath = ( self, mobile ) => Game.world.PathFinder.FindUnitPath( this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPath(
self.Location, destination, self.Location, destination,
mobile.GetMovementType() ); mobile.GetMovementType() );
this.destination = destination; this.destination = destination;
@@ -30,9 +30,9 @@ namespace OpenRa.Traits.Activities
public Move(int2 destination, Actor ignoreBuilding) public Move(int2 destination, Actor ignoreBuilding)
{ {
this.getPath = (self, mobile) => this.getPath = (self, mobile) =>
Game.world.PathFinder.FindPath( self.World.PathFinder.FindPath(
PathSearch.FromPoint( self.Location, destination, mobile.GetMovementType(), false ) PathSearch.FromPoint( self.Location, destination, mobile.GetMovementType(), false )
.WithCustomBlocker( Game.world.PathFinder.AvoidUnitsNear( self.Location, 4 )).WithIgnoredBuilding( ignoreBuilding )); .WithCustomBlocker( self.World.PathFinder.AvoidUnitsNear( self.Location, 4 )).WithIgnoredBuilding( ignoreBuilding ));
this.destination = destination; this.destination = destination;
this.nearEnough = 0; this.nearEnough = 0;
@@ -41,7 +41,7 @@ namespace OpenRa.Traits.Activities
public Move( Actor target, int range ) public Move( Actor target, int range )
{ {
this.getPath = ( self, mobile ) => Game.world.PathFinder.FindUnitPathToRange( this.getPath = ( self, mobile ) => self.World.PathFinder.FindUnitPathToRange(
self.Location, target.Location, self.Location, target.Location,
mobile.GetMovementType(), range ); mobile.GetMovementType(), range );
this.destination = null; this.destination = null;
@@ -57,13 +57,13 @@ namespace OpenRa.Traits.Activities
bool CanEnterCell( int2 c, Actor self ) bool CanEnterCell( int2 c, Actor self )
{ {
if (!Game.world.BuildingInfluence.CanMoveHere(c) if (!self.World.BuildingInfluence.CanMoveHere(c)
&& Game.world.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding) && self.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.world.UnitInfluence.GetUnitsAt(c).Any(a => a != self && !Game.world.IsActorCrushableByActor(a, self))); return (!self.World.UnitInfluence.GetUnitsAt(c).Any(a => a != self && !self.World.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.world.UnitInfluence.Remove( self, mobile ); self.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.world.UnitInfluence.Add( self, mobile ); self.World.UnitInfluence.Add( self, mobile );
if (newPath.Count != 0) if (newPath.Count != 0)
path = newPath; path = newPath;

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Traits.Activities
{ {
if (!limitedAmmo.GiveAmmo()) return NextActivity; if (!limitedAmmo.GiveAmmo()) return NextActivity;
var hostBuilding = Game.world.FindUnits(self.CenterLocation, self.CenterLocation) var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
.FirstOrDefault(a => a.traits.Contains<RenderBuilding>()); .FirstOrDefault(a => a.traits.Contains<RenderBuilding>());
if (hostBuilding != null) if (hostBuilding != null)

View File

@@ -35,7 +35,7 @@ namespace OpenRa.Traits.Activities
if (self.Health == hp) if (self.Health == hp)
return NextActivity; return NextActivity;
var hostBuilding = Game.world.FindUnits(self.CenterLocation, self.CenterLocation) var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
.FirstOrDefault(a => a.traits.Contains<RenderBuilding>()); .FirstOrDefault(a => a.traits.Contains<RenderBuilding>());
if (hostBuilding != null) if (hostBuilding != null)

View File

@@ -18,7 +18,7 @@ namespace OpenRa.Traits.Activities
Actor ChooseAirfield(Actor self) Actor ChooseAirfield(Actor self)
{ {
var airfield = Game.world.Actors var airfield = self.World.Actors
.Where(a => a.Info.Name == "afld" .Where(a => a.Info.Name == "afld"
&& a.Owner == self.Owner && a.Owner == self.Owner
&& !Reservable.IsReserved(a)) && !Reservable.IsReserved(a))

View File

@@ -23,7 +23,7 @@ namespace OpenRa.Traits.Activities
self.Health = 0; self.Health = 0;
foreach (var ns in self.traits.WithInterface<INotifySold>()) foreach (var ns in self.traits.WithInterface<INotifySold>())
ns.Sold(self); ns.Sold(self);
Game.world.AddFrameEndTask( _ => Game.world.Remove( self ) ); self.World.AddFrameEndTask( _ => self.World.Remove( self ) );
// todo: give dudes // todo: give dudes
} }

View File

@@ -24,7 +24,7 @@ namespace OpenRa.Traits.Activities
{ {
var rb = self.traits.Get<RenderBuilding>(); var rb = self.traits.Get<RenderBuilding>();
rb.PlayCustomAnimBackwards(self, "make", rb.PlayCustomAnimBackwards(self, "make",
() => Game.world.AddFrameEndTask(w => DoUndeploy(w,self))); () => self.World.AddFrameEndTask(w => DoUndeploy(w,self)));
Sound.Play("cashturn.aud"); Sound.Play("cashturn.aud");
started = true; started = true;

View File

@@ -13,13 +13,13 @@ 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.world.UnitInfluence.GetUnitsAt(self.Location).Count() > 1) if (self.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++)
for (var j = -1; j < 2; j++) for (var j = -1; j < 2; j++)
if ((i != 0 || j != 0) && if ((i != 0 || j != 0) &&
Game.world.IsCellBuildable(self.Location + new int2(i, j), self.World.IsCellBuildable(self.Location + new int2(i, j),
UnitMovementType.Foot)) UnitMovementType.Foot))
return self.Location + new int2(i, j); return self.Location + new int2(i, j);
@@ -54,7 +54,7 @@ namespace OpenRa.Traits.Activities
var actor = cargo.Unload(self); var actor = cargo.Unload(self);
Game.world.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
w.Add(actor); w.Add(actor);
actor.traits.Get<Mobile>().TeleportTo(actor, self.Location); actor.traits.Get<Mobile>().TeleportTo(actor, self.Location);

View File

@@ -150,18 +150,18 @@ namespace OpenRa.Traits
var destAltitude = destUnit != null ? destUnit.Altitude : 0; var destAltitude = destUnit != null ? destUnit.Altitude : 0;
if( weapon.RenderAsTesla ) if( weapon.RenderAsTesla )
Game.world.Add( new TeslaZap( firePos, thisTarget.CenterLocation.ToInt2() ) ); self.World.Add( new TeslaZap( firePos, thisTarget.CenterLocation.ToInt2() ) );
if (Rules.ProjectileInfo[weapon.Projectile].ROT != 0) if (Rules.ProjectileInfo[weapon.Projectile].ROT != 0)
{ {
var fireFacing = thisLocalOffset.ElementAtOrDefault(2) + var fireFacing = thisLocalOffset.ElementAtOrDefault(2) +
(self.traits.Contains<Turreted>() ? self.traits.Get<Turreted>().turretFacing : unit.Facing); (self.traits.Contains<Turreted>() ? self.traits.Get<Turreted>().turretFacing : unit.Facing);
Game.world.Add(new Missile(weapon, self.Owner, self, self.World.Add(new Missile(weapon, self.Owner, self,
firePos, thisTarget, srcAltitude, fireFacing)); firePos, thisTarget, srcAltitude, fireFacing));
} }
else else
Game.world.Add(new Bullet(weapon, self.Owner, self, self.World.Add(new Bullet(weapon, self.Owner, self,
firePos, thisTarget.CenterLocation.ToInt2(), srcAltitude, destAltitude)); firePos, thisTarget.CenterLocation.ToInt2(), srcAltitude, destAltitude));
if (!string.IsNullOrEmpty(weapon.Report)) if (!string.IsNullOrEmpty(weapon.Report))
@@ -205,8 +205,8 @@ namespace OpenRa.Traits
self.CancelActivity(); self.CancelActivity();
QueueAttack(self, order); QueueAttack(self, order);
if (self.Owner == Game.world.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
Game.world.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor))); self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
} }
else else
target = null; target = null;

View File

@@ -43,7 +43,7 @@ namespace OpenRa.Traits
Actor ChooseTarget(Actor self, float range) Actor ChooseTarget(Actor self, float range)
{ {
var inRange = Game.world.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range); var inRange = self.World.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range);
return inRange return inRange
.Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */ .Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */

View File

@@ -27,7 +27,7 @@ namespace OpenRa.Traits
Actor ChooseTarget(Actor self, float range) Actor ChooseTarget(Actor self, float range)
{ {
var inRange = Game.world.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range); var inRange = self.World.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range);
return inRange return inRange
.Where(a => a.Owner != null && a.Owner != self.Owner) /* todo: one day deal with friendly players */ .Where(a => a.Owner != null && a.Owner != self.Owner) /* todo: one day deal with friendly players */

View File

@@ -97,7 +97,7 @@ namespace OpenRa.Traits
// If the disabled state has changed since the last frame // If the disabled state has changed since the last frame
if (Disabled ^ wasDisabled if (Disabled ^ wasDisabled
&& (wasDisabled = Disabled)) // Yes, I mean assignment && (wasDisabled = Disabled)) // Yes, I mean assignment
Game.world.AddFrameEndTask(w => w.Add(new PowerDownIndicator(self))); self.World.AddFrameEndTask(w => w.Add(new PowerDownIndicator(self)));
if (!isRepairing) return; if (!isRepairing) return;
@@ -113,7 +113,7 @@ namespace OpenRa.Traits
return; return;
} }
Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self))); self.World.AddFrameEndTask(w => w.Add(new RepairIndicator(self)));
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
if (self.Health == maxHP) if (self.Health == maxHP)
{ {

View File

@@ -30,7 +30,7 @@ namespace OpenRa.Traits
if (remainingUncloakTime > 0) if (remainingUncloakTime > 0)
return rs; return rs;
if (self.Owner == Game.world.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
return rs.Select(a => a.WithPalette(PaletteType.Shadow)); return rs.Select(a => a.WithPalette(PaletteType.Shadow));
else else
return new Renderable[] { }; return new Renderable[] { };

View File

@@ -27,7 +27,7 @@ namespace OpenRa.Traits
{ {
// force-move // force-move
if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null; if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null;
if (!Game.world.IsActorCrushableByActor(underCursor, self)) return null; if (!self.World.IsActorCrushableByActor(underCursor, self)) return null;
} }
return new Order("Move", self, null, xy, null); return new Order("Move", self, null, xy, null);
@@ -50,14 +50,14 @@ namespace OpenRa.Traits
public bool CanEnterCell(int2 a) public bool CanEnterCell(int2 a)
{ {
if (!Game.world.BuildingInfluence.CanMoveHere(a)) return false; if (!self.World.BuildingInfluence.CanMoveHere(a)) return false;
var crushable = true; var crushable = true;
foreach (Actor actor in Game.world.UnitInfluence.GetUnitsAt(a)) foreach (Actor actor in self.World.UnitInfluence.GetUnitsAt(a))
{ {
if (actor == self) continue; if (actor == self) continue;
if (!Game.world.IsActorCrushableByActor(actor, self)) if (!self.World.IsActorCrushableByActor(actor, self))
{ {
crushable = false; crushable = false;
break; break;
@@ -66,9 +66,9 @@ namespace OpenRa.Traits
if (!crushable) return false; if (!crushable) return false;
return Game.world.Map.IsInMap(a.X, a.Y) && return self.World.Map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(GetMovementType(), TerrainCosts.Cost(GetMovementType(),
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity; self.World.TileSet.GetWalkability(self.World.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
} }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace OpenRa.Traits
var unit = self.traits.GetOrDefault<Unit>(); var unit = self.traits.GetOrDefault<Unit>();
var altitude = unit != null ? unit.Altitude : 0; var altitude = unit != null ? unit.Altitude : 0;
Game.world.AddFrameEndTask( self.World.AddFrameEndTask(
w => w.Add(new Bullet("UnitExplode", e.Attacker.Owner, e.Attacker, w => w.Add(new Bullet("UnitExplode", e.Attacker.Owner, e.Attacker,
self.CenterLocation.ToInt2(), self.CenterLocation.ToInt2(), self.CenterLocation.ToInt2(), self.CenterLocation.ToInt2(),
altitude, altitude))); altitude, altitude)));

View File

@@ -28,7 +28,7 @@ namespace OpenRa.Traits
// Gap Generator building; powered down // Gap Generator building; powered down
return (self.traits.Contains<Building>() && self.traits.Get<Building>().Disabled) return (self.traits.Contains<Building>() && self.traits.Get<Building>().Disabled)
? new int2[] {} ? new int2[] {}
: Game.world.FindTilesInCircle(self.Location, range); : self.World.FindTilesInCircle(self.Location, range);
} }
} }
} }

View File

@@ -41,7 +41,7 @@ namespace OpenRa.Traits
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty) && underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
return new Order("Deliver", self, underCursor, int2.Zero, null); return new Order("Deliver", self, underCursor, int2.Zero, null);
if (underCursor == null && Game.world.Map.ContainsResource(xy)) if (underCursor == null && self.World.Map.ContainsResource(xy))
return new Order("Harvest", self, null, xy, null); return new Order("Harvest", self, null, xy, null);
return null; return null;

View File

@@ -8,7 +8,7 @@ namespace OpenRa.Traits
{ {
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r) public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{ {
return Game.world.LocalPlayer == self.Owner return self.World.LocalPlayer == self.Owner
? r : new Renderable[] { }; ? r : new Renderable[] { };
} }
} }

View File

@@ -29,7 +29,7 @@ namespace OpenRa.Traits
{ {
var power = self.Owner.SupportPowers[order.TargetString].Impl; var power = self.Owner.SupportPowers[order.TargetString].Impl;
power.OnFireNotification(self, self.Location); power.OnFireNotification(self, self.Location);
Game.world.AddFrameEndTask(w => w.Add(new InvulnEffect(self))); self.World.AddFrameEndTask(w => w.Add(new InvulnEffect(self)));
RemainingTicks = (int)(Rules.General.IronCurtain * 60 * 25); RemainingTicks = (int)(Rules.General.IronCurtain * 60 * 25);
} }
} }

View File

@@ -25,7 +25,7 @@ namespace OpenRa.Traits
if( order.OrderString == "DeployMcv" ) if( order.OrderString == "DeployMcv" )
{ {
var factBuildingInfo = Rules.Info[ "fact" ].Traits.Get<BuildingInfo>(); var factBuildingInfo = Rules.Info[ "fact" ].Traits.Get<BuildingInfo>();
if( Game.world.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self ) ) if( self.World.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self ) )
{ {
self.CancelActivity(); self.CancelActivity();
self.QueueActivity( new Turn( 96 ) ); self.QueueActivity( new Turn( 96 ) );

View File

@@ -21,7 +21,7 @@ namespace OpenRa.Traits
public int2 fromCell public int2 fromCell
{ {
get { return __fromCell; } get { return __fromCell; }
set { Game.world.UnitInfluence.Remove(self, this); __fromCell = value; Game.world.UnitInfluence.Add(self, this); } set { self.World.UnitInfluence.Remove(self, this); __fromCell = value; self.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.world.UnitInfluence.Remove(self, this); self.World.UnitInfluence.Remove(self, this);
self.Location = value; self.Location = value;
self.Owner.Shroud.Explore(self); self.Owner.Shroud.Explore(self);
} }
Game.world.UnitInfluence.Add(self, this); self.World.UnitInfluence.Add(self, this);
} }
} }
@@ -42,7 +42,7 @@ namespace OpenRa.Traits
{ {
this.self = self; this.self = self;
__fromCell = toCell; __fromCell = toCell;
Game.world.UnitInfluence.Add(self, this); self.World.UnitInfluence.Add(self, this);
} }
public void TeleportTo(Actor self, int2 xy) public void TeleportTo(Actor self, int2 xy)
@@ -62,7 +62,7 @@ namespace OpenRa.Traits
{ {
// force-move // force-move
if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null; if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null;
if (!Game.world.IsActorCrushableByActor(underCursor, self)) return null; if (!self.World.IsActorCrushableByActor(underCursor, self)) return null;
} }
if (Util.GetEffectiveSpeed(self) == 0) return null; /* allow disabling move orders from modifiers */ if (Util.GetEffectiveSpeed(self) == 0) return null; /* allow disabling move orders from modifiers */
@@ -93,14 +93,14 @@ namespace OpenRa.Traits
public bool CanEnterCell(int2 a) public bool CanEnterCell(int2 a)
{ {
if (!Game.world.BuildingInfluence.CanMoveHere(a)) return false; if (!self.World.BuildingInfluence.CanMoveHere(a)) return false;
var crushable = true; var crushable = true;
foreach (Actor actor in Game.world.UnitInfluence.GetUnitsAt(a)) foreach (Actor actor in self.World.UnitInfluence.GetUnitsAt(a))
{ {
if (actor == self) continue; if (actor == self) continue;
if (!Game.world.IsActorCrushableByActor(actor, self)) if (!self.World.IsActorCrushableByActor(actor, self))
{ {
crushable = false; crushable = false;
break; break;
@@ -109,9 +109,9 @@ namespace OpenRa.Traits
if (!crushable) return false; if (!crushable) return false;
return Game.world.Map.IsInMap(a.X, a.Y) && return self.World.Map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(GetMovementType(), TerrainCosts.Cost(GetMovementType(),
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity; self.World.TileSet.GetWalkability(self.World.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
} }
public IEnumerable<int2> GetCurrentPath() public IEnumerable<int2> GetCurrentPath()

View File

@@ -14,7 +14,7 @@ namespace OpenRa.Traits
{ {
if( order.OrderString == "PlaceBuilding" ) if( order.OrderString == "PlaceBuilding" )
{ {
Game.world.AddFrameEndTask( _ => self.World.AddFrameEndTask( _ =>
{ {
var queue = self.traits.Get<ProductionQueue>(); var queue = self.traits.Get<ProductionQueue>();
var unit = Rules.Info[ order.TargetString ]; var unit = Rules.Info[ order.TargetString ];
@@ -22,8 +22,8 @@ namespace OpenRa.Traits
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 ) if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
return; return;
Game.world.CreateActor( order.TargetString, order.TargetLocation, order.Player ); self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player );
if (order.Player == Game.world.LocalPlayer) if (order.Player == self.World.LocalPlayer)
{ {
Sound.Play("placbldg.aud"); Sound.Play("placbldg.aud");
Sound.Play("build5.aud"); Sound.Play("build5.aud");

View File

@@ -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.world.UnitInfluence.GetUnitsAt( location.Value ).Any() ) if( location == null || self.World.UnitInfluence.GetUnitsAt( location.Value ).Any() )
return false; return false;
var newUnit = Game.world.CreateActor( producee.Name, location.Value, self.Owner ); var newUnit = self.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>();
@@ -86,7 +86,7 @@ namespace OpenRa.Traits
// Cancel existing primaries // Cancel existing primaries
foreach (var p in self.Info.Traits.Get<ProductionInfo>().Produces) foreach (var p in self.Info.Traits.Get<ProductionInfo>().Produces)
{ {
foreach (var b in Game.world.Actors.Where(x => x.traits.Contains<Production>() foreach (var b in self.World.Actors.Where(x => x.traits.Contains<Production>()
&& x.Owner == self.Owner && x.Owner == self.Owner
&& x.traits.Get<Production>().IsPrimary == true && x.traits.Get<Production>().IsPrimary == true
&& (x.Info.Traits.Get<ProductionInfo>().Produces.Contains(p)))) && (x.Info.Traits.Get<ProductionInfo>().Produces.Contains(p))))

View File

@@ -49,11 +49,11 @@ namespace OpenRa.Traits
BeginProduction( unit.Category, BeginProduction( unit.Category,
new ProductionItem( order.TargetString, (int)time, ui.Cost, new ProductionItem( order.TargetString, (int)time, ui.Cost,
() => Game.world.AddFrameEndTask( () => self.World.AddFrameEndTask(
_ => _ =>
{ {
var isBuilding = unit.Traits.Contains<BuildingInfo>(); var isBuilding = unit.Traits.Contains<BuildingInfo>();
if( !hasPlayedSound && order.Player == Game.world.LocalPlayer ) if( !hasPlayedSound && order.Player == self.World.LocalPlayer )
{ {
Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" ); Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" );
hasPlayedSound = true; hasPlayedSound = true;
@@ -131,7 +131,7 @@ namespace OpenRa.Traits
Actor producer = null; Actor producer = null;
// Prioritise primary structure in build order // Prioritise primary structure in build order
var primaryProducers = Game.world.Actors var primaryProducers = self.World.Actors
.Where(x => x.traits.Contains<Production>() .Where(x => x.traits.Contains<Production>()
&& producerTypes.Contains(x.Info) && producerTypes.Contains(x.Info)
&& x.Owner == self.Owner && x.Owner == self.Owner
@@ -152,7 +152,7 @@ namespace OpenRa.Traits
// Pick the first available producer // Pick the first available producer
if (producer == null) if (producer == null)
{ {
producer = Game.world.Actors producer = self.World.Actors
.Where( x => producerTypes.Contains( x.Info ) && x.Owner == self.Owner ) .Where( x => producerTypes.Contains( x.Info ) && x.Owner == self.Owner )
.FirstOrDefault(); .FirstOrDefault();
} }

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Traits
for (var j = min.Y; j <= max.Y; j++) for (var j = min.Y; j <= max.Y; j++)
for (var i = min.X; i <= max.X; i++) for (var i = min.X; i <= max.X; i++)
if (Game.world.IsCellBuildable(new int2(i, j), umt)) if (self.World.IsCellBuildable(new int2(i, j), umt))
return new int2(i, j); return new int2(i, j);
return null; return null;

View File

@@ -28,7 +28,7 @@ namespace OpenRa.Traits
public IEnumerable<Renderable> Render(Actor self) public IEnumerable<Renderable> Render(Actor self)
{ {
var uog = Game.controller.orderGenerator as UnitOrderGenerator; var uog = Game.controller.orderGenerator as UnitOrderGenerator;
if (uog != null && self.Owner == Game.world.LocalPlayer && uog.selection.Contains(self)) if (uog != null && self.Owner == self.World.LocalPlayer && uog.selection.Contains(self))
yield return Util.Centered(self, yield return Util.Centered(self,
anim.Image, Util.CenterOfCell(rallyPoint)); anim.Image, Util.CenterOfCell(rallyPoint));
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRa.Traits
if( Game.skipMakeAnims ) if( Game.skipMakeAnims )
Complete( self ); Complete( self );
else else
anim.PlayThen( "make", () => Game.world.AddFrameEndTask( _ => Complete( self ) ) ); anim.PlayThen( "make", () => self.World.AddFrameEndTask( _ => Complete( self ) ) );
DoBib(self, false); DoBib(self, false);
} }
@@ -45,11 +45,11 @@ namespace OpenRa.Traits
var p = self.Location + new int2(i % size, i / size + bibOffset); var p = self.Location + new int2(i % size, i / size + bibOffset);
if (isRemove) if (isRemove)
{ {
if (Game.world.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex)) if (self.World.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex))
Game.world.Map.MapTiles[ p.X, p.Y ].smudge = 0; self.World.Map.MapTiles[ p.X, p.Y ].smudge = 0;
} }
else else
Game.world.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex); self.World.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex);
} }
} }
} }
@@ -87,7 +87,7 @@ namespace OpenRa.Traits
break; break;
case DamageState.Dead: case DamageState.Dead:
DoBib(self, true); DoBib(self, true);
Game.world.AddFrameEndTask(w => w.Add(new Explosion(self.CenterLocation.ToInt2(), 7, false))); self.World.AddFrameEndTask(w => w.Add(new Explosion(self.CenterLocation.ToInt2(), 7, false)));
break; break;
} }
} }

View File

@@ -34,7 +34,7 @@ namespace OpenRa.Traits
public void Tick(Actor self) public void Tick(Actor self)
{ {
var b = self.GetBounds(false); var b = self.GetBounds(false);
if (isOpen && !Game.world.UnitInfluence.GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any()) if (isOpen && !self.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"));

View File

@@ -77,7 +77,7 @@ namespace OpenRa.Traits
if (e.DamageState == DamageState.Dead) if (e.DamageState == DamageState.Dead)
{ {
Sound.PlayVoice("Die", self); Sound.PlayVoice("Die", self);
Game.world.AddFrameEndTask(w => w.Add(new Corpse(self, e.Warhead.InfDeath))); self.World.AddFrameEndTask(w => w.Add(new Corpse(self, e.Warhead.InfDeath)));
} }
} }
} }

View File

@@ -22,8 +22,8 @@ namespace OpenRa.Traits
for (var j = -1; j < 2; j++) for (var j = -1; j < 2; j++)
for (var i = -1; i < 2; i++) for (var i = -1; i < 2; i++)
if (Game.SharedRandom.NextDouble() < info.Chance) if (Game.SharedRandom.NextDouble() < info.Chance)
if (Game.world.OreCanSpreadInto(self.Location.X + i, self.Location.Y + j)) if (self.World.OreCanSpreadInto(self.Location.X + i, self.Location.Y + j))
Game.world.Map.AddOre(self.Location.X + i, self.Location.Y + j); self.World.Map.AddOre(self.Location.X + i, self.Location.Y + j);
ticks = info.Interval; ticks = info.Interval;
} }

View File

@@ -30,7 +30,7 @@ namespace OpenRa.Traits
public bool IsCrushableBy(UnitMovementType umt, Player player) public bool IsCrushableBy(UnitMovementType umt, Player player)
{ {
if (player == Game.world.LocalPlayer) return false; if (player == self.World.LocalPlayer) return false;
switch (umt) switch (umt)
{ {
case UnitMovementType.Track: return true; case UnitMovementType.Track: return true;

View File

@@ -18,7 +18,7 @@ namespace OpenRa.Traits
self.Owner.TakeCash(toSteal); self.Owner.TakeCash(toSteal);
thief.Owner.GiveCash(toSteal); thief.Owner.GiveCash(toSteal);
if (Game.world.LocalPlayer == thief.Owner) if (self.World.LocalPlayer == thief.Owner)
Sound.Play("credit1.aud"); Sound.Play("credit1.aud");
} }
@@ -27,7 +27,7 @@ namespace OpenRa.Traits
var numPips = self.Info.Traits.Get<StoresOreInfo>().Pips; var numPips = self.Info.Traits.Get<StoresOreInfo>().Pips;
return Graphics.Util.MakeArray( numPips, return Graphics.Util.MakeArray( numPips,
i => (Game.world.LocalPlayer.GetSiloFullness() > i * 1.0f / numPips) i => (self.World.LocalPlayer.GetSiloFullness() > i * 1.0f / numPips)
? PipType.Yellow : PipType.Transparent ); ? PipType.Yellow : PipType.Transparent );
} }
} }

View File

@@ -33,7 +33,7 @@ namespace OpenRa.Traits
if (remainingSurfaceTime > 0) if (remainingSurfaceTime > 0)
return rs; return rs;
if (self.Owner == Game.world.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
return rs.Select(a => a.WithPalette(PaletteType.Shadow)); return rs.Select(a => a.WithPalette(PaletteType.Shadow));
else else
return new Renderable[] { }; return new Renderable[] { };

View File

@@ -23,7 +23,7 @@ namespace OpenRa.Traits
public void Damaged(Actor self, AttackInfo e) public void Damaged(Actor self, AttackInfo e)
{ {
if (e.DamageState == DamageState.Dead) if (e.DamageState == DamageState.Dead)
if (self.Owner == Game.world.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
Sound.Play(self.Info.Traits.Get<OwnedActorInfo>().WaterBound Sound.Play(self.Info.Traits.Get<OwnedActorInfo>().WaterBound
? "navylst1.aud" : "unitlst1.aud"); ? "navylst1.aud" : "unitlst1.aud");
} }

View File

@@ -55,7 +55,7 @@ namespace OpenRa.Mods.Aftermath
Sound.Play("chrotnk1.aud"); Sound.Play("chrotnk1.aud");
chargeTick = chargeLength; chargeTick = chargeLength;
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<ChronoshiftPaletteEffect>())) foreach (var a in self.World.Actors.Where(a => a.traits.Contains<ChronoshiftPaletteEffect>()))
a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift(); a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift();
} }
} }

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Mods.Aftermath
{ {
// Override chronoshifting action to detonate vehicle // Override chronoshifting action to detonate vehicle
var movement = self.traits.GetOrDefault<IMovement>(); var movement = self.traits.GetOrDefault<IMovement>();
var chronosphere = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains<Chronosphere>()).FirstOrDefault(); var chronosphere = self.World.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains<Chronosphere>()).FirstOrDefault();
if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation)) if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation))
{ {
self.InflictDamage(chronosphere, self.Health, Rules.WarheadInfo["Super"]); self.InflictDamage(chronosphere, self.Health, Rules.WarheadInfo["Super"]);
@@ -44,7 +44,7 @@ namespace OpenRa.Mods.Aftermath
var altitude = unit != null ? unit.Altitude : 0; var altitude = unit != null ? unit.Altitude : 0;
int2 detonateLocation = self.CenterLocation.ToInt2(); int2 detonateLocation = self.CenterLocation.ToInt2();
Game.world.AddFrameEndTask( self.World.AddFrameEndTask(
w => w.Add(new Bullet(self.Info.Traits.Get<AttackBaseInfo>().PrimaryWeapon, detonatedBy.Owner, detonatedBy, w => w.Add(new Bullet(self.Info.Traits.Get<AttackBaseInfo>().PrimaryWeapon, detonatedBy.Owner, detonatedBy,
detonateLocation, detonateLocation, altitude, altitude))); detonateLocation, detonateLocation, altitude, altitude)));
} }

View File

@@ -37,7 +37,7 @@ namespace OpenRa.Mods.RA.Activities
} }
// the engineer is sacrificed. // the engineer is sacrificed.
Game.world.AddFrameEndTask(w => w.Remove(self)); self.World.AddFrameEndTask(w => w.Remove(self));
return NextActivity; return NextActivity;
} }

View File

@@ -16,7 +16,7 @@ namespace OpenRa.Mods.RA.Activities
public IActivity Tick(Actor self) public IActivity Tick(Actor self)
{ {
if (target == null || target.IsDead) return NextActivity; if (target == null || target.IsDead) return NextActivity;
Game.world.AddFrameEndTask(w => w.Add(new DelayedAction(25*2, self.World.AddFrameEndTask(w => w.Add(new DelayedAction(25*2,
() => target.InflictDamage(self, target.Health, Rules.WarheadInfo["DemolishWarhead"])))); () => target.InflictDamage(self, target.Health, Rules.WarheadInfo["DemolishWarhead"]))));
return NextActivity; return NextActivity;
} }

View File

@@ -17,7 +17,7 @@ namespace OpenRa.Mods.RA.Activities
foreach (var t in target.traits.WithInterface<IAcceptSpy>()) foreach (var t in target.traits.WithInterface<IAcceptSpy>())
t.OnInfiltrate(target, self); t.OnInfiltrate(target, self);
Game.world.AddFrameEndTask(w => w.Remove(self)); self.World.AddFrameEndTask(w => w.Remove(self));
return NextActivity; return NextActivity;
} }

View File

@@ -23,7 +23,7 @@ namespace OpenRa.Mods.RA.Activities
foreach (var t in target.traits.WithInterface<IAcceptThief>()) foreach (var t in target.traits.WithInterface<IAcceptThief>())
t.OnSteal(target, self); t.OnSteal(target, self);
Game.world.AddFrameEndTask(w => w.Remove(self)); self.World.AddFrameEndTask(w => w.Remove(self));
return NextActivity; return NextActivity;
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRa.Mods.RA
public Mine(Actor self) public Mine(Actor self)
{ {
this.self = self; this.self = self;
Game.world.UnitInfluence.Add(self, this); self.World.UnitInfluence.Add(self, this);
} }
public void OnCrush(Actor crusher) public void OnCrush(Actor crusher)
@@ -32,17 +32,17 @@ namespace OpenRa.Mods.RA
var info = self.Info.Traits.Get<MineInfo>(); var info = self.Info.Traits.Get<MineInfo>();
var warhead = Rules.WarheadInfo[info.Warhead]; var warhead = Rules.WarheadInfo[info.Warhead];
Game.world.AddFrameEndTask(_ => self.World.AddFrameEndTask(_ =>
{ {
Game.world.Remove(self); self.World.Remove(self);
Game.world.Add(new Explosion(self.CenterLocation.ToInt2(), warhead.Explosion, false)); self.World.Add(new Explosion(self.CenterLocation.ToInt2(), warhead.Explosion, false));
crusher.InflictDamage(crusher, info.Damage, warhead); crusher.InflictDamage(crusher, info.Damage, warhead);
}); });
} }
public bool IsPathableCrush(UnitMovementType umt, Player player) public bool IsPathableCrush(UnitMovementType umt, Player player)
{ {
return !self.Info.Traits.Get<MineInfo>().AvoidFriendly || (player != Game.world.LocalPlayer); return !self.Info.Traits.Get<MineInfo>().AvoidFriendly || (player != self.World.LocalPlayer);
} }
public bool IsCrushableBy(UnitMovementType umt, Player player) public bool IsCrushableBy(UnitMovementType umt, Player player)

View File

@@ -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.world.UnitInfluence.GetUnitsAt(xy).Any(a => a != self)) if (self.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)
@@ -36,7 +36,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( self.World.AddFrameEndTask(
w => w.CreateActor(self.Info.Traits.Get<MinelayerInfo>().Mine, self.Location, self.Owner)); w => w.CreateActor(self.Info.Traits.Get<MinelayerInfo>().Mine, self.Location, self.Owner));
} }
} }

View File

@@ -21,15 +21,15 @@ namespace OpenRa.Mods.RA
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r) public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{ {
if (self.Owner == Game.world.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
return r; return r;
return r.Select(a => a.WithPalette(Game.world.LocalPlayer.Palette)); return r.Select(a => a.WithPalette(self.World.LocalPlayer.Palette));
} }
public override void Tick(Actor self) public override void Tick(Actor self)
{ {
anim.ChangeImage(self.Owner == Game.world.LocalPlayer ? GetImage(self) : "e1"); anim.ChangeImage(self.Owner == self.World.LocalPlayer ? GetImage(self) : "e1");
base.Tick(self); base.Tick(self);
} }
} }