Fix null being passed through the INotifyAttack interface

This commit is contained in:
abcdefg30
2016-10-23 22:07:03 +02:00
parent 892825aeb9
commit 19549a9068
3 changed files with 17 additions and 8 deletions

View File

@@ -31,18 +31,22 @@ namespace OpenRA.Mods.D2k.Activities
readonly Sandworm sandworm;
readonly ConditionManager conditionManager;
readonly WeaponInfo weapon;
readonly Armament armament;
readonly AttackSwallow swallow;
readonly IPositionable positionable;
readonly IFacing facing;
int countdown;
CPos burrowLocation;
AttackState stance;
int attackingToken = ConditionManager.InvalidConditionToken;
public SwallowActor(Actor self, Target target, WeaponInfo weapon)
public SwallowActor(Actor self, Target target, Armament a, IFacing facing)
{
this.target = target;
this.weapon = weapon;
this.facing = facing;
armament = a;
weapon = a.Weapon;
sandworm = self.Trait<Sandworm>();
positionable = self.Trait<Mobile>();
swallow = self.Trait<AttackSwallow>();
@@ -80,11 +84,13 @@ namespace OpenRA.Mods.D2k.Activities
foreach (var player in affectedPlayers)
self.World.AddFrameEndTask(w => w.Add(new MapNotificationEffect(player, "Speech", swallow.Info.WormAttackNotification, 25, true, attackPosition, Color.Red)));
var barrel = armament.CheckFire(self, facing, target);
if (barrel == null)
return false;
// armament.CheckFire already calls INotifyAttack.PreparingAttack
foreach (var notify in self.TraitsImplementing<INotifyAttack>())
{
notify.PreparingAttack(self, target, null, null);
notify.Attacking(self, target, null, null);
}
notify.Attacking(self, target, armament, barrel);
return true;
}

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.D2k.Traits
return;
self.CancelActivity();
self.QueueActivity(new SwallowActor(self, target, a.Weapon));
self.QueueActivity(new SwallowActor(self, target, a, facing.Value));
}
}
}