CatStation/Content.Server/EntityEffects/Effects/Smite/HomingRodEntityEffectSystem.cs
AndrewFenriz 53e29ab962
Move admin smites to prototypes (#45550)
* Add prototype-backed admin verb framework

* Add reusable admin verb operations

* Add smite-specific admin operations

* Migrate admin smites to prototypes

* More docs for god of docs

* We dont have prediction here, so...

* Final cleanup

* Fix adminSmite

* Add segment display control

* Add generic thermoregulator

* Add thermobath systems

* Replace hotplate with thermobath

* Refine thermobath layout

* move simple smites to effects

* move comps to effects

* move add action to effect

* move add mind role to effect

* move add user interfaces to effect

* move godmode to effect

* move eye zoom to effect

* move speed swap to effect

* move spill bloodstream to effect

* move remove organs to effect

* move cream pie to effect

* move slip to effect

* fix server effect usings

* move homing rod to effect

* move locker stuff to effect

* move tabletop dimension to effect

* move pinball to effect

* move yeet to effect

* move silicon laws to effect

* move ghost kick to effect

* remove admin operations

* revert sht

* remove BOM

* use admin verb prototypes for smites

* add heart attack smite prototype

* docs update

* fix AdminSmiteVomitOrgans

* split and move to shared

* move to shared

* move to shared and predict

* PredictedQueueDel

* fix Popup

* fix HomingRod

* port DeleteEntityEntityEffectSystem

* fix StuffIntoLockerEntityEffectSystem

* upd

* fix eye

* fix movement

* fix!!

* fix and doc

* Add admin verb category prototype

* upd AdminVerbPrototype

* split verbs

* SuperSuperSuperBonk

* Update PopupMessageEntityEffectSystem.cs

* fields

---------

Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
2026-09-18 19:01:16 +00:00

45 lines
1.7 KiB
C#

using System.Numerics;
using Content.Server.Physics.Components;
using Content.Shared.EntityEffects;
using Content.Shared.EntityEffects.Effects.Smite;
using Content.Shared.Movement.Components;
using Robust.Shared.Random;
using Robust.Shared.Spawners;
namespace Content.Server.EntityEffects.Effects.Smite;
/// <summary>
/// Spawns a rod at a distance and makes it chase this entity.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T, TEffect}"/>
public sealed partial class HomingRodEntityEffectSystem : EntityEffectSystem<MetaDataComponent, HomingRod>
{
[Dependency] private IRobustRandom _random = default!;
[Dependency] private SharedTransformSystem _transform = default!;
protected override void Effect(Entity<MetaDataComponent> entity, ref EntityEffectEvent<HomingRod> args)
{
var speed = args.Effect.Speed;
if (args.Effect.MatchTargetSprintSpeed &&
TryComp<MovementSpeedModifierComponent>(entity, out var movement))
speed = movement.CurrentSprintSpeed + 0.001f;
if (speed <= 0)
return;
var offset = _random.NextAngle().RotateVec(new Vector2(args.Effect.Distance, 0));
var spawnCoords = _transform.GetMapCoordinates(entity).Offset(offset);
var rod = Spawn(args.Effect.Prototype, spawnCoords);
EnsureComp<ChasingWalkComponent>(rod, out var chasing);
chasing.NextChangeVectorTime = TimeSpan.MaxValue;
chasing.ChasingEntity = entity.Owner;
chasing.ImpulseInterval = 0.1f;
chasing.RotateWithImpulse = true;
chasing.MaxSpeed = speed;
chasing.Speed = speed;
if (TryComp<TimedDespawnComponent>(rod, out var despawn))
despawn.Lifetime = offset.Length() / speed * 3;
}
}