Introduce IWarhead and move Warhead to Mods.Common

This commit is contained in:
penev92
2015-07-04 16:12:56 +03:00
parent 53f00a7930
commit fe94b7686e
7 changed files with 24 additions and 21 deletions

View File

@@ -8,9 +8,7 @@
*/
#endregion
using System;
using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits
{
@@ -88,7 +86,7 @@ namespace OpenRA.Traits
{
Attacker = repairer,
Damage = -MaxHP,
DamageState = this.DamageState,
DamageState = DamageState,
PreviousDamageState = DamageState.Dead,
Warhead = null,
};
@@ -106,9 +104,9 @@ namespace OpenRA.Traits
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)
return;
@@ -177,7 +175,7 @@ namespace OpenRA.Traits
public class HealthInit : IActorInit<int>
{
[FieldFromYamlKey] readonly int value = 100;
readonly bool allowZero = false;
readonly bool allowZero;
public HealthInit() { }
public HealthInit(int init, bool allowZero = false)
{
@@ -205,7 +203,7 @@ namespace OpenRA.Traits
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;
var health = self.TraitOrDefault<Health>();

View File

@@ -12,9 +12,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Linq;
using OpenRA.Activities;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Primitives;
@@ -48,9 +46,9 @@ namespace OpenRA.Traits
public class AttackInfo
{
public Actor Attacker;
public DamageWarhead Warhead;
public int Damage;
public Actor Attacker;
public IWarhead Warhead;
public DamageState DamageState;
public DamageState PreviousDamageState;
}
@@ -353,4 +351,12 @@ namespace OpenRA.Traits
void OnObjectiveCompleted(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);
}
}