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%.
This commit is contained in:
SlamBamActionman
2024-03-24 23:45:52 +01:00
committed by GitHub
parent a8b714af3f
commit 8f652eaa75
4 changed files with 122 additions and 6 deletions

View File

@@ -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<ImmovableRodRuleCompon
{
base.Started(uid, component, gameRule, args);
var proto = _prototypeManager.Index<EntityPrototype>(component.RodPrototype);
var protoName = EntitySpawnCollection.GetSpawns(component.RodPrototypes).First();
var proto = _prototypeManager.Index<EntityPrototype>(protoName);
if (proto.TryGetComponent<ImmovableRodComponent>(out var rod) && proto.TryGetComponent<TimedDespawnComponent>(out var despawn))
{
TryFindRandomTile(out _, out _, out _, out var targetCoords);
@@ -27,12 +32,12 @@ public sealed class ImmovableRodRule : StationEventSystem<ImmovableRodRuleCompon
var angle = RobustRandom.NextAngle();
var direction = angle.ToVec();
var spawnCoords = targetCoords.ToMap(EntityManager, _transform).Offset(-direction * speed * despawn.Lifetime / 2);
var ent = Spawn(component.RodPrototype, spawnCoords);
var ent = Spawn(protoName, spawnCoords);
_gun.ShootProjectile(ent, direction, Vector2.Zero, uid, speed: speed);
}
else
{
Sawmill.Error($"Invalid immovable rod prototype: {component.RodPrototype}");
Sawmill.Error($"Invalid immovable rod prototype: {protoName}");
}
}
}