From 8f652eaa7560a47a750173d716426dcd1ad7c01b Mon Sep 17 00:00:00 2001 From: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Date: Sun, 24 Mar 2024 23:45:52 +0100 Subject: [PATCH] Immovable Rod visual variations (#25932) * Adds variations to immovable rod * slash oopsie * Changed prototypes from being hardcoded to being defined in the rules component * Changed from 10% chance to 5% * Changes based on feedback * Fix nullable error * Moved randomized logic to .yaml. Probabilities of alternate rods add up to 5%. --- .../Components/ImmovableRodRuleComponent.cs | 7 +- .../StationEvents/Events/ImmovableRodRule.cs | 13 ++- .../Entities/Objects/Fun/immovable_rod.yml | 83 +++++++++++++++++++ Resources/Prototypes/GameRules/events.yml | 25 ++++++ 4 files changed, 122 insertions(+), 6 deletions(-) diff --git a/Content.Server/StationEvents/Components/ImmovableRodRuleComponent.cs b/Content.Server/StationEvents/Components/ImmovableRodRuleComponent.cs index 95c3265207..7b35dd9a14 100644 --- a/Content.Server/StationEvents/Components/ImmovableRodRuleComponent.cs +++ b/Content.Server/StationEvents/Components/ImmovableRodRuleComponent.cs @@ -1,4 +1,5 @@ using Content.Server.StationEvents.Events; +using Content.Shared.Storage; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; @@ -7,6 +8,8 @@ namespace Content.Server.StationEvents.Components; [RegisterComponent, Access(typeof(ImmovableRodRule))] public sealed partial class ImmovableRodRuleComponent : Component { - [DataField("rodPrototype", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string RodPrototype = "ImmovableRodKeepTilesStill"; + /// List of possible rods and spawn probabilities. + /// + [DataField] + public List RodPrototypes = new(); } diff --git a/Content.Server/StationEvents/Events/ImmovableRodRule.cs b/Content.Server/StationEvents/Events/ImmovableRodRule.cs index a61c6b69e1..1b8fb6be1f 100644 --- a/Content.Server/StationEvents/Events/ImmovableRodRule.cs +++ b/Content.Server/StationEvents/Events/ImmovableRodRule.cs @@ -3,9 +3,11 @@ using Content.Server.GameTicking.Rules.Components; using Content.Server.ImmovableRod; using Content.Server.StationEvents.Components; using Content.Server.Weapons.Ranged.Systems; -using Robust.Shared.Spawners; +using Content.Shared.Storage; using Robust.Shared.Prototypes; +using Robust.Shared.Random; using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; +using System.Linq; namespace Content.Server.StationEvents.Events; @@ -19,7 +21,10 @@ public sealed class ImmovableRodRule : StationEventSystem(component.RodPrototype); + var protoName = EntitySpawnCollection.GetSpawns(component.RodPrototypes).First(); + + var proto = _prototypeManager.Index(protoName); + if (proto.TryGetComponent(out var rod) && proto.TryGetComponent(out var despawn)) { TryFindRandomTile(out _, out _, out _, out var targetCoords); @@ -27,12 +32,12 @@ public sealed class ImmovableRodRule : StationEventSystem