diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 03982fd3da..b70f1847f0 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -42,7 +42,7 @@ namespace OpenRA.Traits public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyBuildComplete { void BuildingComplete(Actor self); } public interface INotifyProduction { void UnitProduced(Actor self, Actor other); } - public interface INotifyCapture { void OnCapture(Actor self, Actor captor); } + public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); } public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); } public interface IProvideHazard { IEnumerable HazardCells(Actor self); } diff --git a/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs b/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs index 846da2cf85..54dee4f418 100644 --- a/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs +++ b/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc CancelDock(self, dockedHarv); } - public void OnCapture (Actor self, Actor captor) + public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner) { if (dockedHarv == null) return; diff --git a/OpenRA.Mods.RA/Activities/CaptureBuilding.cs b/OpenRA.Mods.RA/Activities/CaptureBuilding.cs index 088459b93c..e58287a2da 100644 --- a/OpenRA.Mods.RA/Activities/CaptureBuilding.cs +++ b/OpenRA.Mods.RA/Activities/CaptureBuilding.cs @@ -27,17 +27,16 @@ namespace OpenRA.Mods.RA.Activities target.World.AddFrameEndTask(w => { // momentarily remove from world so the ownership queries don't get confused + var oldOwner = target.Owner; w.Remove(target); target.Owner = self.Owner; w.Add(target); foreach (var t in target.traits.WithInterface()) - t.OnCapture(target, self); + t.OnCapture(target, self, oldOwner, self.Owner); + + w.Remove(self); }); - - // the engineer is sacrificed. - self.World.AddFrameEndTask(w => w.Remove(self)); - return NextActivity; } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 9863fcad59..ab4ec874ed 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -211,6 +211,7 @@ + diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs index 8f53f6f10d..a15dde588c 100755 --- a/OpenRA.Mods.RA/OreRefinery.cs +++ b/OpenRA.Mods.RA/OreRefinery.cs @@ -103,7 +103,7 @@ namespace OpenRA.Mods.RA self.traits.Get().OnDock(self, harv, dockOrder); } - public void OnCapture (Actor self, Actor captor) + public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner) { // Unlink any non-docked harvs foreach (var harv in LinkedHarv) diff --git a/OpenRA.Mods.RA/OreRefineryDockAction.cs b/OpenRA.Mods.RA/OreRefineryDockAction.cs index 8be42d7320..69f9fd06ee 100644 --- a/OpenRA.Mods.RA/OreRefineryDockAction.cs +++ b/OpenRA.Mods.RA/OreRefineryDockAction.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA })); } - public void OnCapture (Actor self, Actor captor) + public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner) { if (dockedHarv == null) return; diff --git a/OpenRA.Mods.RA/StoresOre.cs b/OpenRA.Mods.RA/StoresOre.cs index 10f95aa73e..f01268efaf 100644 --- a/OpenRA.Mods.RA/StoresOre.cs +++ b/OpenRA.Mods.RA/StoresOre.cs @@ -23,9 +23,9 @@ namespace OpenRA.Mods.RA class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier, IStoreOre { - readonly PlayerResources Player; readonly StoresOreInfo Info; + PlayerResources Player; public StoresOre(Actor self, StoresOreInfo info) { Player = self.Owner.PlayerActor.traits.Get(); @@ -34,10 +34,11 @@ namespace OpenRA.Mods.RA public int Capacity { get { return Info.Capacity; } } - public void OnCapture(Actor self, Actor captor) + public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) { var ore = Stored(self); Player.TakeOre(ore); + Player = newOwner.PlayerActor.traits.Get(); Player.GiveOre(ore); } diff --git a/mods/cnc/defaults.yaml b/mods/cnc/defaults.yaml index cd4ad3a140..2992e59599 100644 --- a/mods/cnc/defaults.yaml +++ b/mods/cnc/defaults.yaml @@ -98,6 +98,12 @@ ActorTypes: c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,e1,e1,e1,e1,e1,e1,e1 MustBeDestroyed: GivesExperience: + CaptureNotification@GDI: + Race: gdi + Notification: gdicapt1.aud + CaptureNotification@NOD: + Race: nod + Notification: nodcapt1.aud ^CivBuilding: Inherits: ^Building diff --git a/mods/ra/defaults.yaml b/mods/ra/defaults.yaml index 24b26d6d14..aeb974dc42 100644 --- a/mods/ra/defaults.yaml +++ b/mods/ra/defaults.yaml @@ -93,7 +93,8 @@ MustBeDestroyed: GivesExperience: FrozenUnderFog: - + CaptureNotification: + Notification: strucap1.aud ^Wall: Category: Building Building: