diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index fb142aff40..875e4cb158 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -97,7 +97,6 @@ namespace OpenRA.Traits .Concat(self.Owner.PlayerActor.TraitsImplementing())) nd.Damaged(self, ai); - if (DamageState != oldState) foreach (var nd in self.TraitsImplementing()) nd.DamageStateChanged(self, ai); diff --git a/OpenRA.Mods.RA/Cargo.cs b/OpenRA.Mods.RA/Cargo.cs index 726506c521..a382276248 100644 --- a/OpenRA.Mods.RA/Cargo.cs +++ b/OpenRA.Mods.RA/Cargo.cs @@ -9,6 +9,8 @@ #endregion using System.Collections.Generic; +using System.Linq; +using OpenRA.FileFormats; using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Orders; using OpenRA.Traits; @@ -22,7 +24,7 @@ namespace OpenRA.Mods.RA public readonly string[] Types = { }; public readonly int UnloadFacing = 0; - public object Create( ActorInitializer init ) { return new Cargo( init.self, this ); } + public object Create( ActorInitializer init ) { return new Cargo( init, this ); } } public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyKilled @@ -34,7 +36,17 @@ namespace OpenRA.Mods.RA List cargo = new List(); public IEnumerable Passengers { get { return cargo; } } - public Cargo( Actor self, CargoInfo info ) { this.self = self; this.info = info; } + public Cargo( ActorInitializer init, CargoInfo info ) + { + this.self = init.self; + this.info = info; + + if (init.Contains()) + { + cargo = init.Get().ToList(); + totalWeight = cargo.Sum( c => GetWeight(c) ); + } + } public IEnumerable Orders { @@ -149,4 +161,12 @@ namespace OpenRA.Mods.RA public interface INotifyPassengerEntered { void PassengerEntered(Actor self, Actor passenger); } public interface INotifyPassengerExited { void PassengerExited(Actor self, Actor passenger); } + + public class CargoInit : IActorInit + { + [FieldFromYamlKey] public readonly Actor[] value = {}; + public CargoInit() { } + public CargoInit( Actor[] init ) { value = init; } + public Actor[] Value( World world ) { return value; } + } }