Refactoring to remove static Rules & SequenceProvider
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
if (self.World.WorldTick - lastAttackTime > info.NotifyInterval * 25)
|
||||
{
|
||||
Sound.PlayNotification(self.Owner, "Speech", "BaseAttack", self.Owner.Country.Race);
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", "BaseAttack", self.Owner.Country.Race);
|
||||
|
||||
if (radarPings != null)
|
||||
radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
|
||||
|
||||
6
OpenRA.Mods.RA/Player/ClassicProductionQueue.cs
Executable file → Normal file
6
OpenRA.Mods.RA/Player/ClassicProductionQueue.cs
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
foreach (var p in producers.Where(p => !p.Actor.IsDisabled()))
|
||||
{
|
||||
if (p.Trait.Produce(p.Actor, Rules.Info[name]))
|
||||
if (p.Trait.Produce(p.Actor, self.World.Map.Rules.Actors[name]))
|
||||
{
|
||||
FinishProduction();
|
||||
return true;
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public override int GetBuildTime(String unitString)
|
||||
{
|
||||
var unit = Rules.Info[unitString];
|
||||
var unit = self.World.Map.Rules.Actors[unitString];
|
||||
if (unit == null || !unit.Traits.Contains<BuildableInfo>())
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
if (self.World.WorldTick - lastAttackTime > info.NotifyInterval * 25)
|
||||
{
|
||||
Sound.PlayNotification(self.Owner, "Speech", "HarvesterAttack", self.Owner.Country.Race);
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", "HarvesterAttack", self.Owner.Country.Race);
|
||||
|
||||
if (radarPings != null)
|
||||
radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA
|
||||
self.World.Add(playerBeacon);
|
||||
|
||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
Sound.PlayNotification(null, info.NotificationType, info.Notification,
|
||||
Sound.PlayNotification(self.World.Map.Rules, null, info.NotificationType, info.Notification,
|
||||
self.World.RenderPlayer != null ? self.World.RenderPlayer.Country.Race : null);
|
||||
|
||||
if (radarPings != null)
|
||||
|
||||
6
OpenRA.Mods.RA/Player/PlaceBuilding.cs
Executable file → Normal file
6
OpenRA.Mods.RA/Player/PlaceBuilding.cs
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA
|
||||
if (queue == null)
|
||||
return;
|
||||
|
||||
var unit = Rules.Info[order.TargetString];
|
||||
var unit = self.World.Map.Rules.Actors[order.TargetString];
|
||||
var buildingInfo = unit.Traits.Get<BuildingInfo>();
|
||||
|
||||
if (order.OrderString == "LineBuild")
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
if (GetNumBuildables(self.Owner) > prevItems)
|
||||
w.Add(new DelayedAction(10,
|
||||
() => Sound.PlayNotification(order.Player, "Speech", "NewOptions", order.Player.Country.Race)));
|
||||
() => Sound.PlayNotification(self.World.Map.Rules, order.Player, "Speech", "NewOptions", order.Player.Country.Race)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
20
OpenRA.Mods.RA/Player/ProductionQueue.cs
Executable file → Normal file
20
OpenRA.Mods.RA/Player/ProductionQueue.cs
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
IEnumerable<ActorInfo> AllBuildables(string category)
|
||||
{
|
||||
return Rules.Info.Values
|
||||
return self.World.Map.Rules.Actors.Values
|
||||
.Where( x => x.Name[ 0 ] != '^' )
|
||||
.Where( x => x.Traits.Contains<BuildableInfo>() )
|
||||
.Where( x => x.Traits.Get<BuildableInfo>().Queue == category );
|
||||
@@ -149,14 +149,14 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void PrerequisitesAvailable(string key)
|
||||
{
|
||||
var ps = Produceable[ Rules.Info[key] ];
|
||||
var ps = Produceable[ self.World.Map.Rules.Actors[key] ];
|
||||
if (!ps.Sticky)
|
||||
ps.Buildable = true;
|
||||
}
|
||||
|
||||
public void PrerequisitesUnavailable(string key)
|
||||
{
|
||||
var ps = Produceable[ Rules.Info[key] ];
|
||||
var ps = Produceable[ self.World.Map.Rules.Actors[key] ];
|
||||
if (!ps.Sticky)
|
||||
ps.Buildable = false;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
case "StartProduction":
|
||||
{
|
||||
var unit = Rules.Info[order.TargetString];
|
||||
var unit = self.World.Map.Rules.Actors[order.TargetString];
|
||||
var bi = unit.Traits.Get<BuildableInfo>();
|
||||
if (bi.Queue != Info.Type)
|
||||
return; /* Not built by this queue */
|
||||
@@ -243,15 +243,15 @@ namespace OpenRA.Mods.RA
|
||||
var isBuilding = unit.Traits.Contains<BuildingInfo>();
|
||||
if (isBuilding && !hasPlayedSound)
|
||||
{
|
||||
hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
|
||||
hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
|
||||
}
|
||||
else if (!isBuilding)
|
||||
{
|
||||
if (BuildUnit(order.TargetString))
|
||||
Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
|
||||
else if (!hasPlayedSound && time > 0)
|
||||
{
|
||||
hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
|
||||
hasPlayedSound = Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
|
||||
}
|
||||
}
|
||||
})));
|
||||
@@ -274,7 +274,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
virtual public int GetBuildTime(String unitString)
|
||||
{
|
||||
var unit = Rules.Info[unitString];
|
||||
var unit = self.World.Map.Rules.Actors[unitString];
|
||||
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
||||
return 0;
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
var sp = self.TraitsImplementing<Production>().FirstOrDefault(p => p.Info.Produces.Contains(Info.Type));
|
||||
if (sp != null && !self.IsDisabled() && sp.Produce(self, Rules.Info[name]))
|
||||
if (sp != null && !self.IsDisabled() && sp.Produce(self, self.World.Map.Rules.Actors[name]))
|
||||
{
|
||||
FinishProduction();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user