From 0319b8cbdab44f27db49ee47d59cdf0c0807405a Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Thu, 24 Jul 2014 19:41:01 -0500 Subject: [PATCH 1/3] INotifyCreated --- OpenRA.Game/Traits/TraitsInterfaces.cs | 1 + OpenRA.Game/World.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 563acaeece..088f7d515a 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -63,6 +63,7 @@ namespace OpenRA.Traits public interface IValidateOrder { bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order); } public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); } public interface INotify { void Play(Player p, string notification); } + public interface INotifyCreated { void Created(Actor self); } public interface INotifyAddedToWorld { void AddedToWorld(Actor self); } public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); } public interface INotifySold { void Selling(Actor self); void Sold(Actor self); } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 50b04194e5..d58d68e474 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -188,6 +188,8 @@ namespace OpenRA public Actor CreateActor(bool addToWorld, string name, TypeDictionary initDict) { var a = new Actor(this, name, initDict); + foreach (var t in a.TraitsImplementing()) + t.Created(a); if (addToWorld) Add(a); return a; From 72a30e2157fca8948ed931f087b7a89d4f228d0c Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Thu, 24 Jul 2014 19:42:28 -0500 Subject: [PATCH 2/3] Appears to fix sticky locking of preplaced buildings --- OpenRA.Mods.RA/Buildings/Building.cs | 18 +++++++++--------- OpenRA.Mods.RA/Render/WithMakeAnimation.cs | 4 +--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index 839fad50f0..83a7e30512 100644 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -101,13 +101,13 @@ namespace OpenRA.Mods.RA.Buildings } } - public class Building : INotifyDamage, IOccupySpace, INotifyCapture, ITick, INotifySold, INotifyTransform, ISync, ITechTreePrerequisite, INotifyAddedToWorld, INotifyRemovedFromWorld + public class Building : INotifyDamage, IOccupySpace, INotifyCapture, INotifySold, INotifyTransform, ISync, ITechTreePrerequisite, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld { public readonly BuildingInfo Info; public bool BuildComplete { get; private set; } [Sync] readonly CPos topLeft; readonly Actor self; - readonly bool skipMakeAnimation; + public readonly bool UseMakeAnimation; PowerManager PlayerPower; @@ -141,7 +141,7 @@ namespace OpenRA.Mods.RA.Buildings .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info); - skipMakeAnimation = init.Contains(); + UseMakeAnimation = !init.Contains(); } public int GetPowerUsage() @@ -168,6 +168,12 @@ namespace OpenRA.Mods.RA.Buildings PlayerPower = newOwner.PlayerActor.Trait(); } + public void Created(Actor self) + { + if (!UseMakeAnimation) + NotifyBuildingComplete(self); + } + public void AddedToWorld(Actor self) { self.World.ActorMap.AddInfluence(self, this); @@ -182,12 +188,6 @@ namespace OpenRA.Mods.RA.Buildings self.World.ScreenMap.Remove(self); } - public void Tick(Actor self) - { - if (!BuildComplete && (skipMakeAnimation || !self.HasTrait())) - NotifyBuildingComplete(self); - } - public void NotifyBuildingComplete(Actor self) { if (BuildComplete) diff --git a/OpenRA.Mods.RA/Render/WithMakeAnimation.cs b/OpenRA.Mods.RA/Render/WithMakeAnimation.cs index d53d1ca9a4..484918f1c4 100644 --- a/OpenRA.Mods.RA/Render/WithMakeAnimation.cs +++ b/OpenRA.Mods.RA/Render/WithMakeAnimation.cs @@ -38,15 +38,13 @@ namespace OpenRA.Mods.RA.Render renderBuilding = self.Trait(); var building = self.Trait(); - if (!init.Contains()) + if (building.UseMakeAnimation) { renderBuilding.PlayCustomAnimThen(self, info.Sequence, () => { building.NotifyBuildingComplete(self); }); } - else - building.NotifyBuildingComplete(self); } public void Reverse(Actor self, Activity activity) From 4d23b71f2cccac9d4f6667f5c01d0c1309d8d226 Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Fri, 25 Jul 2014 19:53:23 -0500 Subject: [PATCH 3/3] Fixed D2K turrets. --- OpenRA.Mods.RA/Buildings/Building.cs | 6 +++--- OpenRA.Mods.RA/Render/WithMakeAnimation.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index 83a7e30512..b67132d957 100644 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -107,7 +107,7 @@ namespace OpenRA.Mods.RA.Buildings public bool BuildComplete { get; private set; } [Sync] readonly CPos topLeft; readonly Actor self; - public readonly bool UseMakeAnimation; + public readonly bool SkipMakeAnimation; PowerManager PlayerPower; @@ -141,7 +141,7 @@ namespace OpenRA.Mods.RA.Buildings .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info); - UseMakeAnimation = !init.Contains(); + SkipMakeAnimation = init.Contains(); } public int GetPowerUsage() @@ -170,7 +170,7 @@ namespace OpenRA.Mods.RA.Buildings public void Created(Actor self) { - if (!UseMakeAnimation) + if (SkipMakeAnimation || !self.HasTrait()) NotifyBuildingComplete(self); } diff --git a/OpenRA.Mods.RA/Render/WithMakeAnimation.cs b/OpenRA.Mods.RA/Render/WithMakeAnimation.cs index 484918f1c4..230d03ef39 100644 --- a/OpenRA.Mods.RA/Render/WithMakeAnimation.cs +++ b/OpenRA.Mods.RA/Render/WithMakeAnimation.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Render renderBuilding = self.Trait(); var building = self.Trait(); - if (building.UseMakeAnimation) + if (!building.SkipMakeAnimation) { renderBuilding.PlayCustomAnimThen(self, info.Sequence, () => {