Building capture eva + wtf on silo capture

This commit is contained in:
Paul Chote
2010-07-23 22:28:46 +12:00
parent 31cb2081c6
commit 52c8c93b30
9 changed files with 20 additions and 12 deletions

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Traits
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyDamage { void Damaged(Actor self, 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); } 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 IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); }
public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); } public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); }
public interface IProvideHazard { IEnumerable<HazardLayer.Hazard> HazardCells(Actor self); } public interface IProvideHazard { IEnumerable<HazardLayer.Hazard> HazardCells(Actor self); }

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc
CancelDock(self, dockedHarv); CancelDock(self, dockedHarv);
} }
public void OnCapture (Actor self, Actor captor) public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner)
{ {
if (dockedHarv == null) if (dockedHarv == null)
return; return;

View File

@@ -27,17 +27,16 @@ namespace OpenRA.Mods.RA.Activities
target.World.AddFrameEndTask(w => target.World.AddFrameEndTask(w =>
{ {
// momentarily remove from world so the ownership queries don't get confused // momentarily remove from world so the ownership queries don't get confused
var oldOwner = target.Owner;
w.Remove(target); w.Remove(target);
target.Owner = self.Owner; target.Owner = self.Owner;
w.Add(target); w.Add(target);
foreach (var t in target.traits.WithInterface<INotifyCapture>()) foreach (var t in target.traits.WithInterface<INotifyCapture>())
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; return NextActivity;
} }

View File

@@ -211,6 +211,7 @@
<Compile Include="RadarColorFromTerrain.cs" /> <Compile Include="RadarColorFromTerrain.cs" />
<Compile Include="EngineerRepair.cs" /> <Compile Include="EngineerRepair.cs" />
<Compile Include="Activities\RepairBuilding.cs" /> <Compile Include="Activities\RepairBuilding.cs" />
<Compile Include="BuildingCaptureNotification.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Mods.RA
self.traits.Get<IAcceptOreDockAction>().OnDock(self, harv, dockOrder); self.traits.Get<IAcceptOreDockAction>().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 // Unlink any non-docked harvs
foreach (var harv in LinkedHarv) foreach (var harv in LinkedHarv)

View File

@@ -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) if (dockedHarv == null)
return; return;

View File

@@ -23,9 +23,9 @@ namespace OpenRA.Mods.RA
class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier, IStoreOre class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier, IStoreOre
{ {
readonly PlayerResources Player;
readonly StoresOreInfo Info; readonly StoresOreInfo Info;
PlayerResources Player;
public StoresOre(Actor self, StoresOreInfo info) public StoresOre(Actor self, StoresOreInfo info)
{ {
Player = self.Owner.PlayerActor.traits.Get<PlayerResources>(); Player = self.Owner.PlayerActor.traits.Get<PlayerResources>();
@@ -34,10 +34,11 @@ namespace OpenRA.Mods.RA
public int Capacity { get { return Info.Capacity; } } 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); var ore = Stored(self);
Player.TakeOre(ore); Player.TakeOre(ore);
Player = newOwner.PlayerActor.traits.Get<PlayerResources>();
Player.GiveOre(ore); Player.GiveOre(ore);
} }

View File

@@ -98,6 +98,12 @@
ActorTypes: c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,e1,e1,e1,e1,e1,e1,e1 ActorTypes: c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,e1,e1,e1,e1,e1,e1,e1
MustBeDestroyed: MustBeDestroyed:
GivesExperience: GivesExperience:
CaptureNotification@GDI:
Race: gdi
Notification: gdicapt1.aud
CaptureNotification@NOD:
Race: nod
Notification: nodcapt1.aud
^CivBuilding: ^CivBuilding:
Inherits: ^Building Inherits: ^Building

View File

@@ -93,7 +93,8 @@
MustBeDestroyed: MustBeDestroyed:
GivesExperience: GivesExperience:
FrozenUnderFog: FrozenUnderFog:
CaptureNotification:
Notification: strucap1.aud
^Wall: ^Wall:
Category: Building Category: Building
Building: Building: