CatStation/Content.Server/Physics/Components/ChasingWalkComponent.cs
Samuka 838984971c
Xenoborg guided missile (#45247)
* update math

* target finder system

* ports

* guns with projectiles

* make sure

* custom sprites for the laser

* add auto link

* add module

* sprite for the missile

* update animation speed

* ops

* make it glow

* overlay sprite

* stuff that doesn't work

* update launcher

* fix it

* make it see from far

* make it work

* sprite for the module

* 30 seconds is too much

* sprite for the range finder

* why was that here?

* update sprite of the missile

* update module icon

* ops

* update missile and missile launcher

* make it look like the launcher item

* remove ammo counter from range finder

* increase to 15 seconds

* no longer show the battery percentage

* use comp

* change summary

* ops

* new line

* make it last longer

* commentary

* acme moment

* fix bug when shooter was also the target and the projectile wouldn't move

* empty commit

* fix test fail

* replace with global behavior

* forgot to remove from the yml

* important

* check to see if the target exists

* fix autorefill bug

* remove unused system

* make it reload a tad slower

---------

Co-authored-by: beck-thompson <beck314159@hotmail.com>
2026-08-16 05:10:57 +00:00

107 lines
3.3 KiB
C#

using Content.Server.Administration.Systems;
using Content.Server.Physics.Controllers;
using Content.Server.Weapons.Ranged.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Physics.Components;
/// <summary>
/// A component which makes its entity chasing entity with selected component.
/// </summary>
[RegisterComponent, Access(typeof(ChasingWalkSystem), typeof(AdminVerbSystem), typeof(GunSystem)), AutoGenerateComponentPause]
public sealed partial class ChasingWalkComponent : Component
{
/// <summary>
/// The next moment in time when the entity is pushed toward its goal
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
[AutoPausedField]
public TimeSpan NextImpulseTime;
/// <summary>
/// Push-to-target frequency.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float ImpulseInterval = 2f;
/// <summary>
/// The max angle the entity can turn each impulse
/// </summary>
[DataField]
public Angle MaxAngleVectorChangePerImpulse = Angle.FromDegrees(180);
/// <summary>
/// The minimum speed at which this entity will move.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MinSpeed = 1.5f;
/// <summary>
/// The maximum speed at which this entity will move.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxSpeed = 3f;
/// <summary>
/// The current speed.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Speed;
/// <summary>
/// If the entity should stop moving if they are already on top of the target
/// </summary>
[DataField]
public bool StopAtTarget = true;
/// <summary>
/// The minimum time interval in which an object can change its motion target.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float ChangeVectorMinInterval = 5f;
/// <summary>
/// The maximum time interval in which an object can change its motion target.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float ChangeVectorMaxInterval = 25f;
/// <summary>
/// The next change of direction time.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
[AutoPausedField]
public TimeSpan NextChangeVectorTime;
/// <summary>
/// List of components used to select a target to chase.
/// </summary>
[DataField]
public ComponentRegistry ChasingComponent = [];
/// <summary>
/// The maximum radius in which the entity chooses the target component to follow
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxChaseRadius = 25;
/// <summary>
/// The entity uid that is being chased.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public EntityUid? ChasingEntity;
/// <summary>
/// whether the entity should point in the direction its moving
/// </summary>
[DataField]
public bool RotateWithImpulse;
/// <summary>
/// Sprite rotation offset.
/// </summary>
[DataField]
public Angle RotationAngleOffset = Angle.Zero;
}