Add OnBuildingPlaced lua trigger.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
eb550bbbbb
commit
3177de7b2c
@@ -131,6 +131,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, placed.CenterPosition);
|
||||
|
||||
if (producer.Actor != null)
|
||||
foreach (var nbp in producer.Actor.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(producer.Actor, placed);
|
||||
|
||||
foreach (var nbp in self.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(self, placed);
|
||||
|
||||
// Build the connection segments
|
||||
var segmentType = actorInfo.TraitInfo<LineBuildInfo>().SegmentType;
|
||||
if (string.IsNullOrEmpty(segmentType))
|
||||
@@ -141,8 +148,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (t.Cell == targetLocation)
|
||||
continue;
|
||||
|
||||
var segment = self.World.Map.Rules.Actors[segmentType];
|
||||
var replaceableSegments = segment.TraitInfos<ReplacementInfo>()
|
||||
var segmentInfo = self.World.Map.Rules.Actors[segmentType];
|
||||
var replaceableSegments = segmentInfo.TraitInfos<ReplacementInfo>()
|
||||
.SelectMany(r => r.ReplaceableTypes)
|
||||
.ToHashSet();
|
||||
|
||||
@@ -151,7 +158,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (a.TraitsImplementing<Replaceable>().Any(r => !r.IsTraitDisabled && r.Info.Types.Overlaps(replaceableSegments)))
|
||||
self.World.Remove(a);
|
||||
|
||||
w.CreateActor(segmentType,
|
||||
var segment = w.CreateActor(segmentType,
|
||||
[
|
||||
new LocationInit(t.Cell),
|
||||
new OwnerInit(order.Player),
|
||||
@@ -160,6 +167,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
new LineBuildParentInit([t.Actor, placed]),
|
||||
new PlaceBuildingInit()
|
||||
]);
|
||||
|
||||
if (producer.Actor != null)
|
||||
foreach (var nbp in producer.Actor.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(producer.Actor, segment);
|
||||
|
||||
foreach (var nbp in self.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(self, segment);
|
||||
}
|
||||
}
|
||||
else if (os == "PlacePlug")
|
||||
@@ -201,11 +215,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, building.CenterPosition);
|
||||
}
|
||||
|
||||
if (producer.Actor != null)
|
||||
foreach (var nbp in producer.Actor.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(producer.Actor);
|
||||
if (producer.Actor != null)
|
||||
foreach (var nbp in producer.Actor.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(producer.Actor, building);
|
||||
|
||||
foreach (var nbp in self.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(self, building);
|
||||
}
|
||||
|
||||
queue.EndProduction(item);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user