remove more uses of Game.world
This commit is contained in:
@@ -21,10 +21,10 @@ namespace OpenRA.Network
|
|||||||
return Game.LobbyInfo.Clients.FirstOrDefault(c => c.Index == id);
|
return Game.LobbyInfo.Clients.FirstOrDefault(c => c.Index == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Player FindPlayerByClientId(int id)
|
static Player FindPlayerByClientId( this World world, int id)
|
||||||
{
|
{
|
||||||
/* todo: find the interactive player. */
|
/* todo: find the interactive player. */
|
||||||
return Game.world.players.Values.FirstOrDefault(p => p.ClientIndex == id);
|
return world.players.Values.FirstOrDefault(p => p.ClientIndex == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ProcessOrder( World world, int clientId, Order order )
|
public static void ProcessOrder( World world, int clientId, Order order )
|
||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Network
|
|||||||
var client = FindClientById(clientId);
|
var client = FindClientById(clientId);
|
||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
var player = FindPlayerByClientId(clientId);
|
var player = world.FindPlayerByClientId(clientId);
|
||||||
if (player != null && player.WinState == WinState.Lost)
|
if (player != null && player.WinState == WinState.Lost)
|
||||||
Game.AddChatLine(client.Color1, client.Name + " (Dead)", order.TargetString);
|
Game.AddChatLine(client.Color1, client.Name + " (Dead)", order.TargetString);
|
||||||
else
|
else
|
||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Network
|
|||||||
var client = FindClientById(clientId);
|
var client = FindClientById(clientId);
|
||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
var player = FindPlayerByClientId(clientId);
|
var player = world.FindPlayerByClientId(clientId);
|
||||||
var display = (world.GameHasStarted) ?
|
var display = (world.GameHasStarted) ?
|
||||||
player != null && (world.LocalPlayer != null && player.Stances[world.LocalPlayer] == Stance.Ally
|
player != null && (world.LocalPlayer != null && player.Stances[world.LocalPlayer] == Stance.Ally
|
||||||
|| player.WinState == WinState.Lost) :
|
|| player.WinState == WinState.Lost) :
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ namespace OpenRA.Traits
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "DevShroud":
|
case "DevShroud":
|
||||||
{
|
{
|
||||||
DisableShroud ^= true;
|
DisableShroud ^= true;
|
||||||
if (self.World.LocalPlayer == self.Owner)
|
if (self.World.LocalPlayer == self.Owner)
|
||||||
Game.world.LocalPlayer.Shroud.Disabled = DisableShroud;
|
self.World.LocalPlayer.Shroud.Disabled = DisableShroud;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "DevPathDebug":
|
case "DevPathDebug":
|
||||||
@@ -83,17 +83,17 @@ namespace OpenRA.Traits
|
|||||||
if (self.World.LocalPlayer == self.Owner)
|
if (self.World.LocalPlayer == self.Owner)
|
||||||
Game.Settings.Debug.ShowCollisions ^= true;
|
Game.Settings.Debug.ShowCollisions ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "DevGiveExploration":
|
|
||||||
{
|
|
||||||
if (self.World.LocalPlayer == self.Owner)
|
|
||||||
self.World.WorldActor.Trait<Shroud>().ExploreAll(self.World);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
case "DevGiveExploration":
|
||||||
|
{
|
||||||
|
if (self.World.LocalPlayer == self.Owner)
|
||||||
|
self.World.WorldActor.Trait<Shroud>().ExploreAll(self.World);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.Debug("Cheat used: {0} by {1}"
|
Game.Debug("Cheat used: {0} by {1}"
|
||||||
.F(order.OrderString, self.Owner.PlayerName));
|
.F(order.OrderString, self.Owner.PlayerName));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
void DrawUnitPath(Actor self)
|
void DrawUnitPath(Actor self)
|
||||||
{
|
{
|
||||||
if (!Game.world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug) return;
|
if (!self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug) return;
|
||||||
|
|
||||||
var activity = self.GetCurrentActivity();
|
var activity = self.GetCurrentActivity();
|
||||||
var mobile = self.TraitOrDefault<IMove>();
|
var mobile = self.TraitOrDefault<IMove>();
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ namespace OpenRA.Mods.RA
|
|||||||
int2 baseCenter;
|
int2 baseCenter;
|
||||||
XRandom random = new XRandom(); //we do not use the synced random number generator.
|
XRandom random = new XRandom(); //we do not use the synced random number generator.
|
||||||
|
|
||||||
|
World world { get { return p.PlayerActor.World; } }
|
||||||
|
|
||||||
Dictionary<string, float> unitsToBuild = new Dictionary<string, float>
|
Dictionary<string, float> unitsToBuild = new Dictionary<string, float>
|
||||||
{
|
{
|
||||||
{"e1", .0f},
|
{"e1", .0f},
|
||||||
@@ -171,9 +173,9 @@ namespace OpenRA.Mods.RA
|
|||||||
var bi = Rules.Info[item.Item].Traits.Get<BuildingInfo>();
|
var bi = Rules.Info[item.Item].Traits.Get<BuildingInfo>();
|
||||||
|
|
||||||
for (var k = 0; k < MaxBaseDistance; k++)
|
for (var k = 0; k < MaxBaseDistance; k++)
|
||||||
foreach (var t in Game.world.FindTilesInCircle(baseCenter, k))
|
foreach (var t in world.FindTilesInCircle(baseCenter, k))
|
||||||
if (Game.world.CanPlaceBuilding(item.Item, bi, t, null))
|
if (world.CanPlaceBuilding(item.Item, bi, t, null))
|
||||||
if (Game.world.IsCloseEnoughToBase(p, item.Item, bi, t))
|
if (world.IsCloseEnoughToBase(p, item.Item, bi, t))
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
return null; // i don't know where to put it.
|
return null; // i don't know where to put it.
|
||||||
@@ -237,7 +239,7 @@ namespace OpenRA.Mods.RA
|
|||||||
// 2. human.
|
// 2. human.
|
||||||
// 3. not dead.
|
// 3. not dead.
|
||||||
|
|
||||||
var possibleTargets = Game.world.WorldActor.Trait<MPStartLocations>().Start
|
var possibleTargets = world.WorldActor.Trait<MPStartLocations>().Start
|
||||||
.Where(kv => kv.Key != p && IsHumanPlayer(kv.Key)
|
.Where(kv => kv.Key != p && IsHumanPlayer(kv.Key)
|
||||||
&& p.WinState == WinState.Undefined)
|
&& p.WinState == WinState.Undefined)
|
||||||
.Select(kv => kv.Value);
|
.Select(kv => kv.Value);
|
||||||
@@ -276,7 +278,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (attackTarget == null)
|
if (attackTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var a in unitsHangingAroundTheBase)
|
foreach (var a in unitsHangingAroundTheBase)
|
||||||
if (TryToMove(a, attackTarget.Value))
|
if (TryToMove(a, attackTarget.Value))
|
||||||
attackForce.Add(a);
|
attackForce.Add(a);
|
||||||
|
|
||||||
@@ -305,8 +307,8 @@ namespace OpenRA.Mods.RA
|
|||||||
private int2 ChooseRallyLocationNear(int2 startPos)
|
private int2 ChooseRallyLocationNear(int2 startPos)
|
||||||
{
|
{
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
foreach (var t in Game.world.FindTilesInCircle(startPos, 8))
|
foreach (var t in world.FindTilesInCircle(startPos, 8))
|
||||||
if (Game.world.IsCellBuildable(t, false) && t != startPos && r.Next(64) == 0)
|
if (world.IsCellBuildable(t, false) && t != startPos && r.Next(64) == 0)
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
return startPos; // i don't know where to put it.
|
return startPos; // i don't know where to put it.
|
||||||
@@ -353,7 +355,7 @@ namespace OpenRA.Mods.RA
|
|||||||
private void BuildRandom(string category)
|
private void BuildRandom(string category)
|
||||||
{
|
{
|
||||||
// Pick a free queue
|
// Pick a free queue
|
||||||
var queue = Game.world.Queries.WithTraitMultiple<ProductionQueue>()
|
var queue = world.Queries.WithTraitMultiple<ProductionQueue>()
|
||||||
.Where(a => a.Actor.Owner == p &&
|
.Where(a => a.Actor.Owner == p &&
|
||||||
a.Trait.Info.Type == category &&
|
a.Trait.Info.Type == category &&
|
||||||
a.Trait.CurrentItem() == null)
|
a.Trait.CurrentItem() == null)
|
||||||
@@ -386,7 +388,7 @@ namespace OpenRA.Mods.RA
|
|||||||
private void BuildBuildings()
|
private void BuildBuildings()
|
||||||
{
|
{
|
||||||
// Pick a free queue
|
// Pick a free queue
|
||||||
var queue = Game.world.Queries.WithTraitMultiple<ProductionQueue>()
|
var queue = world.Queries.WithTraitMultiple<ProductionQueue>()
|
||||||
.Where(a => a.Actor.Owner == p && a.Trait.Info.Type == "Building")
|
.Where(a => a.Actor.Owner == p && a.Trait.Info.Type == "Building")
|
||||||
.Select(a => a.Trait)
|
.Select(a => a.Trait)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
@@ -448,7 +450,7 @@ namespace OpenRA.Mods.RA
|
|||||||
private void BuildDefense()
|
private void BuildDefense()
|
||||||
{
|
{
|
||||||
// Pick a free queue
|
// Pick a free queue
|
||||||
var queue = Game.world.Queries.WithTraitMultiple<ProductionQueue>()
|
var queue = world.Queries.WithTraitMultiple<ProductionQueue>()
|
||||||
.Where(a => a.Actor.Owner == p && a.Trait.Info.Type == "Defense")
|
.Where(a => a.Actor.Owner == p && a.Trait.Info.Type == "Defense")
|
||||||
.Select(a => a.Trait)
|
.Select(a => a.Trait)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user