Fix null being passed through the INotifyAttack interface
This commit is contained in:
@@ -156,7 +156,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
paxPos[a.Actor].SetVisualPosition(a.Actor, pos + PortOffset(self, port));
|
paxPos[a.Actor].SetVisualPosition(a.Actor, pos + PortOffset(self, port));
|
||||||
|
|
||||||
var barrel = a.CheckFire(a.Actor, facing.Value, target);
|
var barrel = a.CheckFire(a.Actor, facing.Value, target);
|
||||||
if (barrel != null && a.Info.MuzzleSequence != null)
|
if (barrel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (a.Info.MuzzleSequence != null)
|
||||||
{
|
{
|
||||||
// Muzzle facing is fixed once the firing starts
|
// Muzzle facing is fixed once the firing starts
|
||||||
var muzzleAnim = new Animation(self.World, paxRender[a.Actor].GetImage(a.Actor), () => muzzleFacing);
|
var muzzleAnim = new Animation(self.World, paxRender[a.Actor].GetImage(a.Actor), () => muzzleFacing);
|
||||||
|
|||||||
@@ -31,18 +31,22 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
readonly Sandworm sandworm;
|
readonly Sandworm sandworm;
|
||||||
readonly ConditionManager conditionManager;
|
readonly ConditionManager conditionManager;
|
||||||
readonly WeaponInfo weapon;
|
readonly WeaponInfo weapon;
|
||||||
|
readonly Armament armament;
|
||||||
readonly AttackSwallow swallow;
|
readonly AttackSwallow swallow;
|
||||||
readonly IPositionable positionable;
|
readonly IPositionable positionable;
|
||||||
|
readonly IFacing facing;
|
||||||
|
|
||||||
int countdown;
|
int countdown;
|
||||||
CPos burrowLocation;
|
CPos burrowLocation;
|
||||||
AttackState stance;
|
AttackState stance;
|
||||||
int attackingToken = ConditionManager.InvalidConditionToken;
|
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.target = target;
|
||||||
this.weapon = weapon;
|
this.facing = facing;
|
||||||
|
armament = a;
|
||||||
|
weapon = a.Weapon;
|
||||||
sandworm = self.Trait<Sandworm>();
|
sandworm = self.Trait<Sandworm>();
|
||||||
positionable = self.Trait<Mobile>();
|
positionable = self.Trait<Mobile>();
|
||||||
swallow = self.Trait<AttackSwallow>();
|
swallow = self.Trait<AttackSwallow>();
|
||||||
@@ -80,11 +84,13 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
foreach (var player in affectedPlayers)
|
foreach (var player in affectedPlayers)
|
||||||
self.World.AddFrameEndTask(w => w.Add(new MapNotificationEffect(player, "Speech", swallow.Info.WormAttackNotification, 25, true, attackPosition, Color.Red)));
|
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>())
|
foreach (var notify in self.TraitsImplementing<INotifyAttack>())
|
||||||
{
|
notify.Attacking(self, target, armament, barrel);
|
||||||
notify.PreparingAttack(self, target, null, null);
|
|
||||||
notify.Attacking(self, target, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new SwallowActor(self, target, a.Weapon));
|
self.QueueActivity(new SwallowActor(self, target, a, facing.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user