Add an INotifyKilled interface, which is what most things that used INotifyDamaged actually cared about.
This commit is contained in:
@@ -107,7 +107,11 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
attacker.Owner.Kills++;
|
attacker.Owner.Kills++;
|
||||||
self.Owner.Deaths++;
|
self.Owner.Deaths++;
|
||||||
|
|
||||||
|
foreach (var nd in self.TraitsImplementing<INotifyKilled>()
|
||||||
|
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyKilled>()))
|
||||||
|
nd.Killed(self, ai);
|
||||||
|
|
||||||
if( RemoveOnDeath )
|
if( RemoveOnDeath )
|
||||||
self.Destroy();
|
self.Destroy();
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace OpenRA.Traits
|
|||||||
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
||||||
public interface INotifySold { void Selling(Actor self); void Sold(Actor self); }
|
public interface INotifySold { void Selling(Actor self); void Sold(Actor self); }
|
||||||
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
||||||
|
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
||||||
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
||||||
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
||||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); }
|
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); }
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); }
|
public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeadBuildingState : INotifyDamage
|
class DeadBuildingState : INotifyKilled
|
||||||
{
|
{
|
||||||
DeadBuildingStateInfo info;
|
DeadBuildingStateInfo info;
|
||||||
RenderSimple rs;
|
RenderSimple rs;
|
||||||
@@ -31,18 +31,15 @@ namespace OpenRA.Mods.Cnc
|
|||||||
self.Trait<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
self.Trait<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
if (!rs.anim.HasSequence("dead")) return;
|
||||||
{
|
rs.anim.PlayRepeating("dead");
|
||||||
if (!rs.anim.HasSequence("dead")) return;
|
if (!info.Zombie)
|
||||||
rs.anim.PlayRepeating("dead");
|
self.World.AddFrameEndTask(
|
||||||
if (!info.Zombie)
|
w => w.Add(
|
||||||
self.World.AddFrameEndTask(
|
new DelayedAction(info.LingerTime,
|
||||||
w => w.Add(
|
() => self.Destroy())));
|
||||||
new DelayedAction(info.LingerTime,
|
|
||||||
() => self.Destroy())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
public object Create(ActorInitializer init) { return new SpawnViceroid(this); }
|
public object Create(ActorInitializer init) { return new SpawnViceroid(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpawnViceroid : INotifyDamage
|
class SpawnViceroid : INotifyKilled
|
||||||
{
|
{
|
||||||
readonly SpawnViceroidInfo Info;
|
readonly SpawnViceroidInfo Info;
|
||||||
|
|
||||||
@@ -34,9 +34,9 @@ namespace OpenRA.Mods.Cnc
|
|||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead && e.Warhead != null && e.Warhead.InfDeath == Info.InfDeath
|
if (e.Warhead != null && e.Warhead.InfDeath == Info.InfDeath
|
||||||
&& self.World.SharedRandom.Next(100) <= Info.Probability)
|
&& self.World.SharedRandom.Next(100) <= Info.Probability)
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new ActorLostNotification(this); }
|
public object Create(ActorInitializer init) { return new ActorLostNotification(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ActorLostNotification : INotifyDamage
|
class ActorLostNotification : INotifyKilled
|
||||||
{
|
{
|
||||||
ActorLostNotificationInfo Info;
|
ActorLostNotificationInfo Info;
|
||||||
public ActorLostNotification(ActorLostNotificationInfo info)
|
public ActorLostNotification(ActorLostNotificationInfo info)
|
||||||
@@ -28,15 +28,11 @@ namespace OpenRA.Mods.RA
|
|||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
var player = (Info.NotifyAll) ? self.World.LocalPlayer : self.Owner;
|
||||||
{
|
Sound.PlayToPlayer(player, Info.Notification);
|
||||||
var player = (Info.NotifyAll) ? self.World.LocalPlayer : self.Owner;
|
|
||||||
Sound.PlayToPlayer(player, Info.Notification);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
public virtual object Create( ActorInitializer init ) { return new Aircraft( init , this ); }
|
public virtual object Create( ActorInitializer init ) { return new Aircraft( init , this ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Aircraft : IMove, IFacing, IOccupySpace, ISync, INotifyDamage
|
public class Aircraft : IMove, IFacing, IOccupySpace, ISync, INotifyKilled
|
||||||
{
|
{
|
||||||
public IDisposable reservation;
|
public IDisposable reservation;
|
||||||
|
|
||||||
@@ -88,10 +88,9 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
UnReserve();
|
||||||
UnReserve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,36 +21,27 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string ChuteSound = "chute1.aud";
|
public readonly string ChuteSound = "chute1.aud";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EjectOnDeath : INotifyDamage
|
public class EjectOnDeath : INotifyKilled
|
||||||
{
|
{
|
||||||
|
public void Killed(Actor self, AttackInfo e)
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
|
||||||
{
|
{
|
||||||
if (self.IsDead())
|
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
|
||||||
|
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), new TypeDictionary { new OwnerInit(self.Owner) });
|
||||||
|
var r = self.World.SharedRandom.Next(1, 100);
|
||||||
|
var aircraft = self.Trait<IMove>();
|
||||||
|
|
||||||
|
if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10)
|
||||||
{
|
{
|
||||||
var a = self;
|
var rs = pilot.Trait<RenderSimple>();
|
||||||
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
|
self.World.AddFrameEndTask(w => w.Add(
|
||||||
var pilot = a.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), new TypeDictionary { new OwnerInit(a.Owner) });
|
new Parachute(pilot.Owner, rs.anim.Name,
|
||||||
var r = self.World.SharedRandom.Next(1, 100);
|
Util.CenterOfCell(Util.CellContaining(self.CenterLocation)),
|
||||||
var aircraft = a.Trait<IMove>();
|
aircraft.Altitude, pilot)));
|
||||||
|
|
||||||
if (IsSuitableCell(pilot, a.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10)
|
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||||
{
|
|
||||||
var rs = pilot.Trait<RenderSimple>();
|
|
||||||
|
|
||||||
|
|
||||||
a.World.AddFrameEndTask(w => w.Add(
|
|
||||||
new Parachute(pilot.Owner, rs.anim.Name,
|
|
||||||
Util.CenterOfCell(Util.CellContaining(a.CenterLocation)),
|
|
||||||
aircraft.Altitude, pilot)));
|
|
||||||
|
|
||||||
Sound.Play(info.ChuteSound, a.CenterLocation);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pilot.Destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
pilot.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSuitableCell(Actor actorToDrop, int2 p)
|
bool IsSuitableCell(Actor actorToDrop, int2 p)
|
||||||
|
|||||||
@@ -23,17 +23,14 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
public readonly bool Moves = false;
|
public readonly bool Moves = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FallsToEarth : INotifyDamage
|
class FallsToEarth : INotifyKilled
|
||||||
{
|
{
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (self.IsDead())
|
self.Trait<Health>().RemoveOnDeath = false;
|
||||||
{
|
|
||||||
self.Trait<Health>().RemoveOnDeath = false;
|
|
||||||
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get<FallsToEarthInfo>()));
|
self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get<FallsToEarthInfo>()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
public override object Create( ActorInitializer init ) { return new Plane( init, this ); }
|
public override object Create( ActorInitializer init ) { return new Plane( init, this ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Plane : Aircraft, IIssueOrder, IResolveOrder, IOrderVoice, ITick, INotifyDamage, ISync
|
public class Plane : Aircraft, IIssueOrder, IResolveOrder, IOrderVoice, ITick, ISync
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
public int2 RTBPathHash;
|
public int2 RTBPathHash;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
public object Create(ActorInitializer init) { return new ShakeOnDeath(this); }
|
public object Create(ActorInitializer init) { return new ShakeOnDeath(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ShakeOnDeath : INotifyDamage
|
public class ShakeOnDeath : INotifyKilled
|
||||||
{
|
{
|
||||||
readonly ShakeOnDeathInfo Info;
|
readonly ShakeOnDeathInfo Info;
|
||||||
public ShakeOnDeath(ShakeOnDeathInfo info)
|
public ShakeOnDeath(ShakeOnDeathInfo info)
|
||||||
@@ -29,10 +29,9 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
this.Info = info;
|
this.Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(Info.Intensity, self.CenterLocation, 1);
|
||||||
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(Info.Intensity, self.CenterLocation, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create( ActorInitializer init ) { return new Cargo( init.self ); }
|
public object Create( ActorInitializer init ) { return new Cargo( init.self ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyDamage
|
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyKilled
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
List<Actor> cargo = new List<Actor>();
|
List<Actor> cargo = new List<Actor>();
|
||||||
@@ -145,14 +145,11 @@ namespace OpenRA.Mods.RA
|
|||||||
cargo.Add(a);
|
cargo.Add(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if( e.DamageStateChanged && e.DamageState == DamageState.Dead )
|
foreach( var c in cargo )
|
||||||
{
|
c.Destroy();
|
||||||
foreach( var c in cargo )
|
cargo.Clear();
|
||||||
c.Destroy();
|
|
||||||
cargo.Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class DemoTruckInfo : TraitInfo<DemoTruck> { }
|
class DemoTruckInfo : TraitInfo<DemoTruck> { }
|
||||||
|
|
||||||
class DemoTruck : Chronoshiftable, INotifyDamage
|
class DemoTruck : Chronoshiftable, INotifyKilled
|
||||||
{
|
{
|
||||||
// Explode on chronoshift
|
// Explode on chronoshift
|
||||||
public override bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere)
|
public override bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere)
|
||||||
@@ -24,10 +24,9 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fire primary on death
|
// Fire primary on death
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
Detonate(self, e.Attacker);
|
||||||
Detonate(self, e.Attacker);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Detonate(Actor self, Actor detonatedBy)
|
public void Detonate(Actor self, Actor detonatedBy)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string[] ActorTypes = { "e1" };
|
public readonly string[] ActorTypes = { "e1" };
|
||||||
}
|
}
|
||||||
|
|
||||||
class EmitInfantryOnSell : INotifySold, INotifyDamage
|
class EmitInfantryOnSell : INotifySold, INotifyKilled
|
||||||
{
|
{
|
||||||
public void Selling(Actor self) { }
|
public void Selling(Actor self) { }
|
||||||
|
|
||||||
@@ -62,10 +62,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Sold(Actor self) { Emit(self); }
|
public void Sold(Actor self) { Emit(self); }
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
Emit(self);
|
||||||
Emit(self);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,22 +23,19 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int Chance = 100;
|
public readonly int Chance = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Explodes : INotifyDamage
|
class Explodes : INotifyKilled
|
||||||
{
|
{
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
if (self.World.SharedRandom.Next(100) > self.Info.Traits.Get<ExplodesInfo>().Chance)
|
||||||
{
|
return;
|
||||||
if (self.World.SharedRandom.Next(100) > self.Info.Traits.Get<ExplodesInfo>().Chance)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var weapon = ChooseWeaponForExplosion(self);
|
var weapon = ChooseWeaponForExplosion(self);
|
||||||
if (weapon != null)
|
if (weapon != null)
|
||||||
{
|
{
|
||||||
var move = self.TraitOrDefault<IMove>();
|
var move = self.TraitOrDefault<IMove>();
|
||||||
var altitude = move != null ? move.Altitude : 0;
|
var altitude = move != null ? move.Altitude : 0;
|
||||||
Combat.DoExplosion(e.Attacker, weapon, self.CenterLocation, altitude);
|
Combat.DoExplosion(e.Attacker, weapon, self.CenterLocation, altitude);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int LevelMod = 125;
|
public readonly int LevelMod = 125;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GivesBounty : INotifyDamage
|
class GivesBounty : INotifyKilled
|
||||||
{
|
{
|
||||||
|
|
||||||
int GetMultiplier(Actor self)
|
int GetMultiplier(Actor self)
|
||||||
@@ -34,26 +34,22 @@ namespace OpenRA.Mods.RA
|
|||||||
return (slevel > 0) ? slevel * info.LevelMod : 100;
|
return (slevel > 0) ? slevel * info.LevelMod : 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
||||||
{
|
// Prevent TK from giving Bounty
|
||||||
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[self.Owner] == Stance.Ally)
|
||||||
// Prevent TK from giving Bounty
|
return;
|
||||||
if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[self.Owner] == Stance.Ally)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var valued = self.Info.Traits.GetOrDefault<ValuedInfo>();
|
var valued = self.Info.Traits.GetOrDefault<ValuedInfo>();
|
||||||
var cost = valued != null ? valued.Cost : 0;
|
var cost = valued != null ? valued.Cost : 0;
|
||||||
// 2 hundreds because of GetMultiplier and info.Percentage.
|
// 2 hundreds because of GetMultiplier and info.Percentage.
|
||||||
var bounty = (int)(cost * GetMultiplier(self) * info.Percentage / 10000);
|
var bounty = cost * GetMultiplier(self) * info.Percentage / 10000;
|
||||||
|
|
||||||
if (e.Attacker.World.LocalPlayer != null && e.Attacker.Owner.Stances[e.Attacker.World.LocalPlayer] == Stance.Ally)
|
if (e.Attacker.World.LocalPlayer != null && e.Attacker.Owner.Stances[e.Attacker.World.LocalPlayer] == Stance.Ally)
|
||||||
e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(bounty, 20, 1, self.CenterLocation, e.Attacker.Owner.ColorRamp.GetColor(0))));
|
e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(bounty, 20, 1, self.CenterLocation, e.Attacker.Owner.ColorRamp.GetColor(0))));
|
||||||
|
|
||||||
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,27 +14,24 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class GivesExperienceInfo : TraitInfo<GivesExperience> { public readonly int Experience = -1; }
|
class GivesExperienceInfo : TraitInfo<GivesExperience> { public readonly int Experience = -1; }
|
||||||
|
|
||||||
class GivesExperience : INotifyDamage
|
class GivesExperience : INotifyKilled
|
||||||
{
|
{
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
// Prevent TK from giving exp
|
||||||
{
|
if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally )
|
||||||
// Prevent TK from giving exp
|
return;
|
||||||
if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[ self.Owner ] == Stance.Ally )
|
|
||||||
return;
|
|
||||||
|
|
||||||
var info = self.Info.Traits.Get<GivesExperienceInfo>();
|
var info = self.Info.Traits.Get<GivesExperienceInfo>();
|
||||||
var valued = self.Info.Traits.GetOrDefault<ValuedInfo>();
|
var valued = self.Info.Traits.GetOrDefault<ValuedInfo>();
|
||||||
|
|
||||||
var exp = info.Experience >= 0
|
var exp = info.Experience >= 0
|
||||||
? info.Experience
|
? info.Experience
|
||||||
: valued != null ? valued.Cost : 0;
|
: valued != null ? valued.Cost : 0;
|
||||||
|
|
||||||
var killer = e.Attacker.TraitOrDefault<GainsExperience>();
|
var killer = e.Attacker.TraitOrDefault<GainsExperience>();
|
||||||
if (killer != null)
|
if (killer != null)
|
||||||
killer.GiveExperience(exp);
|
killer.GiveExperience(exp);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,30 +19,29 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string HuskActor = null;
|
public readonly string HuskActor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class LeavesHusk : INotifyDamage
|
class LeavesHusk : INotifyKilled
|
||||||
{
|
{
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
self.World.AddFrameEndTask(w =>
|
||||||
self.World.AddFrameEndTask(w =>
|
{
|
||||||
|
var info = self.Info.Traits.Get<LeavesHuskInfo>();
|
||||||
|
var td = new TypeDictionary
|
||||||
{
|
{
|
||||||
var info = self.Info.Traits.Get<LeavesHuskInfo>();
|
new LocationInit( self.Location ),
|
||||||
var td = new TypeDictionary
|
new OwnerInit( self.Owner ),
|
||||||
{
|
new SkipMakeAnimsInit()
|
||||||
new LocationInit( self.Location ),
|
};
|
||||||
new OwnerInit( self.Owner ),
|
|
||||||
new SkipMakeAnimsInit()
|
if (self.HasTrait<IFacing>())
|
||||||
};
|
td.Add(new FacingInit( self.Trait<IFacing>().Facing ));
|
||||||
|
|
||||||
if (self.HasTrait<IFacing>())
|
|
||||||
td.Add(new FacingInit( self.Trait<IFacing>().Facing ));
|
|
||||||
|
|
||||||
var husk = w.CreateActor(info.HuskActor, td);
|
var husk = w.CreateActor(info.HuskActor, td);
|
||||||
var turreted = self.TraitOrDefault<Turreted>();
|
var turreted = self.TraitOrDefault<Turreted>();
|
||||||
if (turreted != null)
|
if (turreted != null)
|
||||||
foreach (var p in husk.TraitsImplementing<ThrowsParticle>())
|
foreach (var p in husk.TraitsImplementing<ThrowsParticle>())
|
||||||
p.InitialFacing = turreted.turretFacing;
|
p.InitialFacing = turreted.turretFacing;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public virtual object Create(ActorInitializer init) { return new OreRefinery(init.self, this); }
|
public virtual object Create(ActorInitializer init) { return new OreRefinery(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OreRefinery : ITick, IAcceptOre, INotifyDamage, INotifySold, INotifyCapture, IExplodeModifier, ISync
|
public class OreRefinery : ITick, IAcceptOre, INotifyKilled, INotifySold, INotifyCapture, IExplodeModifier, ISync
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly OreRefineryInfo Info;
|
readonly OreRefineryInfo Info;
|
||||||
@@ -110,14 +110,11 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged (Actor self, AttackInfo e)
|
public void Killed (Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
CancelDock(self);
|
||||||
{
|
foreach (var harv in GetLinkedHarvesters())
|
||||||
CancelDock(self);
|
harv.Trait.UnlinkProc(harv.Actor, self);
|
||||||
foreach (var harv in GetLinkedHarvesters())
|
|
||||||
harv.Trait.UnlinkProc(harv.Actor, self);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDock (Actor harv, DeliverResources dockOrder)
|
public void OnDock (Actor harv, DeliverResources dockOrder)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public override object Create(ActorInitializer init) { return new RenderInfantry(init.self, this); }
|
public override object Create(ActorInitializer init) { return new RenderInfantry(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage, INotifyIdle
|
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyKilled, INotifyIdle
|
||||||
{
|
{
|
||||||
public enum AnimationState
|
public enum AnimationState
|
||||||
{
|
{
|
||||||
@@ -117,14 +117,11 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
var death = e.Warhead != null ? e.Warhead.InfDeath : 0;
|
||||||
{
|
Sound.PlayVoice("Die", self, self.Owner.Country.Race);
|
||||||
var death = e.Warhead != null ? e.Warhead.InfDeath : 0;
|
self.World.AddFrameEndTask(w => w.Add(new Corpse(self, death)));
|
||||||
Sound.PlayVoice("Die", self, self.Owner.Country.Race);
|
|
||||||
self.World.AddFrameEndTask(w => w.Add(new Corpse(self, death)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class ReservableInfo : TraitInfo<Reservable> {}
|
class ReservableInfo : TraitInfo<Reservable> {}
|
||||||
|
|
||||||
public class Reservable : ITick, INotifyDamage, INotifyCapture, INotifySold
|
public class Reservable : ITick, INotifyKilled, INotifyCapture, INotifySold
|
||||||
{
|
{
|
||||||
Actor reservedFor;
|
Actor reservedFor;
|
||||||
Aircraft herp;
|
Aircraft herp;
|
||||||
@@ -52,9 +52,9 @@ namespace OpenRA.Mods.RA
|
|||||||
return res != null && res.reservedFor != null;
|
return res != null && res.reservedFor != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (herp != null && e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
if (herp != null)
|
||||||
herp.UnReserve();
|
herp.UnReserve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new StoresOre(init.self, this); }
|
public object Create(ActorInitializer init) { return new StoresOre(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier, IStoreOre, ISync
|
class StoresOre : IPips, INotifyCapture, INotifyKilled, IExplodeModifier, IStoreOre, ISync
|
||||||
{
|
{
|
||||||
readonly StoresOreInfo Info;
|
readonly StoresOreInfo Info;
|
||||||
|
|
||||||
@@ -45,10 +45,9 @@ namespace OpenRA.Mods.RA
|
|||||||
Player.GiveOre(ore);
|
Player.GiveOre(ore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (self.IsDead())
|
Player.TakeOre(Stored); // Lose the stored ore
|
||||||
Player.TakeOre(Stored); // Lose the stored ore
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public override object Create(ActorInitializer init) { return new GpsPower(init.self, this); }
|
public override object Create(ActorInitializer init) { return new GpsPower(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class GpsPower : SupportPower, INotifyDamage, ISync, INotifyStanceChanged, INotifySold
|
class GpsPower : SupportPower, INotifyKilled, ISync, INotifyStanceChanged, INotifySold
|
||||||
{
|
{
|
||||||
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { }
|
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { }
|
||||||
|
|
||||||
@@ -48,20 +48,9 @@ namespace OpenRA.Mods.RA
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Selling(Actor self)
|
public void Selling(Actor self) { DisableGps(); }
|
||||||
{
|
|
||||||
DisableGps();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Sold(Actor self) { }
|
public void Sold(Actor self) { }
|
||||||
|
public void Killed(Actor self, AttackInfo e) { DisableGps(); }
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
|
||||||
{
|
|
||||||
if (e.DamageState == DamageState.Dead)
|
|
||||||
{
|
|
||||||
DisableGps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisableGps()
|
void DisableGps()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user