Added extensibility points to LayMines activity:

Provides two callbacks using INotifyMineLaying interface: MineLaying (just before laying a mine), MineLaid after mine actor has been created (in FrameEndTask)
This commit is contained in:
michaeldgg2
2023-06-24 14:23:00 +02:00
committed by abcdefg30
parent 22b39f35aa
commit dccb3ce9ce
2 changed files with 16 additions and 4 deletions

View File

@@ -147,11 +147,20 @@ namespace OpenRA.Mods.Common.Activities
pool.TakeAmmo(self, minelayer.Info.AmmoUsage);
}
self.World.AddFrameEndTask(w => w.CreateActor(minelayer.Info.Mine, new TypeDictionary
foreach (var t in self.TraitsImplementing<INotifyMineLaying>())
t.MineLaying(self, self.Location);
self.World.AddFrameEndTask(w =>
{
new LocationInit(self.Location),
new OwnerInit(self.Owner),
}));
var mine = w.CreateActor(minelayer.Info.Mine, new TypeDictionary
{
new LocationInit(self.Location),
new OwnerInit(self.Owner),
});
foreach (var t in self.TraitsImplementing<INotifyMineLaying>())
t.MineLaid(self, mine);
});
}
}
}

View File

@@ -158,6 +158,9 @@ namespace OpenRA.Mods.Common.Traits
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced, string productionType, TypeDictionary init); }
public interface INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); }
[RequireExplicitImplementation]
public interface INotifyMineLaying { void MineLaying(Actor self, CPos location); void MineLaid(Actor self, Actor mine); }
[RequireExplicitImplementation]
public interface INotifyDockHost { void Docked(Actor self, Actor client); void Undocked(Actor self, Actor client); }
[RequireExplicitImplementation]