mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-11 19:31:12 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
46 lines
1.9 KiB
C#
46 lines
1.9 KiB
C#
using System.Linq;
|
|
using System.Numerics;
|
|
using Content.Server.ImmovableRod;
|
|
using Content.Server.StationEvents.Components;
|
|
using Content.Server.Weapons.Ranged.Systems;
|
|
using Content.Shared.GameTicking.Components;
|
|
using Content.Shared.Storage;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Spawners;
|
|
|
|
namespace Content.Server.StationEvents.Events;
|
|
|
|
public sealed partial class ImmovableRodRule : StationEventSystem<ImmovableRodRuleComponent>
|
|
{
|
|
[Dependency] private SharedTransformSystem _transform = default!;
|
|
[Dependency] private GunSystem _gun = default!;
|
|
[Dependency] private IPrototypeManager _prototypeManager = default!;
|
|
|
|
protected override void Started(EntityUid uid, ImmovableRodRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
|
{
|
|
base.Started(uid, component, gameRule, args);
|
|
|
|
var protoName = EntitySpawnCollection.GetSpawns(component.RodPrototypes).First();
|
|
|
|
var proto = _prototypeManager.Index<EntityPrototype>(protoName);
|
|
|
|
if (proto.TryComp<ImmovableRodComponent>(out var rod, EntityManager.ComponentFactory) &&
|
|
proto.TryComp<TimedDespawnComponent>(out var despawn, EntityManager.ComponentFactory))
|
|
{
|
|
if (!Station.TryFindRandomTile(out _, out _, out _, out var targetCoords))
|
|
return;
|
|
|
|
var speed = RobustRandom.NextFloat(rod.MinSpeed, rod.MaxSpeed);
|
|
var angle = RobustRandom.NextAngle();
|
|
var direction = angle.ToVec();
|
|
var mapCoords = _transform.ToMapCoordinates(targetCoords);
|
|
var spawnCoords = mapCoords.Offset(-direction * speed * despawn.Lifetime / 2);
|
|
var ent = Spawn(protoName, spawnCoords);
|
|
_gun.ShootProjectile(ent, direction, Vector2.Zero, uid, speed: speed);
|
|
}
|
|
else
|
|
{
|
|
Sawmill.Error($"Invalid immovable rod prototype: {protoName}");
|
|
}
|
|
}
|
|
}
|