Introduce IWarhead and move Warhead to Mods.Common
This commit is contained in:
@@ -62,7 +62,7 @@ namespace OpenRA.GameRules
|
|||||||
public readonly IProjectileInfo Projectile;
|
public readonly IProjectileInfo Projectile;
|
||||||
|
|
||||||
[FieldLoader.LoadUsing("LoadWarheads")]
|
[FieldLoader.LoadUsing("LoadWarheads")]
|
||||||
public readonly List<Warhead> Warheads = new List<Warhead>();
|
public readonly List<IWarhead> Warheads = new List<IWarhead>();
|
||||||
|
|
||||||
readonly HashSet<string> validTargetSet;
|
readonly HashSet<string> validTargetSet;
|
||||||
readonly HashSet<string> invalidTargetSet;
|
readonly HashSet<string> invalidTargetSet;
|
||||||
@@ -86,10 +86,10 @@ namespace OpenRA.GameRules
|
|||||||
|
|
||||||
static object LoadWarheads(MiniYaml yaml)
|
static object LoadWarheads(MiniYaml yaml)
|
||||||
{
|
{
|
||||||
var retList = new List<Warhead>();
|
var retList = new List<IWarhead>();
|
||||||
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
|
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
|
||||||
{
|
{
|
||||||
var ret = Game.CreateObject<Warhead>(node.Value.Value + "Warhead");
|
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
|
||||||
FieldLoader.Load(ret, node.Value);
|
FieldLoader.Load(ret, node.Value);
|
||||||
retList.Add(ret);
|
retList.Add(ret);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,6 @@
|
|||||||
<Compile Include="FileSystem\BagFile.cs" />
|
<Compile Include="FileSystem\BagFile.cs" />
|
||||||
<Compile Include="Map\MapPlayers.cs" />
|
<Compile Include="Map\MapPlayers.cs" />
|
||||||
<Compile Include="MPos.cs" />
|
<Compile Include="MPos.cs" />
|
||||||
<Compile Include="GameRules\Warhead.cs" />
|
|
||||||
<Compile Include="Graphics\QuadRenderer.cs" />
|
<Compile Include="Graphics\QuadRenderer.cs" />
|
||||||
<Compile Include="Download.cs" />
|
<Compile Include="Download.cs" />
|
||||||
<Compile Include="Effects\AsyncAction.cs" />
|
<Compile Include="Effects\AsyncAction.cs" />
|
||||||
@@ -235,7 +234,6 @@
|
|||||||
<Compile Include="Graphics\SelectionBarsRenderable.cs" />
|
<Compile Include="Graphics\SelectionBarsRenderable.cs" />
|
||||||
<Compile Include="Graphics\TargetLineRenderable.cs" />
|
<Compile Include="Graphics\TargetLineRenderable.cs" />
|
||||||
<Compile Include="Graphics\UISpriteRenderable.cs" />
|
<Compile Include="Graphics\UISpriteRenderable.cs" />
|
||||||
<Compile Include="GameRules\DamageWarhead.cs" />
|
|
||||||
<Compile Include="Graphics\SoftwareCursor.cs" />
|
<Compile Include="Graphics\SoftwareCursor.cs" />
|
||||||
<Compile Include="Graphics\HardwareCursor.cs" />
|
<Compile Include="Graphics\HardwareCursor.cs" />
|
||||||
<Compile Include="Support\PerfItem.cs" />
|
<Compile Include="Support\PerfItem.cs" />
|
||||||
|
|||||||
@@ -8,9 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
@@ -88,7 +86,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
Attacker = repairer,
|
Attacker = repairer,
|
||||||
Damage = -MaxHP,
|
Damage = -MaxHP,
|
||||||
DamageState = this.DamageState,
|
DamageState = DamageState,
|
||||||
PreviousDamageState = DamageState.Dead,
|
PreviousDamageState = DamageState.Dead,
|
||||||
Warhead = null,
|
Warhead = null,
|
||||||
};
|
};
|
||||||
@@ -106,9 +104,9 @@ namespace OpenRA.Traits
|
|||||||
nd.AppliedDamage(repairer, self, ai);
|
nd.AppliedDamage(repairer, self, ai);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InflictDamage(Actor self, Actor attacker, int damage, DamageWarhead warhead, bool ignoreModifiers)
|
public void InflictDamage(Actor self, Actor attacker, int damage, IWarhead warhead, bool ignoreModifiers)
|
||||||
{
|
{
|
||||||
// Overkill! don't count extra hits as more kills!
|
// Overkill! Don't count extra hits as more kills!
|
||||||
if (IsDead)
|
if (IsDead)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -177,7 +175,7 @@ namespace OpenRA.Traits
|
|||||||
public class HealthInit : IActorInit<int>
|
public class HealthInit : IActorInit<int>
|
||||||
{
|
{
|
||||||
[FieldFromYamlKey] readonly int value = 100;
|
[FieldFromYamlKey] readonly int value = 100;
|
||||||
readonly bool allowZero = false;
|
readonly bool allowZero;
|
||||||
public HealthInit() { }
|
public HealthInit() { }
|
||||||
public HealthInit(int init, bool allowZero = false)
|
public HealthInit(int init, bool allowZero = false)
|
||||||
{
|
{
|
||||||
@@ -205,7 +203,7 @@ namespace OpenRA.Traits
|
|||||||
return (health == null) ? DamageState.Undamaged : health.DamageState;
|
return (health == null) ? DamageState.Undamaged : health.DamageState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InflictDamage(this Actor self, Actor attacker, int damage, DamageWarhead warhead)
|
public static void InflictDamage(this Actor self, Actor attacker, int damage, IWarhead warhead)
|
||||||
{
|
{
|
||||||
if (self.Disposed) return;
|
if (self.Disposed) return;
|
||||||
var health = self.TraitOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.GameRules;
|
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -48,9 +46,9 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class AttackInfo
|
public class AttackInfo
|
||||||
{
|
{
|
||||||
public Actor Attacker;
|
|
||||||
public DamageWarhead Warhead;
|
|
||||||
public int Damage;
|
public int Damage;
|
||||||
|
public Actor Attacker;
|
||||||
|
public IWarhead Warhead;
|
||||||
public DamageState DamageState;
|
public DamageState DamageState;
|
||||||
public DamageState PreviousDamageState;
|
public DamageState PreviousDamageState;
|
||||||
}
|
}
|
||||||
@@ -353,4 +351,12 @@ namespace OpenRA.Traits
|
|||||||
void OnObjectiveCompleted(Player player, int objectiveID);
|
void OnObjectiveCompleted(Player player, int objectiveID);
|
||||||
void OnObjectiveFailed(Player player, int objectiveID);
|
void OnObjectiveFailed(Player player, int objectiveID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IWarhead
|
||||||
|
{
|
||||||
|
int Delay { get; }
|
||||||
|
bool IsValidAgainst(Actor victim, Actor firedBy);
|
||||||
|
bool IsValidAgainst(FrozenActor victim, Actor firedBy);
|
||||||
|
void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -539,11 +539,13 @@
|
|||||||
<Compile Include="UtilityCommands\UpgradeRules.cs" />
|
<Compile Include="UtilityCommands\UpgradeRules.cs" />
|
||||||
<Compile Include="Warheads\CreateEffectWarhead.cs" />
|
<Compile Include="Warheads\CreateEffectWarhead.cs" />
|
||||||
<Compile Include="Warheads\CreateResourceWarhead.cs" />
|
<Compile Include="Warheads\CreateResourceWarhead.cs" />
|
||||||
|
<Compile Include="Warheads\DamageWarhead.cs" />
|
||||||
<Compile Include="Warheads\DestroyResourceWarhead.cs" />
|
<Compile Include="Warheads\DestroyResourceWarhead.cs" />
|
||||||
<Compile Include="Warheads\GrantUpgradeWarhead.cs" />
|
<Compile Include="Warheads\GrantUpgradeWarhead.cs" />
|
||||||
<Compile Include="Warheads\HealthPercentageDamageWarhead.cs" />
|
<Compile Include="Warheads\HealthPercentageDamageWarhead.cs" />
|
||||||
<Compile Include="Warheads\LeaveSmudgeWarhead.cs" />
|
<Compile Include="Warheads\LeaveSmudgeWarhead.cs" />
|
||||||
<Compile Include="Warheads\SpreadDamageWarhead.cs" />
|
<Compile Include="Warheads\SpreadDamageWarhead.cs" />
|
||||||
|
<Compile Include="Warheads\Warhead.cs" />
|
||||||
<Compile Include="Widgets\ActorPreviewWidget.cs" />
|
<Compile Include="Widgets\ActorPreviewWidget.cs" />
|
||||||
<Compile Include="Widgets\ColorMixerWidget.cs" />
|
<Compile Include="Widgets\ColorMixerWidget.cs" />
|
||||||
<Compile Include="Widgets\ColorPreviewManagerWidget.cs" />
|
<Compile Include="Widgets\ColorPreviewManagerWidget.cs" />
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.GameRules
|
namespace OpenRA.Mods.Common.Warheads
|
||||||
{
|
{
|
||||||
public abstract class DamageWarhead : Warhead
|
public abstract class DamageWarhead : Warhead
|
||||||
{
|
{
|
||||||
@@ -9,14 +9,12 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Effects;
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.GameRules
|
namespace OpenRA.Mods.Common.Warheads
|
||||||
{
|
{
|
||||||
[Desc("Base warhead class. This can be used to derive other warheads from.")]
|
[Desc("Base warhead class. This can be used to derive other warheads from.")]
|
||||||
public abstract class Warhead
|
public abstract class Warhead : IWarhead
|
||||||
{
|
{
|
||||||
[Desc("What types of targets are affected.")]
|
[Desc("What types of targets are affected.")]
|
||||||
public readonly string[] ValidTargets = { "Ground", "Water" };
|
public readonly string[] ValidTargets = { "Ground", "Water" };
|
||||||
@@ -32,6 +30,7 @@ namespace OpenRA.GameRules
|
|||||||
|
|
||||||
[Desc("Delay in ticks before applying the warhead effect.", "0 = instant (old model).")]
|
[Desc("Delay in ticks before applying the warhead effect.", "0 = instant (old model).")]
|
||||||
public readonly int Delay = 0;
|
public readonly int Delay = 0;
|
||||||
|
int IWarhead.Delay { get { return Delay; } }
|
||||||
|
|
||||||
HashSet<string> validTargetSet;
|
HashSet<string> validTargetSet;
|
||||||
HashSet<string> invalidTargetSet;
|
HashSet<string> invalidTargetSet;
|
||||||
Reference in New Issue
Block a user