rules can add modifiers to map!

This commit is contained in:
Ed
2025-09-23 22:46:46 +03:00
parent fe8b2d1122
commit ab47b92ad2
5 changed files with 65 additions and 19 deletions

View File

@@ -49,9 +49,12 @@ public sealed class CP14LocationGenerationSystem : EntitySystem
return;
}
var ev = new CP14BeforeStationLocationGenerationEvent(ent.Comp.Modifiers);
RaiseLocalEvent(ent, ev, true);
var mapId = _transform.GetMapId(largestStationGrid.Value);
GenerateLocation(largestStationGrid.Value, mapId, ent.Comp.Location, ent.Comp.Modifiers);
GenerateLocation(largestStationGrid.Value, mapId, ent.Comp.Location, ev.Modifiers);
}
public override void Update(float frameTime)
@@ -121,3 +124,21 @@ public sealed class CP14LocationGenerationSystem : EntitySystem
}
}
}
/// <summary>
/// Called before procedural location generation on the main map so that other systems can edit modifiers added to the map.
/// </summary>
public sealed class CP14BeforeStationLocationGenerationEvent(List<ProtoId<CP14ProceduralModifierPrototype>> modifiers) : EntityEventArgs
{
public List<ProtoId<CP14ProceduralModifierPrototype>> Modifiers = modifiers;
public void AddModifier(ProtoId<CP14ProceduralModifierPrototype> toAdd)
{
Modifiers.Add(toAdd);
}
public void AddModifiers(IEnumerable<ProtoId<CP14ProceduralModifierPrototype>> toAdd)
{
Modifiers.AddRange(toAdd);
}
}