Include Armament and Barrel in INotifyAttack.

This commit is contained in:
Paul Chote
2013-08-03 16:21:57 +12:00
parent deb03e7a02
commit 755fa6eaf4
11 changed files with 17 additions and 9 deletions

View File

@@ -124,7 +124,6 @@ namespace OpenRA.Traits
}
}
public interface INotifyAttack { void Attacking(Actor self, Target target); }
public interface IRenderModifier { IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r); }
public interface IDamageModifier { float GetDamageModifier(Actor attacker, WarheadInfo warhead); }
public interface ISpeedModifier { decimal GetSpeedModifier(); }

View File

@@ -74,7 +74,8 @@ namespace OpenRA.Mods.RA.Activities
void LayMine(Actor self)
{
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
if (limitedAmmo != null) limitedAmmo.Attacking(self, Target.FromCell(self.Location));
if (limitedAmmo != null)
limitedAmmo.TakeAmmo();
self.World.AddFrameEndTask(
w => w.CreateActor(self.Info.Traits.Get<MinelayerInfo>().Mine, new TypeDictionary

View File

@@ -151,7 +151,7 @@ namespace OpenRA.Mods.RA
});
foreach (var na in self.TraitsImplementing<INotifyAttack>())
na.Attacking(self, target);
na.Attacking(self, target, this, barrel);
Recoil = Info.Recoil;

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA
base.Tick( self );
}
public void Attacking(Actor self, Target target)
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
{
--charges;
timeToRecharge = self.Info.Traits.Get<AttackTeslaInfo>().ReloadTime;

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA
remainingTime = Math.Max(remainingTime, time);
}
public void Attacking(Actor self, Target target) { Uncloak(); }
public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { Uncloak(); }
public bool Cloaked { get { return remainingTime <= 0; } }

View File

@@ -44,6 +44,7 @@ namespace OpenRA.Mods.RA
++ammo;
return true;
}
public bool TakeAmmo()
{
if (ammo <= 0) return false;
@@ -53,7 +54,7 @@ namespace OpenRA.Mods.RA
public int ReloadTimePerAmmo() { return Info.ReloadTicks; }
public void Attacking(Actor self, Target target) { TakeAmmo(); }
public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { TakeAmmo(); }
public IEnumerable<PipType> GetPips(Actor self)
{

View File

@@ -74,6 +74,11 @@ namespace OpenRA.Mods.RA.Render
anim.PlayThen(NormalizeInfantrySequence(self, "heal"), () => State = AnimationState.Idle);
}
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
{
Attacking(self, target);
}
public override void Tick(Actor self)
{
base.Tick(self);

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA.Render
}
}
public void Attacking(Actor self, Target target)
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
{
isShowing = true;
foreach( var mf in muzzleFlashes.Values )

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.RA
Panic();
}
public void Attacking(Actor self, Target target)
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
{
if (self.World.SharedRandom.Next(100 / Info.AttackPanicChance) == 0)
Panic();

View File

@@ -137,7 +137,7 @@ namespace OpenRA.Mods.RA
}
/* lose our disguise if we attack anything */
public void Attacking(Actor self, Target target) { DropDisguise(); }
public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { DropDisguise(); }
}
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> {}

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
@@ -46,4 +47,5 @@ namespace OpenRA.Mods.RA
public interface INotifyParachuteLanded { void OnLanded(); }
public interface INotifyTransform { void OnTransform(Actor self); }
public interface INotifyTransformed { void OnTransformed(Actor toActor); }
public interface INotifyAttack { void Attacking(Actor self, Target target, Armament a, Barrel barrel); }
}