rules can add modifiers to map!
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Content.Server._CP14.GameTicking.Rules.Components;
|
||||
using Content.Server._CP14.Procedural;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
|
||||
namespace Content.Server._CP14.GameTicking.Rules;
|
||||
|
||||
public sealed class CP14StationAdditionalModifierRule : GameRuleSystem<CP14StationAdditionalModifierRuleComponent>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14BeforeStationLocationGenerationEvent>(OnBeforeStationLocationGeneration);
|
||||
}
|
||||
|
||||
private void OnBeforeStationLocationGeneration(CP14BeforeStationLocationGenerationEvent ev)
|
||||
{
|
||||
var query = QueryAllRules();
|
||||
while (query.MoveNext(out var uid, out var huntRule, out var gameRule))
|
||||
{
|
||||
ev.AddModifiers(huntRule.Modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Content.Shared._CP14.Procedural.Prototypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._CP14.GameTicking.Rules.Components;
|
||||
|
||||
[RegisterComponent, Access(typeof(CP14StationAdditionalModifierRule))]
|
||||
public sealed partial class CP14StationAdditionalModifierRuleComponent : Component
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public List<ProtoId<CP14ProceduralModifierPrototype>> Modifiers;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Content.Server._CP14.WeatherControl;
|
||||
/// <summary>
|
||||
/// is the controller that hangs on the prototype map. It regulates which weather rules are run and where they are run.
|
||||
/// </summary>
|
||||
[RegisterComponent, AutoGenerateComponentPause, Access(typeof(CP14WeatherControllerSystem), typeof(CP14WeatherRule))]
|
||||
[RegisterComponent, AutoGenerateComponentPause, Access(typeof(CP14WeatherControllerSystem))]
|
||||
public sealed partial class CP14WeatherControllerComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
showInVote: false
|
||||
cP14Allowed: true
|
||||
rules:
|
||||
- CP14BasicStationEventScheduler
|
||||
#- CP14BasicStationEventScheduler
|
||||
- Sandbox
|
||||
- CP14LurkerHuntRule
|
||||
|
||||
- type: gamePreset
|
||||
id: CP14Peaceful
|
||||
@@ -28,8 +29,8 @@
|
||||
description: cp14-peaceful-description
|
||||
showInVote: true
|
||||
cP14Allowed: true
|
||||
rules:
|
||||
- CP14BasicStationEventScheduler
|
||||
#rules:
|
||||
# - CP14BasicStationEventScheduler
|
||||
|
||||
- type: gamePreset
|
||||
id: CP14VampireClansBattleDouble
|
||||
@@ -40,7 +41,7 @@
|
||||
minPlayers: 20
|
||||
maxPlayers: 29
|
||||
rules:
|
||||
- CP14BasicStationEventScheduler
|
||||
#- CP14BasicStationEventScheduler
|
||||
- CP14GameRuleVampireClanBattleDouble
|
||||
|
||||
- type: gamePreset
|
||||
@@ -51,16 +52,5 @@
|
||||
cP14Allowed: true
|
||||
minPlayers: 30
|
||||
rules:
|
||||
- CP14BasicStationEventScheduler
|
||||
- CP14GameRuleVampireClanBattleTriple
|
||||
|
||||
#- type: gamePreset
|
||||
# id: CP14Survival
|
||||
# name: cp14-gamemode-survival-title
|
||||
# description: cp14-gamemode-survival-description
|
||||
# showInVote: true
|
||||
# cP14Allowed: true
|
||||
# supportedMaps: ShipMapPool
|
||||
# rules:
|
||||
# - Sandbox
|
||||
# - CP14CrashToWindlandsRule
|
||||
#- CP14BasicStationEventScheduler
|
||||
- CP14GameRuleVampireClanBattleTriple
|
||||
Reference in New Issue
Block a user