StyleCop clean OpenRA.Mods.RA
This commit is contained in:
2
Makefile
2
Makefile
@@ -187,6 +187,8 @@ check:
|
|||||||
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.GameMonitor
|
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.GameMonitor
|
||||||
@echo "Checking for code style violations in OpenRA.Mods.Common..."
|
@echo "Checking for code style violations in OpenRA.Mods.Common..."
|
||||||
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Mods.Common
|
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Mods.Common
|
||||||
|
@echo "Checking for code style violations in OpenRA.Mods.RA..."
|
||||||
|
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Mods.RA
|
||||||
@echo "Checking for code style violations in OpenRA.Mods.Cnc..."
|
@echo "Checking for code style violations in OpenRA.Mods.Cnc..."
|
||||||
@mono --debug OpenRA.Utility.exe cnc --check-code-style OpenRA.Mods.Cnc
|
@mono --debug OpenRA.Utility.exe cnc --check-code-style OpenRA.Mods.Cnc
|
||||||
@echo "Checking for code style violations in OpenRA.Mods.D2k..."
|
@echo "Checking for code style violations in OpenRA.Mods.D2k..."
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
|
||||||
return new SelectGenericPowerTarget(order, manager, "ioncannon", MouseButton.Left);
|
return new SelectGenericPowerTarget(order, manager, "ioncannon", MouseButton.Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
if (mi.Button == MouseButton.Left)
|
if (mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
if (!manager.Powers[key].Active)
|
if (!manager.Powers[key].Active)
|
||||||
Sound.PlayToPlayer(manager.self.Owner, manager.Powers[key].Info.InsufficientPowerSound);
|
Sound.PlayToPlayer(manager.Self.Owner, manager.Powers[key].Info.InsufficientPowerSound);
|
||||||
manager.Target(key);
|
manager.Target(key);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (orderBy != null)
|
if (orderBy != null)
|
||||||
return available.MaxByOrDefault(orderBy);
|
return available.MaxByOrDefault(orderBy);
|
||||||
|
|
||||||
return available.RandomOrDefault(ai.random);
|
return available.RandomOrDefault(ai.Random);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorInfo ChooseBuildingToBuild(ProductionQueue queue)
|
ActorInfo ChooseBuildingToBuild(ProductionQueue queue)
|
||||||
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build everything else
|
// Build everything else
|
||||||
foreach (var frac in ai.Info.BuildingFractions.Shuffle(ai.random))
|
foreach (var frac in ai.Info.BuildingFractions.Shuffle(ai.Random))
|
||||||
{
|
{
|
||||||
var name = frac.Key;
|
var name = frac.Key;
|
||||||
|
|
||||||
|
|||||||
@@ -143,10 +143,10 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
public sealed class HackyAI : ITick, IBot, INotifyDamage
|
public sealed class HackyAI : ITick, IBot, INotifyDamage
|
||||||
{
|
{
|
||||||
public MersenneTwister random { get; private set; }
|
public MersenneTwister Random { get; private set; }
|
||||||
public readonly HackyAIInfo Info;
|
public readonly HackyAIInfo Info;
|
||||||
public CPos baseCenter { get; private set; }
|
public CPos BaseCenter { get; private set; }
|
||||||
public Player p { get; private set; }
|
public Player Player { get; private set; }
|
||||||
|
|
||||||
Dictionary<SupportPowerInstance, int> waitingPowers = new Dictionary<SupportPowerInstance, int>();
|
Dictionary<SupportPowerInstance, int> waitingPowers = new Dictionary<SupportPowerInstance, int>();
|
||||||
Dictionary<string, SupportPowerDecision> powerDecisions = new Dictionary<string, SupportPowerDecision>();
|
Dictionary<string, SupportPowerDecision> powerDecisions = new Dictionary<string, SupportPowerDecision>();
|
||||||
@@ -170,16 +170,16 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
// Units that the ai already knows about. Any unit not on this list needs to be given a role.
|
// Units that the ai already knows about. Any unit not on this list needs to be given a role.
|
||||||
List<Actor> activeUnits = new List<Actor>();
|
List<Actor> activeUnits = new List<Actor>();
|
||||||
|
|
||||||
public const int feedbackTime = 30; // ticks; = a bit over 1s. must be >= netlag.
|
public const int FeedbackTime = 30; // ticks; = a bit over 1s. must be >= netlag.
|
||||||
|
|
||||||
public readonly World world;
|
public readonly World World;
|
||||||
public Map Map { get { return world.Map; } }
|
public Map Map { get { return World.Map; } }
|
||||||
IBotInfo IBot.Info { get { return this.Info; } }
|
IBotInfo IBot.Info { get { return this.Info; } }
|
||||||
|
|
||||||
public HackyAI(HackyAIInfo info, ActorInitializer init)
|
public HackyAI(HackyAIInfo info, ActorInitializer init)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
world = init.World;
|
World = init.World;
|
||||||
|
|
||||||
foreach (var decision in info.PowerDecisions)
|
foreach (var decision in info.PowerDecisions)
|
||||||
powerDecisions.Add(decision.OrderName, decision);
|
powerDecisions.Add(decision.OrderName, decision);
|
||||||
@@ -194,7 +194,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
// Called by the host's player creation code
|
// Called by the host's player creation code
|
||||||
public void Activate(Player p)
|
public void Activate(Player p)
|
||||||
{
|
{
|
||||||
this.p = p;
|
Player = p;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
playerPower = p.PlayerActor.Trait<PowerManager>();
|
playerPower = p.PlayerActor.Trait<PowerManager>();
|
||||||
supportPowerMngr = p.PlayerActor.Trait<SupportPowerManager>();
|
supportPowerMngr = p.PlayerActor.Trait<SupportPowerManager>();
|
||||||
@@ -205,11 +205,11 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
foreach (var defense in Info.DefenseQueues)
|
foreach (var defense in Info.DefenseQueues)
|
||||||
builders.Add(new BaseBuilder(this, defense, p, playerPower, playerResource));
|
builders.Add(new BaseBuilder(this, defense, p, playerPower, playerResource));
|
||||||
|
|
||||||
random = new MersenneTwister((int)p.PlayerActor.ActorID);
|
Random = new MersenneTwister((int)p.PlayerActor.ActorID);
|
||||||
|
|
||||||
resourceTypeIndices = new BitArray(world.TileSet.TerrainInfo.Length); // Big enough
|
resourceTypeIndices = new BitArray(World.TileSet.TerrainInfo.Length); // Big enough
|
||||||
foreach (var t in Map.Rules.Actors["world"].Traits.WithInterface<ResourceTypeInfo>())
|
foreach (var t in Map.Rules.Actors["world"].Traits.WithInterface<ResourceTypeInfo>())
|
||||||
resourceTypeIndices.Set(world.TileSet.GetTerrainIndex(t.TerrainType), true);
|
resourceTypeIndices.Set(World.TileSet.GetTerrainIndex(t.TerrainType), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorInfo ChooseRandomUnitToBuild(ProductionQueue queue)
|
ActorInfo ChooseRandomUnitToBuild(ProductionQueue queue)
|
||||||
@@ -218,7 +218,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!buildableThings.Any())
|
if (!buildableThings.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var unit = buildableThings.ElementAtOrDefault(random.Next(buildableThings.Count()));
|
var unit = buildableThings.ElementAtOrDefault(Random.Next(buildableThings.Count()));
|
||||||
return HasAdequateAirUnits(unit) ? unit : null;
|
return HasAdequateAirUnits(unit) ? unit : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,12 +228,12 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!buildableThings.Any())
|
if (!buildableThings.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var myUnits = p.World
|
var myUnits = Player.World
|
||||||
.ActorsWithTrait<IPositionable>()
|
.ActorsWithTrait<IPositionable>()
|
||||||
.Where(a => a.Actor.Owner == p)
|
.Where(a => a.Actor.Owner == Player)
|
||||||
.Select(a => a.Actor.Info.Name).ToArray();
|
.Select(a => a.Actor.Info.Name).ToArray();
|
||||||
|
|
||||||
foreach (var unit in Info.UnitsToBuild.Shuffle(random))
|
foreach (var unit in Info.UnitsToBuild.Shuffle(Random))
|
||||||
if (buildableThings.Any(b => b.Name == unit.Key))
|
if (buildableThings.Any(b => b.Name == unit.Key))
|
||||||
if (myUnits.Count(a => a == unit.Key) < unit.Value * myUnits.Length)
|
if (myUnits.Count(a => a == unit.Key) < unit.Value * myUnits.Length)
|
||||||
if (HasAdequateAirUnits(Map.Rules.Actors[unit.Key]))
|
if (HasAdequateAirUnits(Map.Rules.Actors[unit.Key]))
|
||||||
@@ -244,13 +244,13 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
int CountBuilding(string frac, Player owner)
|
int CountBuilding(string frac, Player owner)
|
||||||
{
|
{
|
||||||
return world.ActorsWithTrait<Building>()
|
return World.ActorsWithTrait<Building>()
|
||||||
.Count(a => a.Actor.Owner == owner && a.Actor.Info.Name == frac);
|
.Count(a => a.Actor.Owner == owner && a.Actor.Info.Name == frac);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CountUnits(string unit, Player owner)
|
int CountUnits(string unit, Player owner)
|
||||||
{
|
{
|
||||||
return world.ActorsWithTrait<IPositionable>()
|
return World.ActorsWithTrait<IPositionable>()
|
||||||
.Count(a => a.Actor.Owner == owner && a.Actor.Info.Name == unit);
|
.Count(a => a.Actor.Owner == owner && a.Actor.Info.Name == unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,14 +259,14 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!Info.BuildingCommonNames.ContainsKey(commonName))
|
if (!Info.BuildingCommonNames.ContainsKey(commonName))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return world.ActorsWithTrait<Building>()
|
return World.ActorsWithTrait<Building>()
|
||||||
.Count(a => a.Actor.Owner == owner && Info.BuildingCommonNames[commonName].Contains(a.Actor.Info.Name));
|
.Count(a => a.Actor.Owner == owner && Info.BuildingCommonNames[commonName].Contains(a.Actor.Info.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActorInfo GetBuildingInfoByCommonName(string commonName, Player owner)
|
public ActorInfo GetBuildingInfoByCommonName(string commonName, Player owner)
|
||||||
{
|
{
|
||||||
if (commonName == "ConstructionYard")
|
if (commonName == "ConstructionYard")
|
||||||
return Map.Rules.Actors.Where(k => Info.BuildingCommonNames[commonName].Contains(k.Key)).Random(random).Value;
|
return Map.Rules.Actors.Where(k => Info.BuildingCommonNames[commonName].Contains(k.Key)).Random(Random).Value;
|
||||||
|
|
||||||
return GetInfoByCommonName(Info.BuildingCommonNames, commonName, owner);
|
return GetInfoByCommonName(Info.BuildingCommonNames, commonName, owner);
|
||||||
}
|
}
|
||||||
@@ -281,30 +281,30 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!names.Any() || !names.ContainsKey(commonName))
|
if (!names.Any() || !names.ContainsKey(commonName))
|
||||||
throw new InvalidOperationException("Can't find {0} in the HackyAI UnitsCommonNames definition.".F(commonName));
|
throw new InvalidOperationException("Can't find {0} in the HackyAI UnitsCommonNames definition.".F(commonName));
|
||||||
|
|
||||||
return Map.Rules.Actors.Where(k => names[commonName].Contains(k.Key)).Random(random).Value;
|
return Map.Rules.Actors.Where(k => names[commonName].Contains(k.Key)).Random(Random).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasAdequateFact()
|
public bool HasAdequateFact()
|
||||||
{
|
{
|
||||||
// Require at least one construction yard, unless we have no vehicles factory (can't build it).
|
// Require at least one construction yard, unless we have no vehicles factory (can't build it).
|
||||||
return CountBuildingByCommonName("ConstructionYard", p) > 0 ||
|
return CountBuildingByCommonName("ConstructionYard", Player) > 0 ||
|
||||||
CountBuildingByCommonName("VehiclesFactory", p) == 0;
|
CountBuildingByCommonName("VehiclesFactory", Player) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasAdequateProc()
|
public bool HasAdequateProc()
|
||||||
{
|
{
|
||||||
// Require at least one refinery, unless we have no power (can't build it).
|
// Require at least one refinery, unless we have no power (can't build it).
|
||||||
return CountBuildingByCommonName("Refinery", p) > 0 ||
|
return CountBuildingByCommonName("Refinery", Player) > 0 ||
|
||||||
CountBuildingByCommonName("Power", p) == 0;
|
CountBuildingByCommonName("Power", Player) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasMinimumProc()
|
public bool HasMinimumProc()
|
||||||
{
|
{
|
||||||
// Require at least two refineries, unless we have no power (can't build it)
|
// Require at least two refineries, unless we have no power (can't build it)
|
||||||
// or barracks (higher priority?)
|
// or barracks (higher priority?)
|
||||||
return CountBuildingByCommonName("Refinery", p) >= 2 ||
|
return CountBuildingByCommonName("Refinery", Player) >= 2 ||
|
||||||
CountBuildingByCommonName("Power", p) == 0 ||
|
CountBuildingByCommonName("Power", Player) == 0 ||
|
||||||
CountBuildingByCommonName("Barracks", p) == 0;
|
CountBuildingByCommonName("Barracks", Player) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For mods like RA (number of building must match the number of aircraft)
|
// For mods like RA (number of building must match the number of aircraft)
|
||||||
@@ -313,8 +313,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!actorInfo.Traits.Contains<ReloadsInfo>() && actorInfo.Traits.Contains<LimitedAmmoInfo>()
|
if (!actorInfo.Traits.Contains<ReloadsInfo>() && actorInfo.Traits.Contains<LimitedAmmoInfo>()
|
||||||
&& actorInfo.Traits.Contains<AircraftInfo>())
|
&& actorInfo.Traits.Contains<AircraftInfo>())
|
||||||
{
|
{
|
||||||
var countOwnAir = CountUnits(actorInfo.Name, p);
|
var countOwnAir = CountUnits(actorInfo.Name, Player);
|
||||||
var countBuildings = CountBuilding(actorInfo.Traits.Get<AircraftInfo>().RearmBuildings.FirstOrDefault(), p);
|
var countBuildings = CountBuilding(actorInfo.Traits.Get<AircraftInfo>().RearmBuildings.FirstOrDefault(), Player);
|
||||||
if (countOwnAir >= countBuildings)
|
if (countOwnAir >= countBuildings)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -338,14 +338,14 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (center != target)
|
if (center != target)
|
||||||
cells = cells.OrderBy(c => (c - target).LengthSquared);
|
cells = cells.OrderBy(c => (c - target).LengthSquared);
|
||||||
else
|
else
|
||||||
cells = cells.Shuffle(random);
|
cells = cells.Shuffle(Random);
|
||||||
|
|
||||||
foreach (var cell in cells)
|
foreach (var cell in cells)
|
||||||
{
|
{
|
||||||
if (!world.CanPlaceBuilding(actorType, bi, cell, null))
|
if (!World.CanPlaceBuilding(actorType, bi, cell, null))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (distanceToBaseIsImportant && !bi.IsCloseEnoughToBase(world, p, actorType, cell))
|
if (distanceToBaseIsImportant && !bi.IsCloseEnoughToBase(World, Player, actorType, cell))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
@@ -359,31 +359,31 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
case BuildingType.Defense:
|
case BuildingType.Defense:
|
||||||
|
|
||||||
// Build near the closest enemy structure
|
// Build near the closest enemy structure
|
||||||
var closestEnemy = world.Actors.Where(a => !a.Destroyed && a.HasTrait<Building>() && p.Stances[a.Owner] == Stance.Enemy)
|
var closestEnemy = World.Actors.Where(a => !a.Destroyed && a.HasTrait<Building>() && Player.Stances[a.Owner] == Stance.Enemy)
|
||||||
.ClosestTo(world.Map.CenterOfCell(defenseCenter));
|
.ClosestTo(World.Map.CenterOfCell(defenseCenter));
|
||||||
|
|
||||||
var targetCell = closestEnemy != null ? closestEnemy.Location : baseCenter;
|
var targetCell = closestEnemy != null ? closestEnemy.Location : BaseCenter;
|
||||||
return findPos(defenseCenter, targetCell, Info.MinimumDefenseRadius, Info.MaximumDefenseRadius);
|
return findPos(defenseCenter, targetCell, Info.MinimumDefenseRadius, Info.MaximumDefenseRadius);
|
||||||
|
|
||||||
case BuildingType.Refinery:
|
case BuildingType.Refinery:
|
||||||
|
|
||||||
// Try and place the refinery near a resource field
|
// Try and place the refinery near a resource field
|
||||||
var nearbyResources = Map.FindTilesInCircle(baseCenter, Info.MaxBaseRadius)
|
var nearbyResources = Map.FindTilesInCircle(BaseCenter, Info.MaxBaseRadius)
|
||||||
.Where(a => resourceTypeIndices.Get(Map.GetTerrainIndex(a)))
|
.Where(a => resourceTypeIndices.Get(Map.GetTerrainIndex(a)))
|
||||||
.Shuffle(random);
|
.Shuffle(Random);
|
||||||
|
|
||||||
foreach (var c in nearbyResources)
|
foreach (var c in nearbyResources)
|
||||||
{
|
{
|
||||||
var found = findPos(c, baseCenter, 0, Info.MaxBaseRadius);
|
var found = findPos(c, BaseCenter, 0, Info.MaxBaseRadius);
|
||||||
if (found != null)
|
if (found != null)
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try and find a free spot somewhere else in the base
|
// Try and find a free spot somewhere else in the base
|
||||||
return findPos(baseCenter, baseCenter, 0, Info.MaxBaseRadius);
|
return findPos(BaseCenter, BaseCenter, 0, Info.MaxBaseRadius);
|
||||||
|
|
||||||
case BuildingType.Building:
|
case BuildingType.Building:
|
||||||
return findPos(baseCenter, baseCenter, 0, distanceToBaseIsImportant ? Info.MaxBaseRadius : Map.MaxTilesInCircleRange);
|
return findPos(BaseCenter, BaseCenter, 0, distanceToBaseIsImportant ? Info.MaxBaseRadius : Map.MaxTilesInCircleRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't find a build location
|
// Can't find a build location
|
||||||
@@ -400,7 +400,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (ticks == 1)
|
if (ticks == 1)
|
||||||
InitializeBase(self);
|
InitializeBase(self);
|
||||||
|
|
||||||
if (ticks % feedbackTime == 0)
|
if (ticks % FeedbackTime == 0)
|
||||||
ProductionUnits(self);
|
ProductionUnits(self);
|
||||||
|
|
||||||
AssignRolesToIdleUnits(self);
|
AssignRolesToIdleUnits(self);
|
||||||
@@ -413,11 +413,11 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
internal Actor ChooseEnemyTarget()
|
internal Actor ChooseEnemyTarget()
|
||||||
{
|
{
|
||||||
if (p.WinState != WinState.Undefined)
|
if (Player.WinState != WinState.Undefined)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var liveEnemies = world.Players
|
var liveEnemies = World.Players
|
||||||
.Where(q => p != q && p.Stances[q] == Stance.Enemy && q.WinState == WinState.Undefined);
|
.Where(p => Player != p && Player.Stances[p] == Stance.Enemy && p.WinState == WinState.Undefined);
|
||||||
|
|
||||||
if (!liveEnemies.Any())
|
if (!liveEnemies.Any())
|
||||||
return null;
|
return null;
|
||||||
@@ -427,18 +427,18 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
.MaxByOrDefault(g => g.Key);
|
.MaxByOrDefault(g => g.Key);
|
||||||
|
|
||||||
var enemy = (leastLikedEnemies != null) ?
|
var enemy = (leastLikedEnemies != null) ?
|
||||||
leastLikedEnemies.Random(random) : liveEnemies.FirstOrDefault();
|
leastLikedEnemies.Random(Random) : liveEnemies.FirstOrDefault();
|
||||||
|
|
||||||
// Pick something worth attacking owned by that player
|
// Pick something worth attacking owned by that player
|
||||||
var target = world.Actors
|
var target = World.Actors
|
||||||
.Where(a => a.Owner == enemy && a.HasTrait<IOccupySpace>())
|
.Where(a => a.Owner == enemy && a.HasTrait<IOccupySpace>())
|
||||||
.ClosestTo(world.Map.CenterOfCell(baseCenter));
|
.ClosestTo(World.Map.CenterOfCell(BaseCenter));
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
/* Assume that "enemy" has nothing. Cool off on attacks. */
|
/* Assume that "enemy" has nothing. Cool off on attacks. */
|
||||||
aggro[enemy].Aggro = aggro[enemy].Aggro / 2 - 1;
|
aggro[enemy].Aggro = aggro[enemy].Aggro / 2 - 1;
|
||||||
Log.Write("debug", "Bot {0} couldn't find target for player {1}", this.p.ClientIndex, enemy.ClientIndex);
|
Log.Write("debug", "Bot {0} couldn't find target for player {1}", Player.ClientIndex, enemy.ClientIndex);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -452,8 +452,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
internal Actor FindClosestEnemy(WPos pos)
|
internal Actor FindClosestEnemy(WPos pos)
|
||||||
{
|
{
|
||||||
var allEnemyUnits = world.Actors
|
var allEnemyUnits = World.Actors
|
||||||
.Where(unit => p.Stances[unit.Owner] == Stance.Enemy && !unit.HasTrait<Husk>() &&
|
.Where(unit => Player.Stances[unit.Owner] == Stance.Enemy && !unit.HasTrait<Husk>() &&
|
||||||
unit.HasTrait<ITargetable>());
|
unit.HasTrait<ITargetable>());
|
||||||
|
|
||||||
return allEnemyUnits.ClosestTo(pos);
|
return allEnemyUnits.ClosestTo(pos);
|
||||||
@@ -461,8 +461,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
internal Actor FindClosestEnemy(WPos pos, WRange radius)
|
internal Actor FindClosestEnemy(WPos pos, WRange radius)
|
||||||
{
|
{
|
||||||
var enemyUnits = world.FindActorsInCircle(pos, radius)
|
var enemyUnits = World.FindActorsInCircle(pos, radius)
|
||||||
.Where(unit => p.Stances[unit.Owner] == Stance.Enemy &&
|
.Where(unit => Player.Stances[unit.Owner] == Stance.Enemy &&
|
||||||
!unit.HasTrait<Husk>() && unit.HasTrait<ITargetable>()).ToList();
|
!unit.HasTrait<Husk>() && unit.HasTrait<ITargetable>()).ToList();
|
||||||
|
|
||||||
if (enemyUnits.Count > 0)
|
if (enemyUnits.Count > 0)
|
||||||
@@ -473,7 +473,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
List<Actor> FindEnemyConstructionYards()
|
List<Actor> FindEnemyConstructionYards()
|
||||||
{
|
{
|
||||||
return world.Actors.Where(a => p.Stances[a.Owner] == Stance.Enemy && !a.IsDead
|
return World.Actors.Where(a => Player.Stances[a.Owner] == Stance.Enemy && !a.IsDead
|
||||||
&& a.HasTrait<BaseBuilding>() && !a.HasTrait<Mobile>()).ToList();
|
&& a.HasTrait<BaseBuilding>() && !a.HasTrait<Mobile>()).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,13 +481,13 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
{
|
{
|
||||||
squads.RemoveAll(s => !s.IsValid);
|
squads.RemoveAll(s => !s.IsValid);
|
||||||
foreach (var s in squads)
|
foreach (var s in squads)
|
||||||
s.units.RemoveAll(a => a.IsDead || a.Owner != p);
|
s.Units.RemoveAll(a => a.IsDead || a.Owner != Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use of this function requires that one squad of this type. Hence it is a piece of shit
|
// Use of this function requires that one squad of this type. Hence it is a piece of shit
|
||||||
Squad GetSquadOfType(SquadType type)
|
Squad GetSquadOfType(SquadType type)
|
||||||
{
|
{
|
||||||
return squads.FirstOrDefault(s => s.type == type);
|
return squads.FirstOrDefault(s => s.Type == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
Squad RegisterNewSquad(SquadType type, Actor target = null)
|
Squad RegisterNewSquad(SquadType type, Actor target = null)
|
||||||
@@ -504,8 +504,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
void AssignRolesToIdleUnits(Actor self)
|
void AssignRolesToIdleUnits(Actor self)
|
||||||
{
|
{
|
||||||
CleanSquads();
|
CleanSquads();
|
||||||
activeUnits.RemoveAll(a => a.IsDead || a.Owner != p);
|
activeUnits.RemoveAll(a => a.IsDead || a.Owner != Player);
|
||||||
unitsHangingAroundTheBase.RemoveAll(a => a.IsDead || a.Owner != p);
|
unitsHangingAroundTheBase.RemoveAll(a => a.IsDead || a.Owner != Player);
|
||||||
|
|
||||||
if (--rushTicks <= 0)
|
if (--rushTicks <= 0)
|
||||||
{
|
{
|
||||||
@@ -554,21 +554,21 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Tell the idle harvester to quit slacking:
|
// Tell the idle harvester to quit slacking:
|
||||||
world.IssueOrder(new Order("Harvest", a, false));
|
World.IssueOrder(new Order("Harvest", a, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindNewUnits(Actor self)
|
void FindNewUnits(Actor self)
|
||||||
{
|
{
|
||||||
var newUnits = self.World.ActorsWithTrait<IPositionable>()
|
var newUnits = self.World.ActorsWithTrait<IPositionable>()
|
||||||
.Where(a => a.Actor.Owner == p && !a.Actor.HasTrait<BaseBuilding>()
|
.Where(a => a.Actor.Owner == Player && !a.Actor.HasTrait<BaseBuilding>()
|
||||||
&& !activeUnits.Contains(a.Actor))
|
&& !activeUnits.Contains(a.Actor))
|
||||||
.Select(a => a.Actor);
|
.Select(a => a.Actor);
|
||||||
|
|
||||||
foreach (var a in newUnits)
|
foreach (var a in newUnits)
|
||||||
{
|
{
|
||||||
if (a.HasTrait<Harvester>())
|
if (a.HasTrait<Harvester>())
|
||||||
world.IssueOrder(new Order("Harvest", a, false));
|
World.IssueOrder(new Order("Harvest", a, false));
|
||||||
else
|
else
|
||||||
unitsHangingAroundTheBase.Add(a);
|
unitsHangingAroundTheBase.Add(a);
|
||||||
|
|
||||||
@@ -578,7 +578,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (air == null)
|
if (air == null)
|
||||||
air = RegisterNewSquad(SquadType.Air);
|
air = RegisterNewSquad(SquadType.Air);
|
||||||
|
|
||||||
air.units.Add(a);
|
air.Units.Add(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
activeUnits.Add(a);
|
activeUnits.Add(a);
|
||||||
@@ -589,7 +589,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
{
|
{
|
||||||
// Create an attack force when we have enough units around our base.
|
// Create an attack force when we have enough units around our base.
|
||||||
// (don't bother leaving any behind for defense)
|
// (don't bother leaving any behind for defense)
|
||||||
var randomizedSquadSize = Info.SquadSize + random.Next(30);
|
var randomizedSquadSize = Info.SquadSize + Random.Next(30);
|
||||||
|
|
||||||
if (unitsHangingAroundTheBase.Count >= randomizedSquadSize)
|
if (unitsHangingAroundTheBase.Count >= randomizedSquadSize)
|
||||||
{
|
{
|
||||||
@@ -597,7 +597,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
foreach (var a in unitsHangingAroundTheBase)
|
foreach (var a in unitsHangingAroundTheBase)
|
||||||
if (!a.HasTrait<Aircraft>())
|
if (!a.HasTrait<Aircraft>())
|
||||||
attackForce.units.Add(a);
|
attackForce.Units.Add(a);
|
||||||
|
|
||||||
unitsHangingAroundTheBase.Clear();
|
unitsHangingAroundTheBase.Clear();
|
||||||
}
|
}
|
||||||
@@ -614,18 +614,18 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
foreach (var b in allEnemyBaseBuilder)
|
foreach (var b in allEnemyBaseBuilder)
|
||||||
{
|
{
|
||||||
var enemies = world.FindActorsInCircle(b.CenterPosition, WRange.FromCells(Info.RushAttackScanRadius))
|
var enemies = World.FindActorsInCircle(b.CenterPosition, WRange.FromCells(Info.RushAttackScanRadius))
|
||||||
.Where(unit => p.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait<AttackBase>()).ToList();
|
.Where(unit => Player.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait<AttackBase>()).ToList();
|
||||||
|
|
||||||
if (rushFuzzy.CanAttack(ownUnits, enemies))
|
if (rushFuzzy.CanAttack(ownUnits, enemies))
|
||||||
{
|
{
|
||||||
var target = enemies.Any() ? enemies.Random(random) : b;
|
var target = enemies.Any() ? enemies.Random(Random) : b;
|
||||||
var rush = GetSquadOfType(SquadType.Rush);
|
var rush = GetSquadOfType(SquadType.Rush);
|
||||||
if (rush == null)
|
if (rush == null)
|
||||||
rush = RegisterNewSquad(SquadType.Rush, target);
|
rush = RegisterNewSquad(SquadType.Rush, target);
|
||||||
|
|
||||||
foreach (var a3 in ownUnits)
|
foreach (var a3 in ownUnits)
|
||||||
rush.units.Add(a3);
|
rush.Units.Add(a3);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -639,32 +639,32 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
protectSq = RegisterNewSquad(SquadType.Protection, attacker);
|
protectSq = RegisterNewSquad(SquadType.Protection, attacker);
|
||||||
|
|
||||||
if (!protectSq.TargetIsValid)
|
if (!protectSq.TargetIsValid)
|
||||||
protectSq.Target = attacker;
|
protectSq.TargetActor = attacker;
|
||||||
|
|
||||||
if (!protectSq.IsValid)
|
if (!protectSq.IsValid)
|
||||||
{
|
{
|
||||||
var ownUnits = world.FindActorsInCircle(world.Map.CenterOfCell(baseCenter), WRange.FromCells(Info.ProtectUnitScanRadius))
|
var ownUnits = World.FindActorsInCircle(World.Map.CenterOfCell(BaseCenter), WRange.FromCells(Info.ProtectUnitScanRadius))
|
||||||
.Where(unit => unit.Owner == p && !unit.HasTrait<Building>()
|
.Where(unit => unit.Owner == Player && !unit.HasTrait<Building>()
|
||||||
&& unit.HasTrait<AttackBase>()).ToList();
|
&& unit.HasTrait<AttackBase>()).ToList();
|
||||||
|
|
||||||
foreach (var a in ownUnits)
|
foreach (var a in ownUnits)
|
||||||
protectSq.units.Add(a);
|
protectSq.Units.Add(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsRallyPointValid(CPos x, BuildingInfo info)
|
bool IsRallyPointValid(CPos x, BuildingInfo info)
|
||||||
{
|
{
|
||||||
return info != null && world.IsCellBuildable(x, info);
|
return info != null && World.IsCellBuildable(x, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRallyPointsForNewProductionBuildings(Actor self)
|
void SetRallyPointsForNewProductionBuildings(Actor self)
|
||||||
{
|
{
|
||||||
var buildings = self.World.ActorsWithTrait<RallyPoint>()
|
var buildings = self.World.ActorsWithTrait<RallyPoint>()
|
||||||
.Where(rp => rp.Actor.Owner == p &&
|
.Where(rp => rp.Actor.Owner == Player &&
|
||||||
!IsRallyPointValid(rp.Trait.Location, rp.Actor.Info.Traits.GetOrDefault<BuildingInfo>())).ToArray();
|
!IsRallyPointValid(rp.Trait.Location, rp.Actor.Info.Traits.GetOrDefault<BuildingInfo>())).ToArray();
|
||||||
|
|
||||||
foreach (var a in buildings)
|
foreach (var a in buildings)
|
||||||
world.IssueOrder(new Order("SetRallyPoint", a.Actor, false) { TargetLocation = ChooseRallyLocationNear(a.Actor), SuppressVisualFeedback = true });
|
World.IssueOrder(new Order("SetRallyPoint", a.Actor, false) { TargetLocation = ChooseRallyLocationNear(a.Actor), SuppressVisualFeedback = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Won't work for shipyards...
|
// Won't work for shipyards...
|
||||||
@@ -679,24 +679,24 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
return producer.Location;
|
return producer.Location;
|
||||||
}
|
}
|
||||||
|
|
||||||
return possibleRallyPoints.Random(random);
|
return possibleRallyPoints.Random(Random);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeBase(Actor self)
|
void InitializeBase(Actor self)
|
||||||
{
|
{
|
||||||
// Find and deploy our mcv
|
// Find and deploy our mcv
|
||||||
var mcv = self.World.Actors
|
var mcv = self.World.Actors
|
||||||
.FirstOrDefault(a => a.Owner == p && a.HasTrait<BaseBuilding>());
|
.FirstOrDefault(a => a.Owner == Player && a.HasTrait<BaseBuilding>());
|
||||||
|
|
||||||
if (mcv != null)
|
if (mcv != null)
|
||||||
{
|
{
|
||||||
baseCenter = mcv.Location;
|
BaseCenter = mcv.Location;
|
||||||
defenseCenter = baseCenter;
|
defenseCenter = BaseCenter;
|
||||||
|
|
||||||
// Don't transform the mcv if it is a fact
|
// Don't transform the mcv if it is a fact
|
||||||
// HACK: This needs to query against MCVs directly
|
// HACK: This needs to query against MCVs directly
|
||||||
if (mcv.HasTrait<Mobile>())
|
if (mcv.HasTrait<Mobile>())
|
||||||
world.IssueOrder(new Order("DeployTransform", mcv, false));
|
World.IssueOrder(new Order("DeployTransform", mcv, false));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
BotDebug("AI: Can't find BaseBuildUnit.");
|
BotDebug("AI: Can't find BaseBuildUnit.");
|
||||||
@@ -707,7 +707,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
void FindAndDeployBackupMcv(Actor self)
|
void FindAndDeployBackupMcv(Actor self)
|
||||||
{
|
{
|
||||||
// HACK: This needs to query against MCVs directly
|
// HACK: This needs to query against MCVs directly
|
||||||
var mcvs = self.World.Actors.Where(a => a.Owner == p && a.HasTrait<BaseBuilding>() && a.HasTrait<Mobile>());
|
var mcvs = self.World.Actors.Where(a => a.Owner == Player && a.HasTrait<BaseBuilding>() && a.HasTrait<Mobile>());
|
||||||
if (!mcvs.Any())
|
if (!mcvs.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -721,8 +721,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (desiredLocation == null)
|
if (desiredLocation == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
world.IssueOrder(new Order("Move", mcv, true) { TargetLocation = desiredLocation.Value });
|
World.IssueOrder(new Order("Move", mcv, true) { TargetLocation = desiredLocation.Value });
|
||||||
world.IssueOrder(new Order("DeployTransform", mcv, true));
|
World.IssueOrder(new Order("DeployTransform", mcv, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,7 +757,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
var attackLocation = FindCoarseAttackLocationToSupportPower(sp);
|
var attackLocation = FindCoarseAttackLocationToSupportPower(sp);
|
||||||
if (attackLocation == null)
|
if (attackLocation == null)
|
||||||
{
|
{
|
||||||
BotDebug("AI: {1} can't find suitable coarse attack location for support power {0}. Delaying rescan.", sp.Info.OrderName, p.PlayerName);
|
BotDebug("AI: {1} can't find suitable coarse attack location for support power {0}. Delaying rescan.", sp.Info.OrderName, Player.PlayerName);
|
||||||
waitingPowers[sp] += powerDecision.GetNextScanTime(this);
|
waitingPowers[sp] += powerDecision.GetNextScanTime(this);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -767,16 +767,16 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
attackLocation = FindFineAttackLocationToSupportPower(sp, (CPos)attackLocation);
|
attackLocation = FindFineAttackLocationToSupportPower(sp, (CPos)attackLocation);
|
||||||
if (attackLocation == null)
|
if (attackLocation == null)
|
||||||
{
|
{
|
||||||
BotDebug("AI: {1} can't find suitable final attack location for support power {0}. Delaying rescan.", sp.Info.OrderName, p.PlayerName);
|
BotDebug("AI: {1} can't find suitable final attack location for support power {0}. Delaying rescan.", sp.Info.OrderName, Player.PlayerName);
|
||||||
waitingPowers[sp] += powerDecision.GetNextScanTime(this);
|
waitingPowers[sp] += powerDecision.GetNextScanTime(this);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid target found, delay by a few ticks to avoid rescanning before power fires via order
|
// Valid target found, delay by a few ticks to avoid rescanning before power fires via order
|
||||||
BotDebug("AI: {2} found new target location {0} for support power {1}.", attackLocation, sp.Info.OrderName, p.PlayerName);
|
BotDebug("AI: {2} found new target location {0} for support power {1}.", attackLocation, sp.Info.OrderName, Player.PlayerName);
|
||||||
waitingPowers[sp] += 10;
|
waitingPowers[sp] += 10;
|
||||||
world.IssueOrder(new Order(sp.Info.OrderName, supportPowerMngr.self, false) { TargetLocation = attackLocation.Value, SuppressVisualFeedback = true });
|
World.IssueOrder(new Order(sp.Info.OrderName, supportPowerMngr.Self, false) { TargetLocation = attackLocation.Value, SuppressVisualFeedback = true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -794,17 +794,17 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
}
|
}
|
||||||
|
|
||||||
var checkRadius = powerDecision.CoarseScanRadius;
|
var checkRadius = powerDecision.CoarseScanRadius;
|
||||||
for (var i = 0; i < world.Map.MapSize.X; i += checkRadius)
|
for (var i = 0; i < World.Map.MapSize.X; i += checkRadius)
|
||||||
{
|
{
|
||||||
for (var j = 0; j < world.Map.MapSize.Y; j += checkRadius)
|
for (var j = 0; j < World.Map.MapSize.Y; j += checkRadius)
|
||||||
{
|
{
|
||||||
var consideredAttractiveness = 0;
|
var consideredAttractiveness = 0;
|
||||||
|
|
||||||
var tl = world.Map.CenterOfCell(new CPos(i, j));
|
var tl = World.Map.CenterOfCell(new CPos(i, j));
|
||||||
var br = world.Map.CenterOfCell(new CPos(i + checkRadius, j + checkRadius));
|
var br = World.Map.CenterOfCell(new CPos(i + checkRadius, j + checkRadius));
|
||||||
var targets = world.ActorMap.ActorsInBox(tl, br);
|
var targets = World.ActorMap.ActorsInBox(tl, br);
|
||||||
|
|
||||||
consideredAttractiveness = powerDecision.GetAttractiveness(targets, p);
|
consideredAttractiveness = powerDecision.GetAttractiveness(targets, Player);
|
||||||
if (consideredAttractiveness <= bestAttractiveness || consideredAttractiveness < powerDecision.MinimumAttractiveness)
|
if (consideredAttractiveness <= bestAttractiveness || consideredAttractiveness < powerDecision.MinimumAttractiveness)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -837,9 +837,9 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
for (var j = 0 - extendedRange; j <= (checkRadius + extendedRange); j += fineCheck)
|
for (var j = 0 - extendedRange; j <= (checkRadius + extendedRange); j += fineCheck)
|
||||||
{
|
{
|
||||||
var y = checkPos.Y + j;
|
var y = checkPos.Y + j;
|
||||||
var pos = world.Map.CenterOfCell(new CPos(x, y));
|
var pos = World.Map.CenterOfCell(new CPos(x, y));
|
||||||
var consideredAttractiveness = 0;
|
var consideredAttractiveness = 0;
|
||||||
consideredAttractiveness += powerDecision.GetAttractiveness(pos, p);
|
consideredAttractiveness += powerDecision.GetAttractiveness(pos, Player);
|
||||||
|
|
||||||
if (consideredAttractiveness <= bestAttractiveness || consideredAttractiveness < powerDecision.MinimumAttractiveness)
|
if (consideredAttractiveness <= bestAttractiveness || consideredAttractiveness < powerDecision.MinimumAttractiveness)
|
||||||
continue;
|
continue;
|
||||||
@@ -854,8 +854,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
internal IEnumerable<ProductionQueue> FindQueues(string category)
|
internal IEnumerable<ProductionQueue> FindQueues(string category)
|
||||||
{
|
{
|
||||||
return world.ActorsWithTrait<ProductionQueue>()
|
return World.ActorsWithTrait<ProductionQueue>()
|
||||||
.Where(a => a.Actor.Owner == p && a.Trait.Info.Type == category && a.Trait.Enabled)
|
.Where(a => a.Actor.Owner == Player && a.Trait.Info.Type == category && a.Trait.Enabled)
|
||||||
.Select(a => a.Trait);
|
.Select(a => a.Trait);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -866,8 +866,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// No construction yards - Build a new MCV
|
// No construction yards - Build a new MCV
|
||||||
if (!HasAdequateFact() && !self.World.Actors.Any(a => a.Owner == p && a.HasTrait<BaseBuilding>() && a.HasTrait<Mobile>()))
|
if (!HasAdequateFact() && !self.World.Actors.Any(a => a.Owner == Player && a.HasTrait<BaseBuilding>() && a.HasTrait<Mobile>()))
|
||||||
BuildUnit("Vehicle", GetUnitInfoByCommonName("Mcv", p).Name);
|
BuildUnit("Vehicle", GetUnitInfoByCommonName("Mcv", Player).Name);
|
||||||
|
|
||||||
foreach (var q in Info.UnitQueues)
|
foreach (var q in Info.UnitQueues)
|
||||||
BuildUnit(q, unitsHangingAroundTheBase.Count < Info.IdleBaseUnitsMaximum);
|
BuildUnit(q, unitsHangingAroundTheBase.Count < Info.IdleBaseUnitsMaximum);
|
||||||
@@ -885,7 +885,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
ChooseUnitToBuild(queue);
|
ChooseUnitToBuild(queue);
|
||||||
|
|
||||||
if (unit != null && Info.UnitsToBuild.Any(u => u.Key == unit.Name))
|
if (unit != null && Info.UnitsToBuild.Any(u => u.Key == unit.Name))
|
||||||
world.IssueOrder(Order.StartProduction(queue.Actor, unit.Name, 1));
|
World.IssueOrder(Order.StartProduction(queue.Actor, unit.Name, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildUnit(string category, string name)
|
void BuildUnit(string category, string name)
|
||||||
@@ -895,7 +895,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (Map.Rules.Actors[name] != null)
|
if (Map.Rules.Actors[name] != null)
|
||||||
world.IssueOrder(Order.StartProduction(queue.Actor, name, 1));
|
World.IssueOrder(Order.StartProduction(queue.Actor, name, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
@@ -914,7 +914,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
{
|
{
|
||||||
BotDebug("Bot noticed damage {0} {1}->{2}, repairing.",
|
BotDebug("Bot noticed damage {0} {1}->{2}, repairing.",
|
||||||
self, e.PreviousDamageState, e.DamageState);
|
self, e.PreviousDamageState, e.DamageState);
|
||||||
world.IssueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false)
|
World.IssueOrder(new Order("RepairBuilding", self.Owner.PlayerActor, false)
|
||||||
{ TargetActor = self });
|
{ TargetActor = self });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -930,7 +930,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
// Protected harvesters or building
|
// Protected harvesters or building
|
||||||
if ((self.HasTrait<Harvester>() || self.HasTrait<Building>()) &&
|
if ((self.HasTrait<Harvester>() || self.HasTrait<Building>()) &&
|
||||||
p.Stances[e.Attacker.Owner] == Stance.Enemy)
|
Player.Stances[e.Attacker.Owner] == Stance.Enemy)
|
||||||
{
|
{
|
||||||
defenseCenter = e.Attacker.Location;
|
defenseCenter = e.Attacker.Location;
|
||||||
ProtectOwn(e.Attacker);
|
ProtectOwn(e.Attacker);
|
||||||
|
|||||||
@@ -20,40 +20,40 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
public class Squad
|
public class Squad
|
||||||
{
|
{
|
||||||
public List<Actor> units = new List<Actor>();
|
public List<Actor> Units = new List<Actor>();
|
||||||
public SquadType type;
|
public SquadType Type;
|
||||||
|
|
||||||
internal World world;
|
internal World World;
|
||||||
internal HackyAI bot;
|
internal HackyAI Bot;
|
||||||
internal MersenneTwister random;
|
internal MersenneTwister Random;
|
||||||
|
|
||||||
internal Target target;
|
internal Target Target;
|
||||||
internal StateMachine fsm;
|
internal StateMachine FuzzyStateMachine;
|
||||||
|
|
||||||
internal AttackOrFleeFuzzy attackOrFleeFuzzy = new AttackOrFleeFuzzy();
|
internal AttackOrFleeFuzzy AttackOrFleeFuzzy = new AttackOrFleeFuzzy();
|
||||||
|
|
||||||
public Squad(HackyAI bot, SquadType type) : this(bot, type, null) { }
|
public Squad(HackyAI bot, SquadType type) : this(bot, type, null) { }
|
||||||
|
|
||||||
public Squad(HackyAI bot, SquadType type, Actor target)
|
public Squad(HackyAI bot, SquadType type, Actor target)
|
||||||
{
|
{
|
||||||
this.bot = bot;
|
Bot = bot;
|
||||||
this.world = bot.world;
|
World = bot.World;
|
||||||
this.random = bot.random;
|
Random = bot.Random;
|
||||||
this.type = type;
|
Type = type;
|
||||||
this.target = OpenRA.Traits.Target.FromActor(target);
|
Target = Target.FromActor(target);
|
||||||
fsm = new StateMachine();
|
FuzzyStateMachine = new StateMachine();
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case SquadType.Assault:
|
case SquadType.Assault:
|
||||||
case SquadType.Rush:
|
case SquadType.Rush:
|
||||||
fsm.ChangeState(this, new GroundUnitsIdleState(), true);
|
FuzzyStateMachine.ChangeState(this, new GroundUnitsIdleState(), true);
|
||||||
break;
|
break;
|
||||||
case SquadType.Air:
|
case SquadType.Air:
|
||||||
fsm.ChangeState(this, new AirIdleState(), true);
|
FuzzyStateMachine.ChangeState(this, new AirIdleState(), true);
|
||||||
break;
|
break;
|
||||||
case SquadType.Protection:
|
case SquadType.Protection:
|
||||||
fsm.ChangeState(this, new UnitsForProtectionIdleState(), true);
|
FuzzyStateMachine.ChangeState(this, new UnitsForProtectionIdleState(), true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,22 +61,22 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (IsValid)
|
if (IsValid)
|
||||||
fsm.Update(this);
|
FuzzyStateMachine.Update(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsValid { get { return units.Any(); } }
|
public bool IsValid { get { return Units.Any(); } }
|
||||||
|
|
||||||
public Actor Target
|
public Actor TargetActor
|
||||||
{
|
{
|
||||||
get { return target.Actor; }
|
get { return Target.Actor; }
|
||||||
set { target = OpenRA.Traits.Target.FromActor(value); }
|
set { Target = Target.FromActor(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TargetIsValid
|
public bool TargetIsValid
|
||||||
{
|
{
|
||||||
get { return target.IsValidFor(units.FirstOrDefault()) && !target.Actor.HasTrait<Husk>(); }
|
get { return Target.IsValidFor(Units.FirstOrDefault()) && !Target.Actor.HasTrait<Husk>(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public WPos CenterPosition { get { return units.Select(u => u.CenterPosition).Average(); } }
|
public WPos CenterPosition { get { return Units.Select(u => u.CenterPosition).Average(); } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,17 +57,17 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
protected static CPos? FindSafePlace(Squad owner, out Actor detectedEnemyTarget, bool needTarget)
|
protected static CPos? FindSafePlace(Squad owner, out Actor detectedEnemyTarget, bool needTarget)
|
||||||
{
|
{
|
||||||
var world = owner.world;
|
var map = owner.World.Map;
|
||||||
detectedEnemyTarget = null;
|
detectedEnemyTarget = null;
|
||||||
var x = (world.Map.MapSize.X % DangerRadius) == 0 ? world.Map.MapSize.X : world.Map.MapSize.X + DangerRadius;
|
var x = (map.MapSize.X % DangerRadius) == 0 ? map.MapSize.X : map.MapSize.X + DangerRadius;
|
||||||
var y = (world.Map.MapSize.Y % DangerRadius) == 0 ? world.Map.MapSize.Y : world.Map.MapSize.Y + DangerRadius;
|
var y = (map.MapSize.Y % DangerRadius) == 0 ? map.MapSize.Y : map.MapSize.Y + DangerRadius;
|
||||||
|
|
||||||
for (var i = 0; i < x; i += DangerRadius * 2)
|
for (var i = 0; i < x; i += DangerRadius * 2)
|
||||||
{
|
{
|
||||||
for (var j = 0; j < y; j += DangerRadius * 2)
|
for (var j = 0; j < y; j += DangerRadius * 2)
|
||||||
{
|
{
|
||||||
var pos = new CPos(i, j);
|
var pos = new CPos(i, j);
|
||||||
if (NearToPosSafely(owner, owner.world.Map.CenterOfCell(pos), out detectedEnemyTarget))
|
if (NearToPosSafely(owner, map.CenterOfCell(pos), out detectedEnemyTarget))
|
||||||
{
|
{
|
||||||
if (needTarget && detectedEnemyTarget == null)
|
if (needTarget && detectedEnemyTarget == null)
|
||||||
continue;
|
continue;
|
||||||
@@ -89,15 +89,15 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
protected static bool NearToPosSafely(Squad owner, WPos loc, out Actor detectedEnemyTarget)
|
protected static bool NearToPosSafely(Squad owner, WPos loc, out Actor detectedEnemyTarget)
|
||||||
{
|
{
|
||||||
detectedEnemyTarget = null;
|
detectedEnemyTarget = null;
|
||||||
var unitsAroundPos = owner.world.FindActorsInCircle(loc, WRange.FromCells(DangerRadius))
|
var unitsAroundPos = owner.World.FindActorsInCircle(loc, WRange.FromCells(DangerRadius))
|
||||||
.Where(unit => owner.bot.p.Stances[unit.Owner] == Stance.Enemy).ToList();
|
.Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList();
|
||||||
|
|
||||||
if (!unitsAroundPos.Any())
|
if (!unitsAroundPos.Any())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (CountAntiAirUnits(unitsAroundPos) * MissileUnitMultiplier < owner.units.Count)
|
if (CountAntiAirUnits(unitsAroundPos) * MissileUnitMultiplier < owner.Units.Count)
|
||||||
{
|
{
|
||||||
detectedEnemyTarget = unitsAroundPos.Random(owner.random);
|
detectedEnemyTarget = unitsAroundPos.Random(owner.Random);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
// Checks the number of anti air enemies around units
|
// Checks the number of anti air enemies around units
|
||||||
protected virtual bool ShouldFlee(Squad owner)
|
protected virtual bool ShouldFlee(Squad owner)
|
||||||
{
|
{
|
||||||
return base.ShouldFlee(owner, enemies => CountAntiAirUnits(enemies) * MissileUnitMultiplier > owner.units.Count);
|
return base.ShouldFlee(owner, enemies => CountAntiAirUnits(enemies) * MissileUnitMultiplier > owner.Units.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
if (ShouldFlee(owner))
|
if (ShouldFlee(owner))
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new AirFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new AirFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,8 +168,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (e == null)
|
if (e == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
owner.Target = e;
|
owner.TargetActor = e;
|
||||||
owner.fsm.ChangeState(owner, new AirAttackState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new AirAttackState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate(Squad owner) { }
|
public void Deactivate(Squad owner) { }
|
||||||
@@ -186,24 +186,24 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
if (!owner.TargetIsValid)
|
if (!owner.TargetIsValid)
|
||||||
{
|
{
|
||||||
var a = owner.units.Random(owner.random);
|
var a = owner.Units.Random(owner.Random);
|
||||||
var closestEnemy = owner.bot.FindClosestEnemy(a.CenterPosition);
|
var closestEnemy = owner.Bot.FindClosestEnemy(a.CenterPosition);
|
||||||
if (closestEnemy != null)
|
if (closestEnemy != null)
|
||||||
owner.Target = closestEnemy;
|
owner.TargetActor = closestEnemy;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new AirFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new AirFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NearToPosSafely(owner, owner.Target.CenterPosition))
|
if (!NearToPosSafely(owner, owner.TargetActor.CenterPosition))
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new AirFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new AirFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var a in owner.units)
|
foreach (var a in owner.Units)
|
||||||
{
|
{
|
||||||
if (BusyAttack(a))
|
if (BusyAttack(a))
|
||||||
continue;
|
continue;
|
||||||
@@ -214,7 +214,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
{
|
{
|
||||||
if (IsRearm(a))
|
if (IsRearm(a))
|
||||||
continue;
|
continue;
|
||||||
owner.world.IssueOrder(new Order("ReturnToBase", a, false));
|
owner.World.IssueOrder(new Order("ReturnToBase", a, false));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +222,8 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owner.Target.HasTrait<ITargetable>() && CanAttackTarget(a, owner.Target))
|
if (owner.TargetActor.HasTrait<ITargetable>() && CanAttackTarget(a, owner.TargetActor))
|
||||||
owner.world.IssueOrder(new Order("Attack", a, false) { TargetActor = owner.Target });
|
owner.World.IssueOrder(new Order("Attack", a, false) { TargetActor = owner.TargetActor });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,21 +239,21 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!owner.IsValid)
|
if (!owner.IsValid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var a in owner.units)
|
foreach (var a in owner.Units)
|
||||||
{
|
{
|
||||||
if (!ReloadsAutomatically(a) && !FullAmmo(a))
|
if (!ReloadsAutomatically(a) && !FullAmmo(a))
|
||||||
{
|
{
|
||||||
if (IsRearm(a))
|
if (IsRearm(a))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
owner.world.IssueOrder(new Order("ReturnToBase", a, false));
|
owner.World.IssueOrder(new Order("ReturnToBase", a, false));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.world.IssueOrder(new Order("Move", a, false) { TargetLocation = RandomBuildingLocation(owner) });
|
owner.World.IssueOrder(new Order("Move", a, false) { TargetLocation = RandomBuildingLocation(owner) });
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.fsm.ChangeState(owner, new AirIdleState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new AirIdleState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate(Squad owner) { }
|
public void Deactivate(Squad owner) { }
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
{
|
{
|
||||||
protected virtual bool ShouldFlee(Squad owner)
|
protected virtual bool ShouldFlee(Squad owner)
|
||||||
{
|
{
|
||||||
return base.ShouldFlee(owner, enemies => !owner.attackOrFleeFuzzy.CanAttack(owner.units, enemies));
|
return base.ShouldFlee(owner, enemies => !owner.AttackOrFleeFuzzy.CanAttack(owner.Units, enemies));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,27 +32,27 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
if (!owner.TargetIsValid)
|
if (!owner.TargetIsValid)
|
||||||
{
|
{
|
||||||
var t = owner.bot.FindClosestEnemy(owner.units.FirstOrDefault().CenterPosition);
|
var t = owner.Bot.FindClosestEnemy(owner.Units.FirstOrDefault().CenterPosition);
|
||||||
if (t == null) return;
|
if (t == null) return;
|
||||||
owner.Target = t;
|
owner.TargetActor = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
var enemyUnits = owner.world.FindActorsInCircle(owner.Target.CenterPosition, WRange.FromCells(10))
|
var enemyUnits = owner.World.FindActorsInCircle(owner.TargetActor.CenterPosition, WRange.FromCells(10))
|
||||||
.Where(unit => owner.bot.p.Stances[unit.Owner] == Stance.Enemy).ToList();
|
.Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList();
|
||||||
|
|
||||||
if (enemyUnits.Any())
|
if (enemyUnits.Any())
|
||||||
{
|
{
|
||||||
if (owner.attackOrFleeFuzzy.CanAttack(owner.units, enemyUnits))
|
if (owner.AttackOrFleeFuzzy.CanAttack(owner.Units, enemyUnits))
|
||||||
{
|
{
|
||||||
foreach (var u in owner.units)
|
foreach (var u in owner.Units)
|
||||||
owner.world.IssueOrder(new Order("AttackMove", u, false) { TargetLocation = owner.Target.Location });
|
owner.World.IssueOrder(new Order("AttackMove", u, false) { TargetLocation = owner.TargetActor.Location });
|
||||||
|
|
||||||
// We have gathered sufficient units. Attack the nearest enemy unit.
|
// We have gathered sufficient units. Attack the nearest enemy unit.
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsAttackMoveState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsAttackMoveState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,46 +70,46 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
if (!owner.TargetIsValid)
|
if (!owner.TargetIsValid)
|
||||||
{
|
{
|
||||||
var closestEnemy = owner.bot.FindClosestEnemy(owner.units.Random(owner.random).CenterPosition);
|
var closestEnemy = owner.Bot.FindClosestEnemy(owner.Units.Random(owner.Random).CenterPosition);
|
||||||
if (closestEnemy != null)
|
if (closestEnemy != null)
|
||||||
owner.Target = closestEnemy;
|
owner.TargetActor = closestEnemy;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var leader = owner.units.ClosestTo(owner.Target.CenterPosition);
|
var leader = owner.Units.ClosestTo(owner.TargetActor.CenterPosition);
|
||||||
if (leader == null)
|
if (leader == null)
|
||||||
return;
|
return;
|
||||||
var ownUnits = owner.world.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(owner.units.Count) / 3)
|
var ownUnits = owner.World.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(owner.Units.Count) / 3)
|
||||||
.Where(a => a.Owner == owner.units.FirstOrDefault().Owner && owner.units.Contains(a)).ToList();
|
.Where(a => a.Owner == owner.Units.FirstOrDefault().Owner && owner.Units.Contains(a)).ToList();
|
||||||
if (ownUnits.Count < owner.units.Count)
|
if (ownUnits.Count < owner.Units.Count)
|
||||||
{
|
{
|
||||||
owner.world.IssueOrder(new Order("Stop", leader, false));
|
owner.World.IssueOrder(new Order("Stop", leader, false));
|
||||||
foreach (var unit in owner.units.Where(a => !ownUnits.Contains(a)))
|
foreach (var unit in owner.Units.Where(a => !ownUnits.Contains(a)))
|
||||||
owner.world.IssueOrder(new Order("AttackMove", unit, false) { TargetLocation = leader.Location });
|
owner.World.IssueOrder(new Order("AttackMove", unit, false) { TargetLocation = leader.Location });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var enemies = owner.world.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(12))
|
var enemies = owner.World.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(12))
|
||||||
.Where(a1 => !a1.Destroyed && !a1.IsDead).ToList();
|
.Where(a1 => !a1.Destroyed && !a1.IsDead).ToList();
|
||||||
var enemynearby = enemies.Where(a1 => a1.HasTrait<ITargetable>() && leader.Owner.Stances[a1.Owner] == Stance.Enemy).ToList();
|
var enemynearby = enemies.Where(a1 => a1.HasTrait<ITargetable>() && leader.Owner.Stances[a1.Owner] == Stance.Enemy).ToList();
|
||||||
if (enemynearby.Any())
|
if (enemynearby.Any())
|
||||||
{
|
{
|
||||||
owner.Target = enemynearby.ClosestTo(leader.CenterPosition);
|
owner.TargetActor = enemynearby.ClosestTo(leader.CenterPosition);
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsAttackState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsAttackState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
foreach (var a in owner.units)
|
foreach (var a in owner.Units)
|
||||||
owner.world.IssueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.Target.Location });
|
owner.World.IssueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.TargetActor.Location });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShouldFlee(owner))
|
if (ShouldFlee(owner))
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,23 +128,23 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
if (!owner.TargetIsValid)
|
if (!owner.TargetIsValid)
|
||||||
{
|
{
|
||||||
var closestEnemy = owner.bot.FindClosestEnemy(owner.units.Random(owner.random).CenterPosition);
|
var closestEnemy = owner.Bot.FindClosestEnemy(owner.Units.Random(owner.Random).CenterPosition);
|
||||||
if (closestEnemy != null)
|
if (closestEnemy != null)
|
||||||
owner.Target = closestEnemy;
|
owner.TargetActor = closestEnemy;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var a in owner.units)
|
foreach (var a in owner.Units)
|
||||||
if (!BusyAttack(a))
|
if (!BusyAttack(a))
|
||||||
owner.world.IssueOrder(new Order("Attack", a, false) { TargetActor = owner.bot.FindClosestEnemy(a.CenterPosition) });
|
owner.World.IssueOrder(new Order("Attack", a, false) { TargetActor = owner.Bot.FindClosestEnemy(a.CenterPosition) });
|
||||||
|
|
||||||
if (ShouldFlee(owner))
|
if (ShouldFlee(owner))
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,9 +162,9 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
GoToRandomOwnBuilding(owner);
|
GoToRandomOwnBuilding(owner);
|
||||||
owner.fsm.ChangeState(owner, new GroundUnitsIdleState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new GroundUnitsIdleState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate(Squad owner) { owner.units.Clear(); }
|
public void Deactivate(Squad owner) { owner.Units.Clear(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
class UnitsForProtectionIdleState : GroundStateBase, IState
|
class UnitsForProtectionIdleState : GroundStateBase, IState
|
||||||
{
|
{
|
||||||
public void Activate(Squad owner) { }
|
public void Activate(Squad owner) { }
|
||||||
public void Tick(Squad owner) { owner.fsm.ChangeState(owner, new UnitsForProtectionAttackState(), true); }
|
public void Tick(Squad owner) { owner.FuzzyStateMachine.ChangeState(owner, new UnitsForProtectionAttackState(), true); }
|
||||||
public void Deactivate(Squad owner) { }
|
public void Deactivate(Squad owner) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,17 +28,17 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
|
|
||||||
if (!owner.TargetIsValid)
|
if (!owner.TargetIsValid)
|
||||||
{
|
{
|
||||||
owner.Target = owner.bot.FindClosestEnemy(owner.CenterPosition, WRange.FromCells(8));
|
owner.TargetActor = owner.Bot.FindClosestEnemy(owner.CenterPosition, WRange.FromCells(8));
|
||||||
|
|
||||||
if (owner.Target == null)
|
if (owner.TargetActor == null)
|
||||||
{
|
{
|
||||||
owner.fsm.ChangeState(owner, new UnitsForProtectionFleeState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new UnitsForProtectionFleeState(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var a in owner.units)
|
foreach (var a in owner.Units)
|
||||||
owner.world.IssueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.Target.Location });
|
owner.World.IssueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.TargetActor.Location });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate(Squad owner) { }
|
public void Deactivate(Squad owner) { }
|
||||||
@@ -54,9 +54,9 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
GoToRandomOwnBuilding(owner);
|
GoToRandomOwnBuilding(owner);
|
||||||
owner.fsm.ChangeState(owner, new UnitsForProtectionIdleState(), true);
|
owner.FuzzyStateMachine.ChangeState(owner, new UnitsForProtectionIdleState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate(Squad owner) { owner.units.Clear(); }
|
public void Deactivate(Squad owner) { owner.Units.Clear(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,17 +26,17 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
protected static void GoToRandomOwnBuilding(Squad squad)
|
protected static void GoToRandomOwnBuilding(Squad squad)
|
||||||
{
|
{
|
||||||
var loc = RandomBuildingLocation(squad);
|
var loc = RandomBuildingLocation(squad);
|
||||||
foreach (var a in squad.units)
|
foreach (var a in squad.Units)
|
||||||
squad.world.IssueOrder(new Order("Move", a, false) { TargetLocation = loc });
|
squad.World.IssueOrder(new Order("Move", a, false) { TargetLocation = loc });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static CPos RandomBuildingLocation(Squad squad)
|
protected static CPos RandomBuildingLocation(Squad squad)
|
||||||
{
|
{
|
||||||
var location = squad.bot.baseCenter;
|
var location = squad.Bot.BaseCenter;
|
||||||
var buildings = squad.world.ActorsWithTrait<Building>()
|
var buildings = squad.World.ActorsWithTrait<Building>()
|
||||||
.Where(a => a.Actor.Owner == squad.bot.p).Select(a => a.Actor).ToArray();
|
.Where(a => a.Actor.Owner == squad.Bot.Player).Select(a => a.Actor).ToArray();
|
||||||
if (buildings.Length > 0)
|
if (buildings.Length > 0)
|
||||||
location = buildings.Random(squad.random).Location;
|
location = buildings.Random(squad.Random).Location;
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,13 +82,13 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!squad.IsValid)
|
if (!squad.IsValid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var u = squad.units.Random(squad.random);
|
var u = squad.Units.Random(squad.Random);
|
||||||
var units = squad.world.FindActorsInCircle(u.CenterPosition, WRange.FromCells(DangerRadius)).ToList();
|
var units = squad.World.FindActorsInCircle(u.CenterPosition, WRange.FromCells(DangerRadius)).ToList();
|
||||||
var ownBaseBuildingAround = units.Where(unit => unit.Owner == squad.bot.p && unit.HasTrait<Building>());
|
var ownBaseBuildingAround = units.Where(unit => unit.Owner == squad.Bot.Player && unit.HasTrait<Building>());
|
||||||
if (ownBaseBuildingAround.Any())
|
if (ownBaseBuildingAround.Any())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var enemyAroundUnit = units.Where(unit => squad.bot.p.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait<AttackBase>());
|
var enemyAroundUnit = units.Where(unit => squad.Bot.Player.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait<AttackBase>());
|
||||||
if (!enemyAroundUnit.Any())
|
if (!enemyAroundUnit.Any())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
[FieldLoader.LoadUsing("LoadConsiderations")]
|
[FieldLoader.LoadUsing("LoadConsiderations")]
|
||||||
[Desc("The decisions associated with this power")]
|
[Desc("The decisions associated with this power")]
|
||||||
readonly List<Consideration> Considerations = new List<Consideration>();
|
public readonly List<Consideration> Considerations = new List<Consideration>();
|
||||||
|
|
||||||
[Desc("Minimum ticks to wait until next Decision scan attempt.")]
|
[Desc("Minimum ticks to wait until next Decision scan attempt.")]
|
||||||
public readonly int MinimumScanTimeInterval = 250;
|
public readonly int MinimumScanTimeInterval = 250;
|
||||||
@@ -93,10 +93,10 @@ namespace OpenRA.Mods.RA
|
|||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetNextScanTime(HackyAI ai) { return ai.random.Next(MinimumScanTimeInterval, MaximumScanTimeInterval); }
|
public int GetNextScanTime(HackyAI ai) { return ai.Random.Next(MinimumScanTimeInterval, MaximumScanTimeInterval); }
|
||||||
|
|
||||||
/// <summary>Makes up part of a decision, describing how to evaluate a target.</summary>
|
/// <summary>Makes up part of a decision, describing how to evaluate a target.</summary>
|
||||||
class Consideration
|
public class Consideration
|
||||||
{
|
{
|
||||||
public enum DecisionMetric { Health, Value, None }
|
public enum DecisionMetric { Health, Value, None }
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
public class Teleport : Activity
|
public class Teleport : Activity
|
||||||
{
|
{
|
||||||
const int maxCellSearchRange = Map.MaxTilesInCircleRange;
|
const int MaxCellSearchRange = Map.MaxTilesInCircleRange;
|
||||||
Actor teleporter;
|
Actor teleporter;
|
||||||
CPos destination;
|
CPos destination;
|
||||||
int? maximumDistance;
|
int? maximumDistance;
|
||||||
@@ -32,8 +32,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
public Teleport(Actor teleporter, CPos destination, int? maximumDistance, bool killCargo, bool screenFlash, string sound)
|
public Teleport(Actor teleporter, CPos destination, int? maximumDistance, bool killCargo, bool screenFlash, string sound)
|
||||||
{
|
{
|
||||||
if (maximumDistance > maxCellSearchRange)
|
if (maximumDistance > MaxCellSearchRange)
|
||||||
throw new InvalidOperationException("Teleport cannot be used with a maximum teleport distance greater than {0}.".F(maxCellSearchRange));
|
throw new InvalidOperationException("Teleport cannot be used with a maximum teleport distance greater than {0}.".F(MaxCellSearchRange));
|
||||||
|
|
||||||
this.teleporter = teleporter;
|
this.teleporter = teleporter;
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (pos.CanEnterCell(destination) && teleporter.Owner.Shroud.IsExplored(destination))
|
if (pos.CanEnterCell(destination) && teleporter.Owner.Shroud.IsExplored(destination))
|
||||||
return destination;
|
return destination;
|
||||||
|
|
||||||
var max = maximumDistance != null ? maximumDistance.Value : maxCellSearchRange;
|
var max = maximumDistance != null ? maximumDistance.Value : MaxCellSearchRange;
|
||||||
foreach (var tile in self.World.Map.FindTilesInCircle(destination, max))
|
foreach (var tile in self.World.Map.FindTilesInCircle(destination, max))
|
||||||
{
|
{
|
||||||
if (teleporter.Owner.Shroud.IsExplored(tile)
|
if (teleporter.Owner.Shroud.IsExplored(tile)
|
||||||
|
|||||||
@@ -30,35 +30,35 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class CashTrickler : ITick, ISync, INotifyCapture
|
class CashTrickler : ITick, ISync, INotifyCapture
|
||||||
{
|
{
|
||||||
|
readonly CashTricklerInfo info;
|
||||||
[Sync] int ticks;
|
[Sync] int ticks;
|
||||||
CashTricklerInfo Info;
|
|
||||||
public CashTrickler(CashTricklerInfo info)
|
public CashTrickler(CashTricklerInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (--ticks < 0)
|
if (--ticks < 0)
|
||||||
{
|
{
|
||||||
ticks = Info.Period;
|
ticks = info.Period;
|
||||||
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(Info.Amount);
|
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(info.Amount);
|
||||||
MaybeAddCashTick(self, Info.Amount);
|
MaybeAddCashTick(self, info.Amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||||
{
|
{
|
||||||
if (Info.CaptureAmount > 0)
|
if (info.CaptureAmount > 0)
|
||||||
{
|
{
|
||||||
newOwner.PlayerActor.Trait<PlayerResources>().GiveCash(Info.CaptureAmount);
|
newOwner.PlayerActor.Trait<PlayerResources>().GiveCash(info.CaptureAmount);
|
||||||
MaybeAddCashTick(self, Info.CaptureAmount);
|
MaybeAddCashTick(self, info.CaptureAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaybeAddCashTick(Actor self, int amount)
|
void MaybeAddCashTick(Actor self, int amount)
|
||||||
{
|
{
|
||||||
if (Info.ShowTicks)
|
if (info.ShowTicks)
|
||||||
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(amount), 30)));
|
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(amount), 30)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
class TeslaZap : IEffect
|
class TeslaZap : IEffect
|
||||||
{
|
{
|
||||||
readonly ProjectileArgs Args;
|
readonly ProjectileArgs args;
|
||||||
readonly TeslaZapInfo Info;
|
readonly TeslaZapInfo info;
|
||||||
TeslaZapRenderable zap;
|
TeslaZapRenderable zap;
|
||||||
int timeUntilRemove = 2; // # of frames
|
int timeUntilRemove = 2; // # of frames
|
||||||
bool doneDamage = false;
|
bool doneDamage = false;
|
||||||
@@ -37,8 +37,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
public TeslaZap(TeslaZapInfo info, ProjectileArgs args)
|
public TeslaZap(TeslaZapInfo info, ProjectileArgs args)
|
||||||
{
|
{
|
||||||
Args = args;
|
this.args = args;
|
||||||
Info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
@@ -48,8 +48,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
if (!doneDamage)
|
if (!doneDamage)
|
||||||
{
|
{
|
||||||
var pos = Args.GuidedTarget.IsValidFor(Args.SourceActor) ? Args.GuidedTarget.CenterPosition : Args.PassiveTarget;
|
var pos = args.GuidedTarget.IsValidFor(args.SourceActor) ? args.GuidedTarget.CenterPosition : args.PassiveTarget;
|
||||||
Args.Weapon.Impact(Target.FromPos(pos), Args.SourceActor, Args.DamageModifiers);
|
args.Weapon.Impact(Target.FromPos(pos), args.SourceActor, args.DamageModifiers);
|
||||||
doneDamage = true;
|
doneDamage = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,8 +58,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
var pos = Args.GuidedTarget.IsValidFor(Args.SourceActor) ? Args.GuidedTarget.CenterPosition : Args.PassiveTarget;
|
var pos = args.GuidedTarget.IsValidFor(args.SourceActor) ? args.GuidedTarget.CenterPosition : args.PassiveTarget;
|
||||||
zap = new TeslaZapRenderable(Args.Source, 0, pos - Args.Source, Info.Image, Info.BrightZaps, Info.DimZaps, Info.Palette);
|
zap = new TeslaZapRenderable(args.Source, 0, pos - args.Source, info.Image, info.BrightZaps, info.DimZaps, info.Palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return zap;
|
yield return zap;
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public class CheckActorReferences : ILintPass
|
public class CheckActorReferences : ILintPass
|
||||||
{
|
{
|
||||||
Action<string> EmitError;
|
Action<string> emitError;
|
||||||
|
|
||||||
public void Run(Action<string> emitError, Action<string> emitWarning, Map map)
|
public void Run(Action<string> emitError, Action<string> emitWarning, Map map)
|
||||||
{
|
{
|
||||||
EmitError = emitError;
|
this.emitError = emitError;
|
||||||
|
|
||||||
foreach (var actorInfo in map.Rules.Actors)
|
foreach (var actorInfo in map.Rules.Actors)
|
||||||
foreach (var traitInfo in actorInfo.Value.Traits.WithInterface<ITraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.Traits.WithInterface<ITraitInfo>())
|
||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (type == typeof(string[]))
|
if (type == typeof(string[]))
|
||||||
return (string[])fieldInfo.GetValue(traitInfo);
|
return (string[])fieldInfo.GetValue(traitInfo);
|
||||||
|
|
||||||
EmitError("Bad type for reference on {0}.{1}. Supported types: string, string[]"
|
emitError("Bad type for reference on {0}.{1}. Supported types: string, string[]"
|
||||||
.F(traitInfo.GetType().Name, fieldInfo.Name));
|
.F(traitInfo.GetType().Name, fieldInfo.Name));
|
||||||
|
|
||||||
return new string[] { };
|
return new string[] { };
|
||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA
|
|||||||
var values = GetFieldValues(traitInfo, fieldInfo);
|
var values = GetFieldValues(traitInfo, fieldInfo);
|
||||||
foreach (var v in values)
|
foreach (var v in values)
|
||||||
if (v != null && !dict.ContainsKey(v.ToLowerInvariant()))
|
if (v != null && !dict.ContainsKey(v.ToLowerInvariant()))
|
||||||
EmitError("{0}.{1}.{2}: Missing {3} `{4}`."
|
emitError("{0}.{1}.{2}: Missing {3} `{4}`."
|
||||||
.F(actorInfo.Name, traitInfo.GetType().Name, fieldInfo.Name, type, v));
|
.F(actorInfo.Name, traitInfo.GetType().Name, fieldInfo.Name, type, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
{
|
{
|
||||||
public class PlaceBuildingOrderGenerator : IOrderGenerator
|
public class PlaceBuildingOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
readonly Actor Producer;
|
readonly Actor producer;
|
||||||
readonly string Building;
|
readonly string building;
|
||||||
readonly BuildingInfo BuildingInfo;
|
readonly BuildingInfo buildingInfo;
|
||||||
IActorPreview[] preview;
|
IActorPreview[] preview;
|
||||||
|
|
||||||
Sprite buildOk, buildBlocked;
|
Sprite buildOk, buildBlocked;
|
||||||
@@ -32,12 +32,12 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
|
|
||||||
public PlaceBuildingOrderGenerator(ProductionQueue queue, string name)
|
public PlaceBuildingOrderGenerator(ProductionQueue queue, string name)
|
||||||
{
|
{
|
||||||
Producer = queue.Actor;
|
producer = queue.Actor;
|
||||||
Building = name;
|
building = name;
|
||||||
|
|
||||||
var map = Producer.World.Map;
|
var map = producer.World.Map;
|
||||||
var tileset = Producer.World.TileSet.Id.ToLowerInvariant();
|
var tileset = producer.World.TileSet.Id.ToLowerInvariant();
|
||||||
BuildingInfo = map.Rules.Actors[Building].Traits.Get<BuildingInfo>();
|
buildingInfo = map.Rules.Actors[building].Traits.Get<BuildingInfo>();
|
||||||
|
|
||||||
buildOk = map.SequenceProvider.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
|
buildOk = map.SequenceProvider.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
|
||||||
buildBlocked = map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
|
buildBlocked = map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
|
||||||
@@ -62,20 +62,20 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
|
|
||||||
if (mi.Button == MouseButton.Left)
|
if (mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
var topLeft = xy - FootprintUtils.AdjustForBuildingSize(BuildingInfo);
|
var topLeft = xy - FootprintUtils.AdjustForBuildingSize(buildingInfo);
|
||||||
if (!world.CanPlaceBuilding(Building, BuildingInfo, topLeft, null)
|
if (!world.CanPlaceBuilding(building, buildingInfo, topLeft, null)
|
||||||
|| !BuildingInfo.IsCloseEnoughToBase(world, Producer.Owner, Building, topLeft))
|
|| !buildingInfo.IsCloseEnoughToBase(world, producer.Owner, building, topLeft))
|
||||||
{
|
{
|
||||||
Sound.PlayNotification(world.Map.Rules, Producer.Owner, "Speech", "BuildingCannotPlaceAudio", Producer.Owner.Country.Race);
|
Sound.PlayNotification(world.Map.Rules, producer.Owner, "Speech", "BuildingCannotPlaceAudio", producer.Owner.Country.Race);
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isLineBuild = world.Map.Rules.Actors[Building].Traits.Contains<LineBuildInfo>();
|
var isLineBuild = world.Map.Rules.Actors[building].Traits.Contains<LineBuildInfo>();
|
||||||
yield return new Order(isLineBuild ? "LineBuild" : "PlaceBuilding", Producer.Owner.PlayerActor, false)
|
yield return new Order(isLineBuild ? "LineBuild" : "PlaceBuilding", producer.Owner.PlayerActor, false)
|
||||||
{
|
{
|
||||||
TargetLocation = topLeft,
|
TargetLocation = topLeft,
|
||||||
TargetActor = Producer,
|
TargetActor = producer,
|
||||||
TargetString = Building,
|
TargetString = building,
|
||||||
SuppressVisualFeedback = true
|
SuppressVisualFeedback = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -94,11 +94,11 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr, World world)
|
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr, World world)
|
||||||
{
|
{
|
||||||
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
|
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
|
||||||
var topLeft = xy - FootprintUtils.AdjustForBuildingSize(BuildingInfo);
|
var topLeft = xy - FootprintUtils.AdjustForBuildingSize(buildingInfo);
|
||||||
|
|
||||||
var rules = world.Map.Rules;
|
var rules = world.Map.Rules;
|
||||||
|
|
||||||
var actorInfo = rules.Actors[Building];
|
var actorInfo = rules.Actors[building];
|
||||||
foreach (var dec in actorInfo.Traits.WithInterface<IPlaceBuildingDecoration>())
|
foreach (var dec in actorInfo.Traits.WithInterface<IPlaceBuildingDecoration>())
|
||||||
foreach (var r in dec.Render(wr, world, actorInfo, world.Map.CenterOfCell(xy)))
|
foreach (var r in dec.Render(wr, world, actorInfo, world.Map.CenterOfCell(xy)))
|
||||||
yield return r;
|
yield return r;
|
||||||
@@ -107,20 +107,20 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
|
|
||||||
// Linebuild for walls.
|
// Linebuild for walls.
|
||||||
// Requires a 1x1 footprint
|
// Requires a 1x1 footprint
|
||||||
if (rules.Actors[Building].Traits.Contains<LineBuildInfo>())
|
if (rules.Actors[building].Traits.Contains<LineBuildInfo>())
|
||||||
{
|
{
|
||||||
if (BuildingInfo.Dimensions.X != 1 || BuildingInfo.Dimensions.Y != 1)
|
if (buildingInfo.Dimensions.X != 1 || buildingInfo.Dimensions.Y != 1)
|
||||||
throw new InvalidOperationException("LineBuild requires a 1x1 sized Building");
|
throw new InvalidOperationException("LineBuild requires a 1x1 sized Building");
|
||||||
|
|
||||||
foreach (var t in BuildingUtils.GetLineBuildCells(world, topLeft, Building, BuildingInfo))
|
foreach (var t in BuildingUtils.GetLineBuildCells(world, topLeft, building, buildingInfo))
|
||||||
cells.Add(t, BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, t));
|
cells.Add(t, buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, building, t));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
var init = new ActorPreviewInitializer(rules.Actors[Building], Producer.Owner, wr, new TypeDictionary());
|
var init = new ActorPreviewInitializer(rules.Actors[building], producer.Owner, wr, new TypeDictionary());
|
||||||
preview = rules.Actors[Building].Traits.WithInterface<IRenderActorPreviewInfo>()
|
preview = rules.Actors[building].Traits.WithInterface<IRenderActorPreviewInfo>()
|
||||||
.SelectMany(rpi => rpi.RenderPreview(init))
|
.SelectMany(rpi => rpi.RenderPreview(init))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
}
|
}
|
||||||
|
|
||||||
var comparer = new RenderableComparer(wr);
|
var comparer = new RenderableComparer(wr);
|
||||||
var offset = world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(world, BuildingInfo);
|
var offset = world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(world, buildingInfo);
|
||||||
var previewRenderables = preview
|
var previewRenderables = preview
|
||||||
.SelectMany(p => p.Render(wr, offset))
|
.SelectMany(p => p.Render(wr, offset))
|
||||||
.OrderBy(r => r, comparer);
|
.OrderBy(r => r, comparer);
|
||||||
@@ -137,9 +137,9 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
yield return r;
|
yield return r;
|
||||||
|
|
||||||
var res = world.WorldActor.Trait<ResourceLayer>();
|
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||||
var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
|
var isCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, building, topLeft);
|
||||||
foreach (var t in FootprintUtils.Tiles(rules, Building, BuildingInfo, topLeft))
|
foreach (var t in FootprintUtils.Tiles(rules, building, buildingInfo, topLeft))
|
||||||
cells.Add(t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null);
|
cells.Add(t, isCloseEnough && world.IsCellBuildable(t, buildingInfo) && res.GetResource(t) == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pal = wr.Palette("terrain");
|
var pal = wr.Palette("terrain");
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
AnimationState state;
|
AnimationState state;
|
||||||
|
|
||||||
IRenderInfantrySequenceModifier rsm;
|
IRenderInfantrySequenceModifier rsm;
|
||||||
bool isModifyingSequence { get { return rsm != null && rsm.IsModifyingSequence; } }
|
bool IsModifyingSequence { get { return rsm != null && rsm.IsModifyingSequence; } }
|
||||||
bool wasModifying;
|
bool wasModifying;
|
||||||
|
|
||||||
public RenderInfantry(Actor self, RenderInfantryInfo info)
|
public RenderInfantry(Actor self, RenderInfantryInfo info)
|
||||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
protected virtual string NormalizeInfantrySequence(Actor self, string baseSequence)
|
protected virtual string NormalizeInfantrySequence(Actor self, string baseSequence)
|
||||||
{
|
{
|
||||||
var prefix = isModifyingSequence ? rsm.SequencePrefix : "";
|
var prefix = IsModifyingSequence ? rsm.SequencePrefix : "";
|
||||||
|
|
||||||
if (DefaultAnimation.HasSequence(prefix + baseSequence))
|
if (DefaultAnimation.HasSequence(prefix + baseSequence))
|
||||||
return prefix + baseSequence;
|
return prefix + baseSequence;
|
||||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
protected virtual bool AllowIdleAnimation(Actor self)
|
protected virtual bool AllowIdleAnimation(Actor self)
|
||||||
{
|
{
|
||||||
return !isModifyingSequence;
|
return !IsModifyingSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self, Target target)
|
public void Attacking(Actor self, Target target)
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
class Repairable : IIssueOrder, IResolveOrder, IOrderVoice
|
class Repairable : IIssueOrder, IResolveOrder, IOrderVoice
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly Health Health;
|
readonly Health health;
|
||||||
|
|
||||||
public Repairable(Actor self)
|
public Repairable(Actor self)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
Health = self.Trait<Health>();
|
health = self.Trait<Health>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
bool CanRepair()
|
bool CanRepair()
|
||||||
{
|
{
|
||||||
var li = self.TraitOrDefault<LimitedAmmo>();
|
var li = self.TraitOrDefault<LimitedAmmo>();
|
||||||
return Health.DamageState > DamageState.Undamaged || (li != null && !li.FullAmmo());
|
return health.DamageState > DamageState.Undamaged || (li != null && !li.FullAmmo());
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
readonly ScaredyCatInfo info;
|
readonly ScaredyCatInfo info;
|
||||||
[Sync] readonly Actor self;
|
[Sync] readonly Actor self;
|
||||||
[Sync] int panicStartedTick;
|
[Sync] int panicStartedTick;
|
||||||
bool panicking { get { return panicStartedTick > 0; } }
|
bool Panicking { get { return panicStartedTick > 0; } }
|
||||||
|
|
||||||
public bool IsModifyingSequence { get { return panicking; } }
|
public bool IsModifyingSequence { get { return Panicking; } }
|
||||||
public string SequencePrefix { get { return "panic-"; } }
|
public string SequencePrefix { get { return "panic-"; } }
|
||||||
|
|
||||||
public ScaredyCat(Actor self, ScaredyCatInfo info)
|
public ScaredyCat(Actor self, ScaredyCatInfo info)
|
||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public void Panic()
|
public void Panic()
|
||||||
{
|
{
|
||||||
if (!panicking)
|
if (!Panicking)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
panicStartedTick = self.World.WorldTick;
|
panicStartedTick = self.World.WorldTick;
|
||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (!panicking)
|
if (!Panicking)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (self.World.WorldTick >= panicStartedTick + info.PanicLength)
|
if (self.World.WorldTick >= panicStartedTick + info.PanicLength)
|
||||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public void TickIdle(Actor self)
|
public void TickIdle(Actor self)
|
||||||
{
|
{
|
||||||
if (!panicking)
|
if (!Panicking)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.Trait<Mobile>().Nudge(self, self, true);
|
self.Trait<Mobile>().Nudge(self, self, true);
|
||||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public int GetSpeedModifier()
|
public int GetSpeedModifier()
|
||||||
{
|
{
|
||||||
return panicking ? info.PanicSpeedModifier : 100;
|
return Panicking ? info.PanicSpeedModifier : 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,22 +26,22 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, INotifyKilled, IExplodeModifier, IStoreResources, ISync
|
class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, INotifyKilled, IExplodeModifier, IStoreResources, ISync
|
||||||
{
|
{
|
||||||
readonly StoresResourcesInfo Info;
|
readonly StoresResourcesInfo info;
|
||||||
|
|
||||||
[Sync] public int Stored { get { return Player.ResourceCapacity == 0 ? 0 : Info.Capacity * Player.Resources / Player.ResourceCapacity; } }
|
[Sync] public int Stored { get { return player.ResourceCapacity == 0 ? 0 : info.Capacity * player.Resources / player.ResourceCapacity; } }
|
||||||
|
|
||||||
PlayerResources Player;
|
PlayerResources player;
|
||||||
public StoresResources(Actor self, StoresResourcesInfo info)
|
public StoresResources(Actor self, StoresResourcesInfo info)
|
||||||
{
|
{
|
||||||
Player = self.Owner.PlayerActor.Trait<PlayerResources>();
|
player = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
Info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Capacity { get { return Info.Capacity; } }
|
public int Capacity { get { return info.Capacity; } }
|
||||||
|
|
||||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
{
|
{
|
||||||
Player = newOwner.PlayerActor.Trait<PlayerResources>();
|
player = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||||
@@ -53,14 +53,14 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
Player.TakeResources(Stored); // lose the stored resources
|
player.TakeResources(Stored); // lose the stored resources
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
{
|
{
|
||||||
return Enumerable.Range(0, Info.PipCount).Select(i =>
|
return Enumerable.Range(0, info.PipCount).Select(i =>
|
||||||
Player.Resources * Info.PipCount > i * Player.ResourceCapacity
|
player.Resources * info.PipCount > i * player.ResourceCapacity
|
||||||
? Info.PipColor : PipType.Transparent);
|
? info.PipColor : PipType.Transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShouldExplode(Actor self) { return Stored > 0; }
|
public bool ShouldExplode(Actor self) { return Stored > 0; }
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
|
||||||
return new SelectTarget(self.World, order, manager, this);
|
return new SelectTarget(Self.World, order, manager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
||||||
@@ -78,14 +78,14 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
||||||
{
|
{
|
||||||
var range = info.Range;
|
var range = info.Range;
|
||||||
var tiles = self.World.Map.FindTilesInCircle(xy, range);
|
var tiles = Self.World.Map.FindTilesInCircle(xy, range);
|
||||||
var units = new List<Actor>();
|
var units = new List<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
units.AddRange(self.World.ActorMap.GetUnitsAt(t));
|
units.AddRange(Self.World.ActorMap.GetUnitsAt(t));
|
||||||
|
|
||||||
return units.Distinct().Where(a =>
|
return units.Distinct().Where(a =>
|
||||||
{
|
{
|
||||||
if (!a.Owner.IsAlliedWith(self.Owner))
|
if (!a.Owner.IsAlliedWith(Self.Owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var um = a.TraitOrDefault<UpgradeManager>();
|
var um = a.TraitOrDefault<UpgradeManager>();
|
||||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
{
|
{
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any())
|
if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any())
|
||||||
yield return new Order(order, manager.self, false) { TargetLocation = xy, SuppressVisualFeedback = true };
|
yield return new Order(order, manager.Self, false) { TargetLocation = xy, SuppressVisualFeedback = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
|
||||||
return new SelectGenericPowerTarget(order, manager, "nuke", MouseButton.Left);
|
return new SelectGenericPowerTarget(order, manager, "nuke", MouseButton.Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,14 +49,14 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public class SupportPower
|
public class SupportPower
|
||||||
{
|
{
|
||||||
public readonly Actor self;
|
public readonly Actor Self;
|
||||||
public readonly SupportPowerInfo Info;
|
public readonly SupportPowerInfo Info;
|
||||||
protected RadarPing ping;
|
protected RadarPing ping;
|
||||||
|
|
||||||
public SupportPower(Actor self, SupportPowerInfo info)
|
public SupportPower(Actor self, SupportPowerInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
this.self = self;
|
Self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Charging(Actor self, string key)
|
public virtual void Charging(Actor self, string key)
|
||||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public virtual IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
public virtual IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
|
||||||
return new SelectGenericPowerTarget(order, manager, "ability", MouseButton.Left);
|
return new SelectGenericPowerTarget(order, manager, "ability", MouseButton.Left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public class SupportPowerManager : ITick, IResolveOrder, ITechTreeElement
|
public class SupportPowerManager : ITick, IResolveOrder, ITechTreeElement
|
||||||
{
|
{
|
||||||
public readonly Actor self;
|
public readonly Actor Self;
|
||||||
public readonly Dictionary<string, SupportPowerInstance> Powers = new Dictionary<string, SupportPowerInstance>();
|
public readonly Dictionary<string, SupportPowerInstance> Powers = new Dictionary<string, SupportPowerInstance>();
|
||||||
|
|
||||||
public readonly DeveloperMode DevMode;
|
public readonly DeveloperMode DevMode;
|
||||||
@@ -34,9 +34,9 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public SupportPowerManager(ActorInitializer init)
|
public SupportPowerManager(ActorInitializer init)
|
||||||
{
|
{
|
||||||
self = init.Self;
|
Self = init.Self;
|
||||||
DevMode = self.Trait<DeveloperMode>();
|
DevMode = Self.Trait<DeveloperMode>();
|
||||||
TechTree = self.Trait<TechTree>();
|
TechTree = Self.Trait<TechTree>();
|
||||||
RadarPings = Exts.Lazy(() => init.World.WorldActor.TraitOrDefault<RadarPings>());
|
RadarPings = Exts.Lazy(() => init.World.WorldActor.TraitOrDefault<RadarPings>());
|
||||||
|
|
||||||
init.World.ActorAdded += ActorAdded;
|
init.World.ActorAdded += ActorAdded;
|
||||||
@@ -45,12 +45,12 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
static string MakeKey(SupportPower sp)
|
static string MakeKey(SupportPower sp)
|
||||||
{
|
{
|
||||||
return sp.Info.AllowMultiple ? sp.Info.OrderName + "_" + sp.self.ActorID : sp.Info.OrderName;
|
return sp.Info.AllowMultiple ? sp.Info.OrderName + "_" + sp.Self.ActorID : sp.Info.OrderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorAdded(Actor a)
|
void ActorAdded(Actor a)
|
||||||
{
|
{
|
||||||
if (a.Owner != self.Owner)
|
if (a.Owner != Self.Owner)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var t in a.TraitsImplementing<SupportPower>())
|
foreach (var t in a.TraitsImplementing<SupportPower>())
|
||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
void ActorRemoved(Actor a)
|
void ActorRemoved(Actor a)
|
||||||
{
|
{
|
||||||
if (a.Owner != self.Owner || !a.HasTrait<SupportPower>())
|
if (a.Owner != Self.Owner || !a.HasTrait<SupportPower>())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var t in a.TraitsImplementing<SupportPower>())
|
foreach (var t in a.TraitsImplementing<SupportPower>())
|
||||||
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public IEnumerable<SupportPowerInstance> GetPowersForActor(Actor a)
|
public IEnumerable<SupportPowerInstance> GetPowersForActor(Actor a)
|
||||||
{
|
{
|
||||||
if (a.Owner != self.Owner || !a.HasTrait<SupportPower>())
|
if (a.Owner != Self.Owner || !a.HasTrait<SupportPower>())
|
||||||
return NoInstances;
|
return NoInstances;
|
||||||
|
|
||||||
return a.TraitsImplementing<SupportPower>()
|
return a.TraitsImplementing<SupportPower>()
|
||||||
@@ -152,8 +152,8 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public class SupportPowerInstance
|
public class SupportPowerInstance
|
||||||
{
|
{
|
||||||
readonly SupportPowerManager Manager;
|
readonly SupportPowerManager manager;
|
||||||
readonly string Key;
|
readonly string key;
|
||||||
|
|
||||||
public List<SupportPower> Instances;
|
public List<SupportPower> Instances;
|
||||||
public int RemainingTime;
|
public int RemainingTime;
|
||||||
@@ -166,41 +166,41 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public SupportPowerInstance(string key, SupportPowerManager manager)
|
public SupportPowerInstance(string key, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Manager = manager;
|
this.manager = manager;
|
||||||
Key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool InstanceDisabled(SupportPower sp)
|
static bool InstanceDisabled(SupportPower sp)
|
||||||
{
|
{
|
||||||
return sp.self.TraitsImplementing<IDisable>().Any(d => d.Disabled);
|
return sp.Self.TraitsImplementing<IDisable>().Any(d => d.Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool notifiedCharging;
|
bool notifiedCharging;
|
||||||
bool notifiedReady;
|
bool notifiedReady;
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
Active = !Disabled && Instances.Any(i => !i.self.IsDisabled());
|
Active = !Disabled && Instances.Any(i => !i.Self.IsDisabled());
|
||||||
if (!Active)
|
if (!Active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Active)
|
if (Active)
|
||||||
{
|
{
|
||||||
var power = Instances.First();
|
var power = Instances.First();
|
||||||
if (Manager.DevMode.FastCharge && RemainingTime > 25)
|
if (manager.DevMode.FastCharge && RemainingTime > 25)
|
||||||
RemainingTime = 25;
|
RemainingTime = 25;
|
||||||
|
|
||||||
if (RemainingTime > 0)
|
if (RemainingTime > 0)
|
||||||
--RemainingTime;
|
--RemainingTime;
|
||||||
if (!notifiedCharging)
|
if (!notifiedCharging)
|
||||||
{
|
{
|
||||||
power.Charging(power.self, Key);
|
power.Charging(power.Self, key);
|
||||||
notifiedCharging = true;
|
notifiedCharging = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RemainingTime == 0
|
if (RemainingTime == 0
|
||||||
&& !notifiedReady)
|
&& !notifiedReady)
|
||||||
{
|
{
|
||||||
power.Charged(power.self, Key);
|
power.Charged(power.Self, key);
|
||||||
notifiedReady = true;
|
notifiedReady = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
if (!Ready)
|
if (!Ready)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Manager.self.World.OrderGenerator = Instances.First().OrderGenerator(Key, Manager);
|
manager.Self.World.OrderGenerator = Instances.First().OrderGenerator(key, manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Order order)
|
public void Activate(Order order)
|
||||||
@@ -222,7 +222,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
var power = Instances.First(i => !InstanceDisabled(i));
|
var power = Instances.First(i => !InstanceDisabled(i));
|
||||||
|
|
||||||
// Note: order.Subject is the *player* actor
|
// Note: order.Subject is the *player* actor
|
||||||
power.Activate(power.self, order, Manager);
|
power.Activate(power.Self, order, manager);
|
||||||
RemainingTime = TotalTime;
|
RemainingTime = TotalTime;
|
||||||
notifiedCharging = notifiedReady = false;
|
notifiedCharging = notifiedReady = false;
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
{
|
{
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
if (mi.Button == expectedButton && world.Map.Contains(xy))
|
if (mi.Button == expectedButton && world.Map.Contains(xy))
|
||||||
yield return new Order(order, manager.self, false) { TargetLocation = xy, SuppressVisualFeedback = true };
|
yield return new Order(order, manager.Self, false) { TargetLocation = xy, SuppressVisualFeedback = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Tick(World world)
|
public virtual void Tick(World world)
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
{
|
{
|
||||||
readonly TakeCoverInfo info;
|
readonly TakeCoverInfo info;
|
||||||
[Sync] int remainingProneTime = 0;
|
[Sync] int remainingProneTime = 0;
|
||||||
bool isProne { get { return remainingProneTime > 0; } }
|
bool IsProne { get { return remainingProneTime > 0; } }
|
||||||
|
|
||||||
public bool IsModifyingSequence { get { return isProne; } }
|
public bool IsModifyingSequence { get { return IsProne; } }
|
||||||
public string SequencePrefix { get { return info.ProneSequencePrefix; } }
|
public string SequencePrefix { get { return info.ProneSequencePrefix; } }
|
||||||
|
|
||||||
public TakeCover(ActorInitializer init, TakeCoverInfo info)
|
public TakeCover(ActorInitializer init, TakeCoverInfo info)
|
||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
/* Don't go prone when healed */
|
/* Don't go prone when healed */
|
||||||
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne))
|
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne))
|
||||||
{
|
{
|
||||||
if (!isProne)
|
if (!IsProne)
|
||||||
localOffset = info.ProneOffset;
|
localOffset = info.ProneOffset;
|
||||||
|
|
||||||
remainingProneTime = info.ProneTime;
|
remainingProneTime = info.ProneTime;
|
||||||
@@ -61,18 +61,18 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
{
|
{
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
|
|
||||||
if (isProne && --remainingProneTime == 0)
|
if (IsProne && --remainingProneTime == 0)
|
||||||
localOffset = WVec.Zero;
|
localOffset = WVec.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
||||||
{
|
{
|
||||||
return isProne && warhead != null ? warhead.ProneModifier : 100;
|
return IsProne && warhead != null ? warhead.ProneModifier : 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetSpeedModifier()
|
public int GetSpeedModifier()
|
||||||
{
|
{
|
||||||
return isProne ? info.SpeedModifier : 100;
|
return IsProne ? info.SpeedModifier : 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
public class OreRefinery : ITick, IAcceptOre, INotifyKilled, INotifySold, INotifyCapture, INotifyOwnerChanged, IExplodeModifier, ISync
|
public class OreRefinery : ITick, IAcceptOre, INotifyKilled, INotifySold, INotifyCapture, INotifyOwnerChanged, IExplodeModifier, ISync
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly OreRefineryInfo Info;
|
readonly OreRefineryInfo info;
|
||||||
PlayerResources PlayerResources;
|
PlayerResources playerResources;
|
||||||
|
|
||||||
int currentDisplayTick = 0;
|
int currentDisplayTick = 0;
|
||||||
int currentDisplayValue = 0;
|
int currentDisplayValue = 0;
|
||||||
@@ -48,16 +48,16 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
[Sync] bool preventDock = false;
|
[Sync] bool preventDock = false;
|
||||||
|
|
||||||
public bool AllowDocking { get { return !preventDock; } }
|
public bool AllowDocking { get { return !preventDock; } }
|
||||||
public CVec DeliverOffset { get { return Info.DockOffset; } }
|
public CVec DeliverOffset { get { return info.DockOffset; } }
|
||||||
|
|
||||||
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, Info.DockAngle); }
|
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, info.DockAngle); }
|
||||||
|
|
||||||
public OreRefinery(Actor self, OreRefineryInfo info)
|
public OreRefinery(Actor self, OreRefineryInfo info)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
Info = info;
|
this.info = info;
|
||||||
PlayerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
currentDisplayTick = Info.TickRate;
|
currentDisplayTick = info.TickRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters()
|
public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters()
|
||||||
@@ -66,12 +66,12 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
.Where(a => a.Trait.LinkedProc == self);
|
.Where(a => a.Trait.LinkedProc == self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanGiveOre(int amount) { return PlayerResources.CanGiveResources(amount); }
|
public bool CanGiveOre(int amount) { return playerResources.CanGiveResources(amount); }
|
||||||
|
|
||||||
public void GiveOre(int amount)
|
public void GiveOre(int amount)
|
||||||
{
|
{
|
||||||
PlayerResources.GiveResources(amount);
|
playerResources.GiveResources(amount);
|
||||||
if (Info.ShowTicks)
|
if (info.ShowTicks)
|
||||||
currentDisplayValue += amount;
|
currentDisplayValue += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,12 +93,12 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
dockedHarv = null;
|
dockedHarv = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Info.ShowTicks && currentDisplayValue > 0 && --currentDisplayTick <= 0)
|
if (info.ShowTicks && currentDisplayValue > 0 && --currentDisplayTick <= 0)
|
||||||
{
|
{
|
||||||
var temp = currentDisplayValue;
|
var temp = currentDisplayValue;
|
||||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||||
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(temp), 30)));
|
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(temp), 30)));
|
||||||
currentDisplayTick = Info.TickRate;
|
currentDisplayTick = info.TickRate;
|
||||||
currentDisplayValue = 0;
|
currentDisplayValue = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
foreach (var harv in GetLinkedHarvesters())
|
foreach (var harv in GetLinkedHarvesters())
|
||||||
harv.Trait.UnlinkProc(harv.Actor, self);
|
harv.Trait.UnlinkProc(harv.Actor, self);
|
||||||
|
|
||||||
PlayerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common;
|
using OpenRA.Mods.Common;
|
||||||
using OpenRA.Mods.RA.Effects;
|
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Mods.RA.Effects;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Traits
|
namespace OpenRA.Mods.RA.Traits
|
||||||
@@ -38,13 +38,13 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
public int RepairersHash { get { return Repairers.Aggregate(0, (code, player) => code ^ Sync.HashPlayer(player)); } }
|
public int RepairersHash { get { return Repairers.Aggregate(0, (code, player) => code ^ Sync.HashPlayer(player)); } }
|
||||||
public List<Player> Repairers = new List<Player>();
|
public List<Player> Repairers = new List<Player>();
|
||||||
|
|
||||||
Health Health;
|
readonly Health health;
|
||||||
public bool RepairActive = false;
|
public bool RepairActive = false;
|
||||||
|
|
||||||
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
|
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
Health = self.Trait<Health>();
|
health = self.Trait<Health>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RepairBuilding(Actor self, Player player)
|
public void RepairBuilding(Actor self, Player player)
|
||||||
@@ -91,8 +91,8 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
var buildingValue = self.GetSellValue();
|
var buildingValue = self.GetSellValue();
|
||||||
|
|
||||||
// The cost is the same regardless of the amount of people repairing
|
// The cost is the same regardless of the amount of people repairing
|
||||||
var hpToRepair = Math.Min(Info.RepairStep, Health.MaxHP - Health.HP);
|
var hpToRepair = Math.Min(Info.RepairStep, health.MaxHP - health.HP);
|
||||||
var cost = Math.Max(1, (hpToRepair * Info.RepairPercent * buildingValue) / (Health.MaxHP * 100));
|
var cost = Math.Max(1, (hpToRepair * Info.RepairPercent * buildingValue) / (health.MaxHP * 100));
|
||||||
|
|
||||||
// TakeCash will return false if the player can't pay, and will stop him from contributing this Tick
|
// TakeCash will return false if the player can't pay, and will stop him from contributing this Tick
|
||||||
var activePlayers = Repairers.Count(player => player.PlayerActor.Trait<PlayerResources>().TakeCash(cost));
|
var activePlayers = Repairers.Count(player => player.PlayerActor.Trait<PlayerResources>().TakeCash(cost));
|
||||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
// to the length of the array
|
// to the length of the array
|
||||||
self.InflictDamage(self, -(hpToRepair * Info.RepairBonuses[activePlayers - 1] / 100), null);
|
self.InflictDamage(self, -(hpToRepair * Info.RepairBonuses[activePlayers - 1] / 100), null);
|
||||||
|
|
||||||
if (Health.DamageState == DamageState.Undamaged)
|
if (health.DamageState == DamageState.Undamaged)
|
||||||
{
|
{
|
||||||
Repairers.Clear();
|
Repairers.Clear();
|
||||||
RepairActive = false;
|
RepairActive = false;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync,
|
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync,
|
||||||
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove
|
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove
|
||||||
{
|
{
|
||||||
readonly HarvesterInfo Info;
|
readonly HarvesterInfo info;
|
||||||
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
|
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
|
||||||
|
|
||||||
[Sync] public Actor OwnerLinkedProc = null;
|
[Sync] public Actor OwnerLinkedProc = null;
|
||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public Harvester(Actor self, HarvesterInfo info)
|
public Harvester(Actor self, HarvesterInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
this.info = info;
|
||||||
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +107,8 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
bool IsAcceptableProcType(Actor proc)
|
bool IsAcceptableProcType(Actor proc)
|
||||||
{
|
{
|
||||||
return Info.DeliveryBuildings.Length == 0 ||
|
return info.DeliveryBuildings.Length == 0 ||
|
||||||
Info.DeliveryBuildings.Contains(proc.Info.Name);
|
info.DeliveryBuildings.Contains(proc.Info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor ClosestProc(Actor self, Actor ignore)
|
Actor ClosestProc(Actor self, Actor ignore)
|
||||||
@@ -146,9 +146,9 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFull { get { return contents.Values.Sum() == Info.Capacity; } }
|
public bool IsFull { get { return contents.Values.Sum() == info.Capacity; } }
|
||||||
public bool IsEmpty { get { return contents.Values.Sum() == 0; } }
|
public bool IsEmpty { get { return contents.Values.Sum() == 0; } }
|
||||||
public int Fullness { get { return contents.Values.Sum() * 100 / Info.Capacity; } }
|
public int Fullness { get { return contents.Values.Sum() * 100 / info.Capacity; } }
|
||||||
|
|
||||||
public void AcceptResource(ResourceType type)
|
public void AcceptResource(ResourceType type)
|
||||||
{
|
{
|
||||||
@@ -244,7 +244,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
if (--contents[type] == 0)
|
if (--contents[type] == 0)
|
||||||
contents.Remove(type);
|
contents.Remove(type);
|
||||||
|
|
||||||
currentUnloadTicks = Info.UnloadTicksPerBale;
|
currentUnloadTicks = info.UnloadTicksPerBale;
|
||||||
}
|
}
|
||||||
|
|
||||||
return contents.Count == 0;
|
return contents.Count == 0;
|
||||||
@@ -419,7 +419,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
PipType GetPipAt(int i)
|
PipType GetPipAt(int i)
|
||||||
{
|
{
|
||||||
var n = i * Info.Capacity / Info.PipCount;
|
var n = i * info.Capacity / info.PipCount;
|
||||||
|
|
||||||
foreach (var rt in contents)
|
foreach (var rt in contents)
|
||||||
if (n < rt.Value)
|
if (n < rt.Value)
|
||||||
@@ -432,7 +432,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
{
|
{
|
||||||
var numPips = Info.PipCount;
|
var numPips = info.PipCount;
|
||||||
|
|
||||||
for (var i = 0; i < numPips; i++)
|
for (var i = 0; i < numPips; i++)
|
||||||
yield return GetPipAt(i);
|
yield return GetPipAt(i);
|
||||||
@@ -442,7 +442,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public int GetSpeedModifier()
|
public int GetSpeedModifier()
|
||||||
{
|
{
|
||||||
return 100 - (100 - Info.FullyLoadedSpeed) * contents.Values.Sum() / Info.Capacity;
|
return 100 - (100 - info.FullyLoadedSpeed) * contents.Values.Sum() / info.Capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
class HarvestOrderTargeter : IOrderTargeter
|
class HarvestOrderTargeter : IOrderTargeter
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public class HarvesterHuskModifier : IHuskModifier
|
public class HarvesterHuskModifier : IHuskModifier
|
||||||
{
|
{
|
||||||
HarvesterHuskModifierInfo Info;
|
readonly HarvesterHuskModifierInfo info;
|
||||||
public HarvesterHuskModifier(HarvesterHuskModifierInfo info)
|
public HarvesterHuskModifier(HarvesterHuskModifierInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string HuskActor(Actor self)
|
public string HuskActor(Actor self)
|
||||||
{
|
{
|
||||||
return self.Trait<Harvester>().Fullness > Info.FullnessThreshold ? Info.FullHuskActor : null;
|
return self.Trait<Harvester>().Fullness > info.FullnessThreshold ? info.FullHuskActor : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,26 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.RA.Traits
|
namespace OpenRA.Mods.RA.Traits
|
||||||
{
|
{
|
||||||
[Desc("Apply palette full screen rotations during chronoshifts. Add this to the world actor.")]
|
[Desc("Apply palette full screen rotations during chronoshifts. Add this to the world actor.")]
|
||||||
class ChronoshiftPaletteEffectInfo : TraitInfo<ChronoshiftPaletteEffect> { }
|
public class ChronoshiftPaletteEffectInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly int ChronoEffectLength = 60;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new ChronoshiftPaletteEffect(this); }
|
||||||
|
}
|
||||||
|
|
||||||
public class ChronoshiftPaletteEffect : IPaletteModifier, ITick
|
public class ChronoshiftPaletteEffect : IPaletteModifier, ITick
|
||||||
{
|
{
|
||||||
const int chronoEffectLength = 60;
|
|
||||||
int remainingFrames;
|
int remainingFrames;
|
||||||
|
ChronoshiftPaletteEffectInfo info;
|
||||||
|
|
||||||
|
public ChronoshiftPaletteEffect(ChronoshiftPaletteEffectInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
public void Enable()
|
public void Enable()
|
||||||
{
|
{
|
||||||
remainingFrames = chronoEffectLength;
|
remainingFrames = info.ChronoEffectLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
@@ -39,7 +49,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
if (remainingFrames == 0)
|
if (remainingFrames == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var frac = (float)remainingFrames / chronoEffectLength;
|
var frac = (float)remainingFrames / info.ChronoEffectLength;
|
||||||
|
|
||||||
foreach (var pal in palettes)
|
foreach (var pal in palettes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,13 +22,19 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
{
|
{
|
||||||
[Desc("Cooldown in seconds until the unit can teleport.")]
|
[Desc("Cooldown in seconds until the unit can teleport.")]
|
||||||
public readonly int ChargeTime = 20;
|
public readonly int ChargeTime = 20;
|
||||||
|
|
||||||
[Desc("Can the unit teleport only a certain distance?")]
|
[Desc("Can the unit teleport only a certain distance?")]
|
||||||
public readonly bool HasDistanceLimit = true;
|
public readonly bool HasDistanceLimit = true;
|
||||||
|
|
||||||
[Desc("The maximum distance in cells this unit can teleport (only used if HasDistanceLimit = true).")]
|
[Desc("The maximum distance in cells this unit can teleport (only used if HasDistanceLimit = true).")]
|
||||||
public readonly int MaxDistance = 12;
|
public readonly int MaxDistance = 12;
|
||||||
|
|
||||||
[Desc("Sound to play when teleporting.")]
|
[Desc("Sound to play when teleporting.")]
|
||||||
public readonly string ChronoshiftSound = "chrotnk1.aud";
|
public readonly string ChronoshiftSound = "chrotnk1.aud";
|
||||||
|
|
||||||
|
[Desc("Display rectangles indicating the current charge status")]
|
||||||
|
public readonly int Pips = 2;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new PortableChrono(this); }
|
public object Create(ActorInitializer init) { return new PortableChrono(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +45,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public PortableChrono(PortableChronoInfo info)
|
public PortableChrono(PortableChronoInfo info)
|
||||||
{
|
{
|
||||||
this.Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
@@ -93,13 +99,11 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
get { return chargeTick <= 0; }
|
get { return chargeTick <= 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display 2 pips indicating the current charge status
|
|
||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
{
|
{
|
||||||
const int numPips = 2;
|
for (var i = 0; i < Info.Pips; i++)
|
||||||
for (var i = 0; i < numPips; i++)
|
|
||||||
{
|
{
|
||||||
if ((1 - chargeTick * 1.0f / (25 * Info.ChargeTime)) * numPips < i + 1)
|
if ((1 - chargeTick * 1.0f / (25 * Info.ChargeTime)) * Info.Pips < i + 1)
|
||||||
{
|
{
|
||||||
yield return PipType.Transparent;
|
yield return PipType.Transparent;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
|
||||||
return new SelectTarget(self.World, order, manager, this);
|
return new SelectTarget(Self.World, order, manager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
||||||
@@ -55,10 +55,10 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
||||||
{
|
{
|
||||||
var range = ((ChronoshiftPowerInfo)Info).Range;
|
var range = ((ChronoshiftPowerInfo)Info).Range;
|
||||||
var tiles = self.World.Map.FindTilesInCircle(xy, range);
|
var tiles = Self.World.Map.FindTilesInCircle(xy, range);
|
||||||
var units = new List<Actor>();
|
var units = new List<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
units.AddRange(self.World.ActorMap.GetUnitsAt(t));
|
units.AddRange(Self.World.ActorMap.GetUnitsAt(t));
|
||||||
|
|
||||||
return units.Distinct().Where(a => a.HasTrait<Chronoshiftable>() &&
|
return units.Distinct().Where(a => a.HasTrait<Chronoshiftable>() &&
|
||||||
!a.TraitsImplementing<IPreventsTeleport>().Any(condition => condition.PreventsTeleport(a)));
|
!a.TraitsImplementing<IPreventsTeleport>().Any(condition => condition.PreventsTeleport(a)));
|
||||||
@@ -66,12 +66,12 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
public bool SimilarTerrain(CPos xy, CPos sourceLocation)
|
public bool SimilarTerrain(CPos xy, CPos sourceLocation)
|
||||||
{
|
{
|
||||||
if (!self.Owner.Shroud.IsExplored(xy))
|
if (!Self.Owner.Shroud.IsExplored(xy))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var range = ((ChronoshiftPowerInfo)Info).Range;
|
var range = ((ChronoshiftPowerInfo)Info).Range;
|
||||||
var sourceTiles = self.World.Map.FindTilesInCircle(xy, range);
|
var sourceTiles = Self.World.Map.FindTilesInCircle(xy, range);
|
||||||
var destTiles = self.World.Map.FindTilesInCircle(sourceLocation, range);
|
var destTiles = Self.World.Map.FindTilesInCircle(sourceLocation, range);
|
||||||
|
|
||||||
using (var se = sourceTiles.GetEnumerator())
|
using (var se = sourceTiles.GetEnumerator())
|
||||||
using (var de = destTiles.GetEnumerator())
|
using (var de = destTiles.GetEnumerator())
|
||||||
@@ -80,10 +80,10 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
var a = se.Current;
|
var a = se.Current;
|
||||||
var b = de.Current;
|
var b = de.Current;
|
||||||
|
|
||||||
if (!self.Owner.Shroud.IsExplored(a) || !self.Owner.Shroud.IsExplored(b))
|
if (!Self.Owner.Shroud.IsExplored(a) || !Self.Owner.Shroud.IsExplored(b))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (self.World.Map.GetTerrainIndex(a) != self.World.Map.GetTerrainIndex(b))
|
if (Self.World.Map.GetTerrainIndex(a) != Self.World.Map.GetTerrainIndex(b))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
var targetUnits = power.UnitsInRange(xy).Where(a => !world.FogObscures(a));
|
var targetUnits = power.UnitsInRange(xy).Where(a => !world.FogObscures(a));
|
||||||
|
|
||||||
foreach (var unit in targetUnits)
|
foreach (var unit in targetUnits)
|
||||||
if (manager.self.Owner.Shroud.IsTargetable(unit))
|
if (manager.Self.Owner.Shroud.IsTargetable(unit))
|
||||||
yield return new SelectionBoxRenderable(unit, Color.Red);
|
yield return new SelectionBoxRenderable(unit, Color.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
this.sourceLocation = sourceLocation;
|
this.sourceLocation = sourceLocation;
|
||||||
this.range = ((ChronoshiftPowerInfo)power.Info).Range;
|
this.range = ((ChronoshiftPowerInfo)power.Info).Range;
|
||||||
|
|
||||||
var tileset = manager.self.World.TileSet.Id.ToLowerInvariant();
|
var tileset = manager.Self.World.TileSet.Id.ToLowerInvariant();
|
||||||
validTile = world.Map.SequenceProvider.GetSequence("overlay", "target-valid-{0}".F(tileset)).GetSprite(0);
|
validTile = world.Map.SequenceProvider.GetSequence("overlay", "target-valid-{0}".F(tileset)).GetSprite(0);
|
||||||
invalidTile = world.Map.SequenceProvider.GetSequence("overlay", "target-invalid").GetSprite(0);
|
invalidTile = world.Map.SequenceProvider.GetSequence("overlay", "target-invalid").GetSprite(0);
|
||||||
sourceTile = world.Map.SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
|
sourceTile = world.Map.SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
|
||||||
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
{
|
{
|
||||||
// Cannot chronoshift into unexplored location
|
// Cannot chronoshift into unexplored location
|
||||||
if (IsValidTarget(xy))
|
if (IsValidTarget(xy))
|
||||||
yield return new Order(order, manager.self, false)
|
yield return new Order(order, manager.Self, false)
|
||||||
{
|
{
|
||||||
TargetLocation = xy,
|
TargetLocation = xy,
|
||||||
ExtraLocation = sourceLocation,
|
ExtraLocation = sourceLocation,
|
||||||
@@ -209,7 +209,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr, World world)
|
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr, World world)
|
||||||
{
|
{
|
||||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||||
if (manager.self.Owner.Shroud.IsTargetable(unit))
|
if (manager.Self.Owner.Shroud.IsTargetable(unit))
|
||||||
yield return new SelectionBoxRenderable(unit, Color.Red);
|
yield return new SelectionBoxRenderable(unit, Color.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||||
{
|
{
|
||||||
var offset = world.Map.CenterOfCell(xy) - world.Map.CenterOfCell(sourceLocation);
|
var offset = world.Map.CenterOfCell(xy) - world.Map.CenterOfCell(sourceLocation);
|
||||||
if (manager.self.Owner.Shroud.IsTargetable(unit))
|
if (manager.Self.Owner.Shroud.IsTargetable(unit))
|
||||||
foreach (var r in unit.Render(wr))
|
foreach (var r in unit.Render(wr))
|
||||||
yield return r.OffsetBy(offset);
|
yield return r.OffsetBy(offset);
|
||||||
}
|
}
|
||||||
@@ -238,10 +238,10 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
// Unit tiles
|
// Unit tiles
|
||||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||||
{
|
{
|
||||||
if (manager.self.Owner.Shroud.IsTargetable(unit))
|
if (manager.Self.Owner.Shroud.IsTargetable(unit))
|
||||||
{
|
{
|
||||||
var targetCell = unit.Location + (xy - sourceLocation);
|
var targetCell = unit.Location + (xy - sourceLocation);
|
||||||
var canEnter = manager.self.Owner.Shroud.IsExplored(targetCell) &&
|
var canEnter = manager.Self.Owner.Shroud.IsExplored(targetCell) &&
|
||||||
unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell);
|
unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell);
|
||||||
var tile = canEnter ? validTile : invalidTile;
|
var tile = canEnter ? validTile : invalidTile;
|
||||||
yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(targetCell), WVec.Zero, -511, pal, 1f, true);
|
yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(targetCell), WVec.Zero, -511, pal, 1f, true);
|
||||||
@@ -255,7 +255,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||||
{
|
{
|
||||||
var targetCell = unit.Location + (xy - sourceLocation);
|
var targetCell = unit.Location + (xy - sourceLocation);
|
||||||
if (manager.self.Owner.Shroud.IsExplored(targetCell) && unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell))
|
if (manager.Self.Owner.Shroud.IsExplored(targetCell) && unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell))
|
||||||
{
|
{
|
||||||
canTeleport = true;
|
canTeleport = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
class GpsWatcher : ISync, IFogVisibilityModifier
|
class GpsWatcher : ISync, IFogVisibilityModifier
|
||||||
{
|
{
|
||||||
[Sync] bool Launched = false;
|
[Sync] bool launched = false;
|
||||||
[Sync] public bool GrantedAllies = false;
|
[Sync] public bool GrantedAllies = false;
|
||||||
[Sync] public bool Granted = false;
|
[Sync] public bool Granted = false;
|
||||||
Player owner;
|
Player owner;
|
||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
atek.World.Add(new DelayedAction(((GpsPowerInfo)info).RevealDelay * 25,
|
atek.World.Add(new DelayedAction(((GpsPowerInfo)info).RevealDelay * 25,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
Launched = true;
|
launched = true;
|
||||||
RefreshGps(atek);
|
RefreshGps(atek);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
void RefreshGranted()
|
void RefreshGranted()
|
||||||
{
|
{
|
||||||
Granted = actors.Count > 0 && Launched;
|
Granted = actors.Count > 0 && launched;
|
||||||
GrantedAllies = owner.World.ActorsWithTrait<GpsWatcher>().Any(p => p.Actor.Owner.IsAlliedWith(owner) && p.Trait.Granted);
|
GrantedAllies = owner.World.ActorsWithTrait<GpsWatcher>().Any(p => p.Actor.Owner.IsAlliedWith(owner) && p.Trait.Granted);
|
||||||
|
|
||||||
if (Granted || GrantedAllies)
|
if (Granted || GrantedAllies)
|
||||||
|
|||||||
@@ -24,16 +24,16 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class TransformOnCapture : INotifyCapture
|
class TransformOnCapture : INotifyCapture
|
||||||
{
|
{
|
||||||
TransformOnCaptureInfo Info;
|
readonly TransformOnCaptureInfo info;
|
||||||
|
|
||||||
public TransformOnCapture(TransformOnCaptureInfo info) { Info = info; }
|
public TransformOnCapture(TransformOnCaptureInfo info) { this.info = info; }
|
||||||
|
|
||||||
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||||
{
|
{
|
||||||
var facing = self.TraitOrDefault<IFacing>();
|
var facing = self.TraitOrDefault<IFacing>();
|
||||||
var transform = new Transform(self, Info.IntoActor) { ForceHealthPercentage = Info.ForceHealthPercentage };
|
var transform = new Transform(self, info.IntoActor) { ForceHealthPercentage = info.ForceHealthPercentage };
|
||||||
if (facing != null) transform.Facing = facing.Facing;
|
if (facing != null) transform.Facing = facing.Facing;
|
||||||
transform.SkipMakeAnims = Info.SkipMakeAnims;
|
transform.SkipMakeAnims = info.SkipMakeAnims;
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(transform);
|
self.QueueActivity(transform);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
PopulateObjectivesList(mo, objectivesPanel, template);
|
PopulateObjectivesList(mo, objectivesPanel, template);
|
||||||
|
|
||||||
Action<Player> RedrawObjectives = player =>
|
Action<Player> redrawObjectives = player =>
|
||||||
{
|
{
|
||||||
if (player == lp)
|
if (player == lp)
|
||||||
PopulateObjectivesList(mo, objectivesPanel, template);
|
PopulateObjectivesList(mo, objectivesPanel, template);
|
||||||
};
|
};
|
||||||
mo.ObjectiveAdded += RedrawObjectives;
|
mo.ObjectiveAdded += redrawObjectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
|
void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
if (lp != null)
|
if (lp != null)
|
||||||
{
|
{
|
||||||
Action<Player> StartBlinking = player =>
|
Action<Player> startBlinking = player =>
|
||||||
{
|
{
|
||||||
if (player == world.LocalPlayer)
|
if (player == world.LocalPlayer)
|
||||||
blinking = true;
|
blinking = true;
|
||||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var mo = lp.PlayerActor.TraitOrDefault<MissionObjectives>();
|
var mo = lp.PlayerActor.TraitOrDefault<MissionObjectives>();
|
||||||
|
|
||||||
if (mo != null)
|
if (mo != null)
|
||||||
mo.ObjectiveAdded += StartBlinking;
|
mo.ObjectiveAdded += startBlinking;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
advertiseCheckbox.OnClick = () => advertiseOnline ^= true;
|
advertiseCheckbox.OnClick = () => advertiseOnline ^= true;
|
||||||
|
|
||||||
allowPortForward = Game.Settings.Server.AllowPortForward;
|
allowPortForward = Game.Settings.Server.AllowPortForward;
|
||||||
var UPnPCheckbox = panel.Get<CheckboxWidget>("UPNP_CHECKBOX");
|
var checkboxUPnP = panel.Get<CheckboxWidget>("UPNP_CHECKBOX");
|
||||||
UPnPCheckbox.IsChecked = () => allowPortForward;
|
checkboxUPnP.IsChecked = () => allowPortForward;
|
||||||
UPnPCheckbox.OnClick = () => allowPortForward ^= true;
|
checkboxUPnP.OnClick = () => allowPortForward ^= true;
|
||||||
UPnPCheckbox.IsDisabled = () => !Game.Settings.Server.NatDeviceAvailable;
|
checkboxUPnP.IsDisabled = () => !Game.Settings.Server.NatDeviceAvailable;
|
||||||
|
|
||||||
var passwordField = panel.GetOrNull<PasswordFieldWidget>("PASSWORD");
|
var passwordField = panel.GetOrNull<PasswordFieldWidget>("PASSWORD");
|
||||||
if (passwordField != null)
|
if (passwordField != null)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
{
|
{
|
||||||
var time = WidgetUtils.FormatTime(p.RemainingTime, false);
|
var time = WidgetUtils.FormatTime(p.RemainingTime, false);
|
||||||
var text = Format.F(p.Info.Description, time);
|
var text = Format.F(p.Info.Description, time);
|
||||||
var color = !p.Ready || Game.LocalTick % 50 < 25 ? p.Instances[0].self.Owner.Color.RGB : Color.White;
|
var color = !p.Ready || Game.LocalTick % 50 < 25 ? p.Instances[0].Self.Owner.Color.RGB : Color.White;
|
||||||
return Pair.New(text, color);
|
return Pair.New(text, color);
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
if (clicked != null)
|
if (clicked != null)
|
||||||
{
|
{
|
||||||
if (!clicked.Power.Active)
|
if (!clicked.Power.Active)
|
||||||
Sound.PlayToPlayer(spm.self.Owner, clicked.Power.Info.InsufficientPowerSound);
|
Sound.PlayToPlayer(spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound);
|
||||||
|
|
||||||
clicked.Power.Target();
|
clicked.Power.Target();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user