Replace CloakCrateAction with upgrades.
This commit is contained in:
@@ -29,7 +29,9 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly bool UncloakOnAttack = true;
|
public readonly bool UncloakOnAttack = true;
|
||||||
public readonly bool UncloakOnMove = false;
|
public readonly bool UncloakOnMove = false;
|
||||||
public readonly bool UncloakOnUnload = false;
|
public readonly bool UncloakOnUnload = false;
|
||||||
public readonly bool RequiresCrate = false;
|
|
||||||
|
[Desc("Enable only if this upgrade is enabled.")]
|
||||||
|
public readonly string RequiresUpgrade = null;
|
||||||
|
|
||||||
public readonly string CloakSound = null;
|
public readonly string CloakSound = null;
|
||||||
public readonly string UncloakSound = null;
|
public readonly string UncloakSound = null;
|
||||||
@@ -40,11 +42,11 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
|
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Cloak : IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
public class Cloak : IUpgradable, IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
||||||
{
|
{
|
||||||
[Sync] int remainingTime;
|
[Sync] int remainingTime;
|
||||||
[Sync] bool damageDisabled;
|
[Sync] bool damageDisabled;
|
||||||
[Sync] bool crateDisabled;
|
[Sync] bool disabled;
|
||||||
|
|
||||||
Actor self;
|
Actor self;
|
||||||
public readonly CloakInfo Info;
|
public readonly CloakInfo Info;
|
||||||
@@ -56,7 +58,20 @@ namespace OpenRA.Mods.RA
|
|||||||
Info = info;
|
Info = info;
|
||||||
|
|
||||||
remainingTime = info.InitialDelay;
|
remainingTime = info.InitialDelay;
|
||||||
crateDisabled = info.RequiresCrate;
|
|
||||||
|
// Disable if an upgrade is required
|
||||||
|
disabled = info.RequiresUpgrade != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AcceptsUpgrade(string type)
|
||||||
|
{
|
||||||
|
return type == Info.RequiresUpgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpgradeAvailable(Actor self, string type, bool available)
|
||||||
|
{
|
||||||
|
if (type == Info.RequiresUpgrade)
|
||||||
|
disabled = !available;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Uncloak() { Uncloak(Info.CloakDelay); }
|
public void Uncloak() { Uncloak(Info.CloakDelay); }
|
||||||
@@ -96,7 +111,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (remainingTime > 0 && !crateDisabled && !damageDisabled && --remainingTime <= 0)
|
if (remainingTime > 0 && !disabled && !damageDisabled && --remainingTime <= 0)
|
||||||
Sound.Play(Info.CloakSound, self.CenterPosition);
|
Sound.Play(Info.CloakSound, self.CenterPosition);
|
||||||
|
|
||||||
if (self.IsDisabled())
|
if (self.IsDisabled())
|
||||||
@@ -131,12 +146,5 @@ namespace OpenRA.Mods.RA
|
|||||||
c = Color.FromArgb(128, c);
|
c = Color.FromArgb(128, c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AcceptsCloakCrate { get { return Info.RequiresCrate && crateDisabled; } }
|
|
||||||
|
|
||||||
public void ReceivedCloakCrate(Actor self)
|
|
||||||
{
|
|
||||||
crateDisabled = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Crates
|
|
||||||
{
|
|
||||||
[Desc("Grants the collector the ability to cloak.")]
|
|
||||||
public class CloakCrateActionInfo : CrateActionInfo
|
|
||||||
{
|
|
||||||
[Desc("The range to search for extra collectors in.", "Extra collectors will also be granted the crate action.")]
|
|
||||||
public readonly WRange Range = new WRange(3);
|
|
||||||
|
|
||||||
[Desc("The maximum number of extra collectors to grant the crate action to.")]
|
|
||||||
public readonly int MaxExtraCollectors = 4;
|
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new CloakCrateAction(init.self, this); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CloakCrateAction : CrateAction
|
|
||||||
{
|
|
||||||
CloakCrateActionInfo Info;
|
|
||||||
|
|
||||||
public CloakCrateAction(Actor self, CloakCrateActionInfo info)
|
|
||||||
: base(self, info)
|
|
||||||
{
|
|
||||||
Info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetSelectionShares(Actor collector)
|
|
||||||
{
|
|
||||||
var cloak = collector.TraitOrDefault<Cloak>();
|
|
||||||
if (cloak == null || !cloak.AcceptsCloakCrate)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return base.GetSelectionShares(collector);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Activate(Actor collector)
|
|
||||||
{
|
|
||||||
collector.Trait<Cloak>().ReceivedCloakCrate(collector);
|
|
||||||
|
|
||||||
var inRange = self.World.FindActorsInCircle(self.CenterPosition, Info.Range);
|
|
||||||
inRange = inRange.Where(a =>
|
|
||||||
(a.Owner == collector.Owner) &&
|
|
||||||
(a != collector) &&
|
|
||||||
(a.TraitOrDefault<Cloak>() != null) &&
|
|
||||||
(a.TraitOrDefault<Cloak>().AcceptsCloakCrate));
|
|
||||||
if (inRange.Any())
|
|
||||||
{
|
|
||||||
if (Info.MaxExtraCollectors > -1)
|
|
||||||
inRange = inRange.Take(Info.MaxExtraCollectors);
|
|
||||||
|
|
||||||
if (inRange.Any())
|
|
||||||
foreach (Actor actor in inRange)
|
|
||||||
{
|
|
||||||
actor.Trait<Cloak>().ReceivedCloakCrate(actor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Activate(collector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -193,7 +193,6 @@
|
|||||||
<Compile Include="Crate.cs" />
|
<Compile Include="Crate.cs" />
|
||||||
<Compile Include="CrateAction.cs" />
|
<Compile Include="CrateAction.cs" />
|
||||||
<Compile Include="CrateSpawner.cs" />
|
<Compile Include="CrateSpawner.cs" />
|
||||||
<Compile Include="Crates\CloakCrateAction.cs" />
|
|
||||||
<Compile Include="Crates\ExplodeCrateAction.cs" />
|
<Compile Include="Crates\ExplodeCrateAction.cs" />
|
||||||
<Compile Include="Crates\GiveCashCrateAction.cs" />
|
<Compile Include="Crates\GiveCashCrateAction.cs" />
|
||||||
<Compile Include="Crates\GiveMcvCrateAction.cs" />
|
<Compile Include="Crates\GiveMcvCrateAction.cs" />
|
||||||
|
|||||||
@@ -369,6 +369,21 @@ namespace OpenRA.Utility
|
|||||||
{
|
{
|
||||||
if (depth == 0 && node.Value.Nodes.Any(n => n.Key.StartsWith("GainsExperience")))
|
if (depth == 0 && node.Value.Nodes.Any(n => n.Key.StartsWith("GainsExperience")))
|
||||||
node.Value.Nodes.Add(new MiniYamlNode("GainsStatUpgrades", new MiniYaml("")));
|
node.Value.Nodes.Add(new MiniYamlNode("GainsStatUpgrades", new MiniYaml("")));
|
||||||
|
|
||||||
|
if (depth == 1 && node.Key == "-CloakCrateAction")
|
||||||
|
node.Key = "-UnitUpgradeCrateAction@cloak";
|
||||||
|
|
||||||
|
if (depth == 1 && node.Key == "CloakCrateAction")
|
||||||
|
{
|
||||||
|
node.Key = "UnitUpgradeCrateAction@cloak";
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("Upgrades", new MiniYaml("cloak")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (depth == 2 && node.Key == "RequiresCrate" && parentKey == "Cloak")
|
||||||
|
{
|
||||||
|
node.Key = "RequiresUpgrade";
|
||||||
|
node.Value.Value = "cloak";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ Rules:
|
|||||||
-GiveMcvCrateAction:
|
-GiveMcvCrateAction:
|
||||||
-GiveCashCrateAction:
|
-GiveCashCrateAction:
|
||||||
-ExplodeCrateAction@fire:
|
-ExplodeCrateAction@fire:
|
||||||
-CloakCrateAction:
|
-UnitUpgradeCrateAction@cloak:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
|
||||||
Sequences:
|
Sequences:
|
||||||
|
|||||||
@@ -645,7 +645,7 @@ Rules:
|
|||||||
-GiveMcvCrateAction:
|
-GiveMcvCrateAction:
|
||||||
-GiveCashCrateAction:
|
-GiveCashCrateAction:
|
||||||
-ExplodeCrateAction@fire:
|
-ExplodeCrateAction@fire:
|
||||||
-CloakCrateAction:
|
-UnitUpgradeCrateAction@cloak:
|
||||||
|
|
||||||
Sequences:
|
Sequences:
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ Rules:
|
|||||||
-GiveMcvCrateAction:
|
-GiveMcvCrateAction:
|
||||||
-RevealMapCrateAction:
|
-RevealMapCrateAction:
|
||||||
-HideMapCrateAction:
|
-HideMapCrateAction:
|
||||||
-CloakCrateAction:
|
-UnitUpgradeCrateAction@cloak:
|
||||||
-ExplodeCrateAction@nuke:
|
-ExplodeCrateAction@nuke:
|
||||||
-ExplodeCrateAction@boom:
|
-ExplodeCrateAction@boom:
|
||||||
-ExplodeCrateAction@fire:
|
-ExplodeCrateAction@fire:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
Cloak:
|
Cloak:
|
||||||
RequiresCrate: true
|
RequiresUpgrade: cloak
|
||||||
InitialDelay: 15
|
InitialDelay: 15
|
||||||
CloakDelay: 90
|
CloakDelay: 90
|
||||||
CloakSound: trans1.aud
|
CloakSound: trans1.aud
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
Cloak:
|
Cloak:
|
||||||
RequiresCrate: true
|
RequiresUpgrade: cloak
|
||||||
InitialDelay: 15
|
InitialDelay: 15
|
||||||
CloakDelay: 90
|
CloakDelay: 90
|
||||||
CloakSound: trans1.aud
|
CloakSound: trans1.aud
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ CRATE:
|
|||||||
ExplodeCrateAction@fire:
|
ExplodeCrateAction@fire:
|
||||||
Weapon: Napalm.Crate
|
Weapon: Napalm.Crate
|
||||||
SelectionShares: 5
|
SelectionShares: 5
|
||||||
CloakCrateAction:
|
UnitUpgradeCrateAction@cloak:
|
||||||
SelectionShares: 5
|
SelectionShares: 5
|
||||||
Effect: cloak
|
Effect: cloak
|
||||||
|
Upgrades: cloak
|
||||||
DuplicateUnitCrateAction:
|
DuplicateUnitCrateAction:
|
||||||
SelectionShares: 10
|
SelectionShares: 10
|
||||||
MaxAmount: 5
|
MaxAmount: 5
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ STNK:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 7c0
|
Range: 7c0
|
||||||
Cloak:
|
Cloak:
|
||||||
RequiresCrate: false
|
RequiresUpgrade: cloak
|
||||||
InitialDelay: 90
|
InitialDelay: 90
|
||||||
CloakDelay: 90
|
CloakDelay: 90
|
||||||
CloakSound: trans1.aud
|
CloakSound: trans1.aud
|
||||||
|
|||||||
Reference in New Issue
Block a user