diff --git a/OpenRa.Game/Traits/AcceptsOre.cs b/OpenRa.Game/Traits/AcceptsOre.cs index 9b77613595..18145caa21 100644 --- a/OpenRa.Game/Traits/AcceptsOre.cs +++ b/OpenRa.Game/Traits/AcceptsOre.cs @@ -11,7 +11,7 @@ namespace OpenRa.Traits { public AcceptsOre(Actor self) { - Game.world.AddFrameEndTask( + self.World.AddFrameEndTask( w => { /* create the free harvester! */ var harvester = w.CreateActor("harv", self.Location + new int2(1, 2), self.Owner); diff --git a/OpenRa.Game/Traits/Activities/DeliverOre.cs b/OpenRa.Game/Traits/Activities/DeliverOre.cs index 93b7d4b1f0..fe20499cd9 100644 --- a/OpenRa.Game/Traits/Activities/DeliverOre.cs +++ b/OpenRa.Game/Traits/Activities/DeliverOre.cs @@ -42,7 +42,7 @@ namespace OpenRa.Traits.Activities umt = mobile.GetMovementType(), checkForBlocked = false, }; - var refineries = Game.world.Actors.Where( x => x.traits.Contains() + var refineries = self.World.Actors.Where( x => x.traits.Contains() && x.Owner == self.Owner ).ToList(); if( refinery != null ) search.AddInitialCell( refinery.Location + refineryDeliverOffset ); @@ -50,7 +50,7 @@ namespace OpenRa.Traits.Activities foreach( var r in refineries ) search.AddInitialCell( r.Location + refineryDeliverOffset ); - var path = Game.world.PathFinder.FindPath( search ); + var path = self.World.PathFinder.FindPath( search ); path.Reverse(); if( path.Count != 0 ) { diff --git a/OpenRa.Game/Traits/Activities/DeployMcv.cs b/OpenRa.Game/Traits/Activities/DeployMcv.cs index be7bd22ee5..f3bf4c9fc7 100755 --- a/OpenRa.Game/Traits/Activities/DeployMcv.cs +++ b/OpenRa.Game/Traits/Activities/DeployMcv.cs @@ -8,16 +8,16 @@ namespace OpenRa.Traits.Activities public IActivity Tick( Actor self ) { - Game.world.AddFrameEndTask( _ => + self.World.AddFrameEndTask( _ => { self.Health = 0; - Game.world.Remove( self ); - if (self.Owner == Game.world.LocalPlayer) + self.World.Remove( self ); + if (self.Owner == self.World.LocalPlayer) { Sound.Play("placbldg.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; } diff --git a/OpenRa.Game/Traits/Activities/EnterTransport.cs b/OpenRa.Game/Traits/Activities/EnterTransport.cs index d320b04929..5acfe04a1d 100644 --- a/OpenRa.Game/Traits/Activities/EnterTransport.cs +++ b/OpenRa.Game/Traits/Activities/EnterTransport.cs @@ -26,7 +26,7 @@ namespace OpenRa.Traits.Activities return NextActivity; cargo.Load(transport, self); - Game.world.AddFrameEndTask(w => w.Remove(self)); + self.World.AddFrameEndTask(w => w.Remove(self)); return this; } diff --git a/OpenRa.Game/Traits/Activities/Harvest.cs b/OpenRa.Game/Traits/Activities/Harvest.cs index 3e2c8516e2..9ac0d84089 100644 --- a/OpenRa.Game/Traits/Activities/Harvest.cs +++ b/OpenRa.Game/Traits/Activities/Harvest.cs @@ -36,8 +36,8 @@ namespace OpenRa.Traits.Activities var renderUnit = self.traits.Get(); /* better have one of these! */ var isGem = false; - if (!Game.world.Map.ContainsResource(self.Location) || - !Game.world.Map.Harvest(self.Location, out isGem)) + if (!self.World.Map.ContainsResource(self.Location) || + !self.World.Map.Harvest(self.Location, out isGem)) return false; var harvestAnim = "harvest" + Util.QuantizeFacing(unit.Facing, 8); @@ -58,12 +58,12 @@ namespace OpenRa.Traits.Activities { 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, checkForBlocked = true }; search.AddInitialCell(self.Location); - return Game.world.PathFinder.FindPath(search); + return self.World.PathFinder.FindPath(search); })); self.QueueActivity(new Harvest()); } diff --git a/OpenRa.Game/Traits/Activities/HeliLand.cs b/OpenRa.Game/Traits/Activities/HeliLand.cs index 4d1600962b..c9d7e983f2 100644 --- a/OpenRa.Game/Traits/Activities/HeliLand.cs +++ b/OpenRa.Game/Traits/Activities/HeliLand.cs @@ -16,7 +16,7 @@ namespace OpenRa.Traits.Activities if (unit.Altitude == 0) 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 --unit.Altitude; diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index e5fbc74a25..6646d5e83c 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -9,7 +9,7 @@ namespace OpenRa.Traits.Activities static Actor ChooseHelipad(Actor self) { - return Game.world.Actors.FirstOrDefault( + return self.World.Actors.FirstOrDefault( a => a.Info.Name == "hpad" && a.Owner == self.Owner && !Reservable.IsReserved(a)); diff --git a/OpenRa.Game/Traits/Activities/Move.cs b/OpenRa.Game/Traits/Activities/Move.cs index c39abdeb6c..c016f87264 100755 --- a/OpenRa.Game/Traits/Activities/Move.cs +++ b/OpenRa.Game/Traits/Activities/Move.cs @@ -20,7 +20,7 @@ namespace OpenRa.Traits.Activities 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, mobile.GetMovementType() ); this.destination = destination; @@ -30,9 +30,9 @@ namespace OpenRa.Traits.Activities public Move(int2 destination, Actor ignoreBuilding) { this.getPath = (self, mobile) => - Game.world.PathFinder.FindPath( + self.World.PathFinder.FindPath( 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.nearEnough = 0; @@ -41,7 +41,7 @@ namespace OpenRa.Traits.Activities 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, mobile.GetMovementType(), range ); this.destination = null; @@ -57,13 +57,13 @@ namespace OpenRa.Traits.Activities bool CanEnterCell( int2 c, Actor self ) { - if (!Game.world.BuildingInfluence.CanMoveHere(c) - && Game.world.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding) + if (!self.World.BuildingInfluence.CanMoveHere(c) + && self.World.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding) return false; // Cannot enter a cell if any unit inside is uncrushable // 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 ) @@ -144,10 +144,10 @@ namespace OpenRa.Traits.Activities 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(); - Game.world.UnitInfluence.Add( self, mobile ); + self.World.UnitInfluence.Add( self, mobile ); if (newPath.Count != 0) path = newPath; diff --git a/OpenRa.Game/Traits/Activities/Rearm.cs b/OpenRa.Game/Traits/Activities/Rearm.cs index 479f55d449..e8c7df209d 100644 --- a/OpenRa.Game/Traits/Activities/Rearm.cs +++ b/OpenRa.Game/Traits/Activities/Rearm.cs @@ -20,7 +20,7 @@ namespace OpenRa.Traits.Activities { 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()); if (hostBuilding != null) diff --git a/OpenRa.Game/Traits/Activities/Repair.cs b/OpenRa.Game/Traits/Activities/Repair.cs index 49254828df..6d5445257a 100644 --- a/OpenRa.Game/Traits/Activities/Repair.cs +++ b/OpenRa.Game/Traits/Activities/Repair.cs @@ -35,7 +35,7 @@ namespace OpenRa.Traits.Activities if (self.Health == hp) 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()); if (hostBuilding != null) diff --git a/OpenRa.Game/Traits/Activities/ReturnToBase.cs b/OpenRa.Game/Traits/Activities/ReturnToBase.cs index b366fbc3e8..3374fe7128 100644 --- a/OpenRa.Game/Traits/Activities/ReturnToBase.cs +++ b/OpenRa.Game/Traits/Activities/ReturnToBase.cs @@ -18,7 +18,7 @@ namespace OpenRa.Traits.Activities Actor ChooseAirfield(Actor self) { - var airfield = Game.world.Actors + var airfield = self.World.Actors .Where(a => a.Info.Name == "afld" && a.Owner == self.Owner && !Reservable.IsReserved(a)) diff --git a/OpenRa.Game/Traits/Activities/Sell.cs b/OpenRa.Game/Traits/Activities/Sell.cs index 917678ed36..e5189bac57 100644 --- a/OpenRa.Game/Traits/Activities/Sell.cs +++ b/OpenRa.Game/Traits/Activities/Sell.cs @@ -23,7 +23,7 @@ namespace OpenRa.Traits.Activities self.Health = 0; foreach (var ns in self.traits.WithInterface()) ns.Sold(self); - Game.world.AddFrameEndTask( _ => Game.world.Remove( self ) ); + self.World.AddFrameEndTask( _ => self.World.Remove( self ) ); // todo: give dudes } diff --git a/OpenRa.Game/Traits/Activities/UndeployMcv.cs b/OpenRa.Game/Traits/Activities/UndeployMcv.cs index 54f295d59d..4f5f23c6c9 100644 --- a/OpenRa.Game/Traits/Activities/UndeployMcv.cs +++ b/OpenRa.Game/Traits/Activities/UndeployMcv.cs @@ -24,7 +24,7 @@ namespace OpenRa.Traits.Activities { var rb = self.traits.Get(); rb.PlayCustomAnimBackwards(self, "make", - () => Game.world.AddFrameEndTask(w => DoUndeploy(w,self))); + () => self.World.AddFrameEndTask(w => DoUndeploy(w,self))); Sound.Play("cashturn.aud"); started = true; diff --git a/OpenRa.Game/Traits/Activities/UnloadCargo.cs b/OpenRa.Game/Traits/Activities/UnloadCargo.cs index 06c59333ca..2d4ac9f803 100644 --- a/OpenRa.Game/Traits/Activities/UnloadCargo.cs +++ b/OpenRa.Game/Traits/Activities/UnloadCargo.cs @@ -13,13 +13,13 @@ namespace OpenRa.Traits.Activities int2? ChooseExitTile(Actor self) { // 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; for (var i = -1; i < 2; i++) for (var j = -1; j < 2; j++) 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)) return self.Location + new int2(i, j); @@ -54,7 +54,7 @@ namespace OpenRa.Traits.Activities var actor = cargo.Unload(self); - Game.world.AddFrameEndTask(w => + self.World.AddFrameEndTask(w => { w.Add(actor); actor.traits.Get().TeleportTo(actor, self.Location); diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 58d95cdbce..af9dcfb010 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -150,18 +150,18 @@ namespace OpenRa.Traits var destAltitude = destUnit != null ? destUnit.Altitude : 0; 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) { var fireFacing = thisLocalOffset.ElementAtOrDefault(2) + (self.traits.Contains() ? self.traits.Get().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)); } 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)); if (!string.IsNullOrEmpty(weapon.Report)) @@ -205,8 +205,8 @@ namespace OpenRa.Traits self.CancelActivity(); QueueAttack(self, order); - if (self.Owner == Game.world.LocalPlayer) - Game.world.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor))); + if (self.Owner == self.World.LocalPlayer) + self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor))); } else target = null; diff --git a/OpenRa.Game/Traits/AutoHeal.cs b/OpenRa.Game/Traits/AutoHeal.cs index ebaa115fac..f81564e3b9 100644 --- a/OpenRa.Game/Traits/AutoHeal.cs +++ b/OpenRa.Game/Traits/AutoHeal.cs @@ -43,7 +43,7 @@ namespace OpenRa.Traits 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 .Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */ diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 7044fb240c..cef1214bc9 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -27,7 +27,7 @@ namespace OpenRa.Traits 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 .Where(a => a.Owner != null && a.Owner != self.Owner) /* todo: one day deal with friendly players */ diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 2c61fa4d68..7aa7582137 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -97,7 +97,7 @@ namespace OpenRa.Traits // If the disabled state has changed since the last frame if (Disabled ^ wasDisabled && (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; @@ -113,7 +113,7 @@ namespace OpenRa.Traits 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"]); if (self.Health == maxHP) { diff --git a/OpenRa.Game/Traits/Cloak.cs b/OpenRa.Game/Traits/Cloak.cs index 7af40d6f5b..6bd0b9fe1f 100644 --- a/OpenRa.Game/Traits/Cloak.cs +++ b/OpenRa.Game/Traits/Cloak.cs @@ -30,7 +30,7 @@ namespace OpenRa.Traits if (remainingUncloakTime > 0) return rs; - if (self.Owner == Game.world.LocalPlayer) + if (self.Owner == self.World.LocalPlayer) return rs.Select(a => a.WithPalette(PaletteType.Shadow)); else return new Renderable[] { }; diff --git a/OpenRa.Game/Traits/ConstructionYard.cs b/OpenRa.Game/Traits/ConstructionYard.cs index c4b1e915eb..36486265d7 100644 --- a/OpenRa.Game/Traits/ConstructionYard.cs +++ b/OpenRa.Game/Traits/ConstructionYard.cs @@ -27,7 +27,7 @@ namespace OpenRa.Traits { // force-move 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); @@ -50,14 +50,14 @@ namespace OpenRa.Traits public bool CanEnterCell(int2 a) { - if (!Game.world.BuildingInfluence.CanMoveHere(a)) return false; + if (!self.World.BuildingInfluence.CanMoveHere(a)) return false; 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 (!Game.world.IsActorCrushableByActor(actor, self)) + if (!self.World.IsActorCrushableByActor(actor, self)) { crushable = false; break; @@ -66,9 +66,9 @@ namespace OpenRa.Traits 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(), - 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; } } } diff --git a/OpenRa.Game/Traits/Explodes.cs b/OpenRa.Game/Traits/Explodes.cs index 3cfc307bdf..4becd48968 100644 --- a/OpenRa.Game/Traits/Explodes.cs +++ b/OpenRa.Game/Traits/Explodes.cs @@ -13,7 +13,7 @@ namespace OpenRa.Traits var unit = self.traits.GetOrDefault(); var altitude = unit != null ? unit.Altitude : 0; - Game.world.AddFrameEndTask( + self.World.AddFrameEndTask( w => w.Add(new Bullet("UnitExplode", e.Attacker.Owner, e.Attacker, self.CenterLocation.ToInt2(), self.CenterLocation.ToInt2(), altitude, altitude))); diff --git a/OpenRa.Game/Traits/GeneratesGap.cs b/OpenRa.Game/Traits/GeneratesGap.cs index 3ed67c8322..e07ad73b69 100644 --- a/OpenRa.Game/Traits/GeneratesGap.cs +++ b/OpenRa.Game/Traits/GeneratesGap.cs @@ -28,7 +28,7 @@ namespace OpenRa.Traits // Gap Generator building; powered down return (self.traits.Contains() && self.traits.Get().Disabled) ? new int2[] {} - : Game.world.FindTilesInCircle(self.Location, range); + : self.World.FindTilesInCircle(self.Location, range); } } } diff --git a/OpenRa.Game/Traits/Harvester.cs b/OpenRa.Game/Traits/Harvester.cs index 904defe75c..a6e6acbfb8 100644 --- a/OpenRa.Game/Traits/Harvester.cs +++ b/OpenRa.Game/Traits/Harvester.cs @@ -41,7 +41,7 @@ namespace OpenRa.Traits && underCursor.traits.Contains() && !IsEmpty) 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 null; diff --git a/OpenRa.Game/Traits/InvisibleToOthers.cs b/OpenRa.Game/Traits/InvisibleToOthers.cs index c42e12b3de..bfec6d643f 100644 --- a/OpenRa.Game/Traits/InvisibleToOthers.cs +++ b/OpenRa.Game/Traits/InvisibleToOthers.cs @@ -8,7 +8,7 @@ namespace OpenRa.Traits { public IEnumerable ModifyRender(Actor self, IEnumerable r) { - return Game.world.LocalPlayer == self.Owner + return self.World.LocalPlayer == self.Owner ? r : new Renderable[] { }; } } diff --git a/OpenRa.Game/Traits/IronCurtainable.cs b/OpenRa.Game/Traits/IronCurtainable.cs index 3645556022..4d761fc2a7 100644 --- a/OpenRa.Game/Traits/IronCurtainable.cs +++ b/OpenRa.Game/Traits/IronCurtainable.cs @@ -29,7 +29,7 @@ namespace OpenRa.Traits { var power = self.Owner.SupportPowers[order.TargetString].Impl; 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); } } diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index 9876423e14..72c75ab5a5 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -25,7 +25,7 @@ namespace OpenRa.Traits if( order.OrderString == "DeployMcv" ) { var factBuildingInfo = Rules.Info[ "fact" ].Traits.Get(); - 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.QueueActivity( new Turn( 96 ) ); diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index d0ad28b242..0ccdda4176 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -21,7 +21,7 @@ namespace OpenRa.Traits public int2 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 { @@ -30,11 +30,11 @@ namespace OpenRa.Traits { if (self.Location != value) { - Game.world.UnitInfluence.Remove(self, this); + self.World.UnitInfluence.Remove(self, this); self.Location = value; 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; __fromCell = toCell; - Game.world.UnitInfluence.Add(self, this); + self.World.UnitInfluence.Add(self, this); } public void TeleportTo(Actor self, int2 xy) @@ -62,7 +62,7 @@ namespace OpenRa.Traits { // force-move 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 */ @@ -93,14 +93,14 @@ namespace OpenRa.Traits public bool CanEnterCell(int2 a) { - if (!Game.world.BuildingInfluence.CanMoveHere(a)) return false; + if (!self.World.BuildingInfluence.CanMoveHere(a)) return false; 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 (!Game.world.IsActorCrushableByActor(actor, self)) + if (!self.World.IsActorCrushableByActor(actor, self)) { crushable = false; break; @@ -109,9 +109,9 @@ namespace OpenRa.Traits 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(), - 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 GetCurrentPath() diff --git a/OpenRa.Game/Traits/PlaceBuilding.cs b/OpenRa.Game/Traits/PlaceBuilding.cs index 64ff2ccac6..bd28b1ff04 100755 --- a/OpenRa.Game/Traits/PlaceBuilding.cs +++ b/OpenRa.Game/Traits/PlaceBuilding.cs @@ -14,7 +14,7 @@ namespace OpenRa.Traits { if( order.OrderString == "PlaceBuilding" ) { - Game.world.AddFrameEndTask( _ => + self.World.AddFrameEndTask( _ => { var queue = self.traits.Get(); var unit = Rules.Info[ order.TargetString ]; @@ -22,8 +22,8 @@ namespace OpenRa.Traits if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 ) return; - Game.world.CreateActor( order.TargetString, order.TargetLocation, order.Player ); - if (order.Player == Game.world.LocalPlayer) + self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player ); + if (order.Player == self.World.LocalPlayer) { Sound.Play("placbldg.aud"); Sound.Play("build5.aud"); diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 5562c043e5..a15ebdb240 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -32,10 +32,10 @@ namespace OpenRa.Traits public bool Produce( Actor self, ActorInfo 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; - 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().Facing = CreationFacing( self, newUnit ); ; var rp = self.traits.GetOrDefault(); @@ -86,7 +86,7 @@ namespace OpenRa.Traits // Cancel existing primaries foreach (var p in self.Info.Traits.Get().Produces) { - foreach (var b in Game.world.Actors.Where(x => x.traits.Contains() + foreach (var b in self.World.Actors.Where(x => x.traits.Contains() && x.Owner == self.Owner && x.traits.Get().IsPrimary == true && (x.Info.Traits.Get().Produces.Contains(p)))) diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index 01585f6a2d..7f698f3ce7 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -49,11 +49,11 @@ namespace OpenRa.Traits BeginProduction( unit.Category, new ProductionItem( order.TargetString, (int)time, ui.Cost, - () => Game.world.AddFrameEndTask( + () => self.World.AddFrameEndTask( _ => { var isBuilding = unit.Traits.Contains(); - if( !hasPlayedSound && order.Player == Game.world.LocalPlayer ) + if( !hasPlayedSound && order.Player == self.World.LocalPlayer ) { Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" ); hasPlayedSound = true; @@ -131,7 +131,7 @@ namespace OpenRa.Traits Actor producer = null; // Prioritise primary structure in build order - var primaryProducers = Game.world.Actors + var primaryProducers = self.World.Actors .Where(x => x.traits.Contains() && producerTypes.Contains(x.Info) && x.Owner == self.Owner @@ -152,7 +152,7 @@ namespace OpenRa.Traits // Pick the first available producer if (producer == null) { - producer = Game.world.Actors + producer = self.World.Actors .Where( x => producerTypes.Contains( x.Info ) && x.Owner == self.Owner ) .FirstOrDefault(); } diff --git a/OpenRa.Game/Traits/ProductionSurround.cs b/OpenRa.Game/Traits/ProductionSurround.cs index 6944e986f4..00f06e2426 100644 --- a/OpenRa.Game/Traits/ProductionSurround.cs +++ b/OpenRa.Game/Traits/ProductionSurround.cs @@ -20,7 +20,7 @@ namespace OpenRa.Traits for (var j = min.Y; j <= max.Y; j++) 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 null; diff --git a/OpenRa.Game/Traits/RallyPoint.cs b/OpenRa.Game/Traits/RallyPoint.cs index e53b225122..570e346af3 100644 --- a/OpenRa.Game/Traits/RallyPoint.cs +++ b/OpenRa.Game/Traits/RallyPoint.cs @@ -28,7 +28,7 @@ namespace OpenRa.Traits public IEnumerable Render(Actor self) { 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, anim.Image, Util.CenterOfCell(rallyPoint)); } diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index 38c2b08f21..b2fdc5b3d6 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -19,7 +19,7 @@ namespace OpenRa.Traits if( Game.skipMakeAnims ) Complete( self ); else - anim.PlayThen( "make", () => Game.world.AddFrameEndTask( _ => Complete( self ) ) ); + anim.PlayThen( "make", () => self.World.AddFrameEndTask( _ => Complete( self ) ) ); DoBib(self, false); } @@ -45,11 +45,11 @@ namespace OpenRa.Traits var p = self.Location + new int2(i % size, i / size + bibOffset); if (isRemove) { - if (Game.world.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex)) - Game.world.Map.MapTiles[ p.X, p.Y ].smudge = 0; + if (self.World.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex)) + self.World.Map.MapTiles[ p.X, p.Y ].smudge = 0; } 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; case DamageState.Dead: 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; } } diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index 4cabc0f7e9..0270bc73e3 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -34,7 +34,7 @@ namespace OpenRa.Traits public void Tick(Actor self) { 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; roof.PlayBackwardsThen(GetPrefix(self) + "build-top", () => roof.Play(GetPrefix(self) + "idle-top")); diff --git a/OpenRa.Game/Traits/RenderInfantry.cs b/OpenRa.Game/Traits/RenderInfantry.cs index ac186c25d6..6336c7ed2e 100644 --- a/OpenRa.Game/Traits/RenderInfantry.cs +++ b/OpenRa.Game/Traits/RenderInfantry.cs @@ -77,7 +77,7 @@ namespace OpenRa.Traits if (e.DamageState == DamageState.Dead) { 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))); } } } diff --git a/OpenRa.Game/Traits/SeedsOre.cs b/OpenRa.Game/Traits/SeedsOre.cs index 08bd8ae6f8..139b5c8881 100644 --- a/OpenRa.Game/Traits/SeedsOre.cs +++ b/OpenRa.Game/Traits/SeedsOre.cs @@ -22,8 +22,8 @@ namespace OpenRa.Traits for (var j = -1; j < 2; j++) for (var i = -1; i < 2; i++) if (Game.SharedRandom.NextDouble() < info.Chance) - if (Game.world.OreCanSpreadInto(self.Location.X + i, self.Location.Y + j)) - Game.world.Map.AddOre(self.Location.X + i, self.Location.Y + j); + if (self.World.OreCanSpreadInto(self.Location.X + i, self.Location.Y + j)) + self.World.Map.AddOre(self.Location.X + i, self.Location.Y + j); ticks = info.Interval; } diff --git a/OpenRa.Game/Traits/SquishByTank.cs b/OpenRa.Game/Traits/SquishByTank.cs index 46584a8901..9c12eec3be 100644 --- a/OpenRa.Game/Traits/SquishByTank.cs +++ b/OpenRa.Game/Traits/SquishByTank.cs @@ -30,7 +30,7 @@ namespace OpenRa.Traits public bool IsCrushableBy(UnitMovementType umt, Player player) { - if (player == Game.world.LocalPlayer) return false; + if (player == self.World.LocalPlayer) return false; switch (umt) { case UnitMovementType.Track: return true; diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index fd9233cbcf..ef99c154c9 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -18,7 +18,7 @@ namespace OpenRa.Traits self.Owner.TakeCash(toSteal); thief.Owner.GiveCash(toSteal); - if (Game.world.LocalPlayer == thief.Owner) + if (self.World.LocalPlayer == thief.Owner) Sound.Play("credit1.aud"); } @@ -27,7 +27,7 @@ namespace OpenRa.Traits var numPips = self.Info.Traits.Get().Pips; 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 ); } } diff --git a/OpenRa.Game/Traits/Submarine.cs b/OpenRa.Game/Traits/Submarine.cs index cd157a46ff..6a589d472a 100644 --- a/OpenRa.Game/Traits/Submarine.cs +++ b/OpenRa.Game/Traits/Submarine.cs @@ -33,7 +33,7 @@ namespace OpenRa.Traits if (remainingSurfaceTime > 0) return rs; - if (self.Owner == Game.world.LocalPlayer) + if (self.Owner == self.World.LocalPlayer) return rs.Select(a => a.WithPalette(PaletteType.Shadow)); else return new Renderable[] { }; diff --git a/OpenRa.Game/Traits/Unit.cs b/OpenRa.Game/Traits/Unit.cs index a1b9875803..0c1a423afc 100755 --- a/OpenRa.Game/Traits/Unit.cs +++ b/OpenRa.Game/Traits/Unit.cs @@ -23,7 +23,7 @@ namespace OpenRa.Traits public void Damaged(Actor self, AttackInfo e) { if (e.DamageState == DamageState.Dead) - if (self.Owner == Game.world.LocalPlayer) + if (self.Owner == self.World.LocalPlayer) Sound.Play(self.Info.Traits.Get().WaterBound ? "navylst1.aud" : "unitlst1.aud"); } diff --git a/OpenRa.Mods.Aftermath/ChronoshiftDeploy.cs b/OpenRa.Mods.Aftermath/ChronoshiftDeploy.cs index cec1075f5e..9fb760b74f 100644 --- a/OpenRa.Mods.Aftermath/ChronoshiftDeploy.cs +++ b/OpenRa.Mods.Aftermath/ChronoshiftDeploy.cs @@ -55,7 +55,7 @@ namespace OpenRa.Mods.Aftermath Sound.Play("chrotnk1.aud"); chargeTick = chargeLength; - foreach (var a in Game.world.Actors.Where(a => a.traits.Contains())) + foreach (var a in self.World.Actors.Where(a => a.traits.Contains())) a.traits.Get().DoChronoshift(); } } diff --git a/OpenRa.Mods.Aftermath/DemoTruck.cs b/OpenRa.Mods.Aftermath/DemoTruck.cs index 03ec10db80..8ff1eb2159 100644 --- a/OpenRa.Mods.Aftermath/DemoTruck.cs +++ b/OpenRa.Mods.Aftermath/DemoTruck.cs @@ -20,7 +20,7 @@ namespace OpenRa.Mods.Aftermath { // Override chronoshifting action to detonate vehicle var movement = self.traits.GetOrDefault(); - var chronosphere = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains()).FirstOrDefault(); + var chronosphere = self.World.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains()).FirstOrDefault(); if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation)) { self.InflictDamage(chronosphere, self.Health, Rules.WarheadInfo["Super"]); @@ -44,7 +44,7 @@ namespace OpenRa.Mods.Aftermath var altitude = unit != null ? unit.Altitude : 0; int2 detonateLocation = self.CenterLocation.ToInt2(); - Game.world.AddFrameEndTask( + self.World.AddFrameEndTask( w => w.Add(new Bullet(self.Info.Traits.Get().PrimaryWeapon, detonatedBy.Owner, detonatedBy, detonateLocation, detonateLocation, altitude, altitude))); } diff --git a/OpenRa.Mods.RA/Activities/CaptureBuilding.cs b/OpenRa.Mods.RA/Activities/CaptureBuilding.cs index 362bf33c2f..cc96f690e0 100644 --- a/OpenRa.Mods.RA/Activities/CaptureBuilding.cs +++ b/OpenRa.Mods.RA/Activities/CaptureBuilding.cs @@ -37,7 +37,7 @@ namespace OpenRa.Mods.RA.Activities } // the engineer is sacrificed. - Game.world.AddFrameEndTask(w => w.Remove(self)); + self.World.AddFrameEndTask(w => w.Remove(self)); return NextActivity; } diff --git a/OpenRa.Mods.RA/Activities/Demolish.cs b/OpenRa.Mods.RA/Activities/Demolish.cs index fad7cb0244..b82ef9b3f9 100644 --- a/OpenRa.Mods.RA/Activities/Demolish.cs +++ b/OpenRa.Mods.RA/Activities/Demolish.cs @@ -16,7 +16,7 @@ namespace OpenRa.Mods.RA.Activities public IActivity Tick(Actor self) { 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"])))); return NextActivity; } diff --git a/OpenRa.Mods.RA/Activities/Infiltrate.cs b/OpenRa.Mods.RA/Activities/Infiltrate.cs index 2e3b0b3d53..d3199ab12e 100644 --- a/OpenRa.Mods.RA/Activities/Infiltrate.cs +++ b/OpenRa.Mods.RA/Activities/Infiltrate.cs @@ -17,7 +17,7 @@ namespace OpenRa.Mods.RA.Activities foreach (var t in target.traits.WithInterface()) t.OnInfiltrate(target, self); - Game.world.AddFrameEndTask(w => w.Remove(self)); + self.World.AddFrameEndTask(w => w.Remove(self)); return NextActivity; } diff --git a/OpenRa.Mods.RA/Activities/Steal.cs b/OpenRa.Mods.RA/Activities/Steal.cs index 7d51b25b35..027aa98c62 100644 --- a/OpenRa.Mods.RA/Activities/Steal.cs +++ b/OpenRa.Mods.RA/Activities/Steal.cs @@ -23,7 +23,7 @@ namespace OpenRa.Mods.RA.Activities foreach (var t in target.traits.WithInterface()) t.OnSteal(target, self); - Game.world.AddFrameEndTask(w => w.Remove(self)); + self.World.AddFrameEndTask(w => w.Remove(self)); return NextActivity; } diff --git a/OpenRa.Mods.RA/Mine.cs b/OpenRa.Mods.RA/Mine.cs index 03883b9209..9b8ae4744b 100644 --- a/OpenRa.Mods.RA/Mine.cs +++ b/OpenRa.Mods.RA/Mine.cs @@ -21,7 +21,7 @@ namespace OpenRa.Mods.RA public Mine(Actor self) { this.self = self; - Game.world.UnitInfluence.Add(self, this); + self.World.UnitInfluence.Add(self, this); } public void OnCrush(Actor crusher) @@ -32,17 +32,17 @@ namespace OpenRa.Mods.RA var info = self.Info.Traits.Get(); var warhead = Rules.WarheadInfo[info.Warhead]; - Game.world.AddFrameEndTask(_ => + self.World.AddFrameEndTask(_ => { - Game.world.Remove(self); - Game.world.Add(new Explosion(self.CenterLocation.ToInt2(), warhead.Explosion, false)); + self.World.Remove(self); + self.World.Add(new Explosion(self.CenterLocation.ToInt2(), warhead.Explosion, false)); crusher.InflictDamage(crusher, info.Damage, warhead); }); } public bool IsPathableCrush(UnitMovementType umt, Player player) { - return !self.Info.Traits.Get().AvoidFriendly || (player != Game.world.LocalPlayer); + return !self.Info.Traits.Get().AvoidFriendly || (player != self.World.LocalPlayer); } public bool IsCrushableBy(UnitMovementType umt, Player player) diff --git a/OpenRa.Mods.RA/Minelayer.cs b/OpenRa.Mods.RA/Minelayer.cs index 770772ba69..8ae75d9059 100644 --- a/OpenRa.Mods.RA/Minelayer.cs +++ b/OpenRa.Mods.RA/Minelayer.cs @@ -17,7 +17,7 @@ namespace OpenRa.Mods.RA return null; // 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; 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) - Game.world.AddFrameEndTask( + self.World.AddFrameEndTask( w => w.CreateActor(self.Info.Traits.Get().Mine, self.Location, self.Owner)); } } diff --git a/OpenRa.Mods.RA/RenderSpy.cs b/OpenRa.Mods.RA/RenderSpy.cs index 122ad6612a..c8528b6375 100644 --- a/OpenRa.Mods.RA/RenderSpy.cs +++ b/OpenRa.Mods.RA/RenderSpy.cs @@ -21,15 +21,15 @@ namespace OpenRa.Mods.RA public IEnumerable ModifyRender(Actor self, IEnumerable r) { - if (self.Owner == Game.world.LocalPlayer) + if (self.Owner == self.World.LocalPlayer) 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) { - anim.ChangeImage(self.Owner == Game.world.LocalPlayer ? GetImage(self) : "e1"); + anim.ChangeImage(self.Owner == self.World.LocalPlayer ? GetImage(self) : "e1"); base.Tick(self); } }