Files
tbd-station-14/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs
Moony 130302a262 Adds twenty-one new smites, moves the explosion smite to the verb category. (#8456)
* Adds seven new smites, moves the explosion smite to the verb category.

* adds even more smites.

* Even more smites, some messages for specific smites.

* Adds even more smites.

* Removes some junk, adds a smite that angers the pointing arrows.

* get rid of dumb component.

* Remove mistake from verb menu presentation.

* How did that happen?

* whoops

* c

* e

* fuck

* Loading...

* removes the BoM go away

* adds the funny kill sign. Fixes ghost smite.

* Move systems around.

* Adjust organ vomit.

* Adds a smite that turns people into an instrument, and one that removes their gravity.

* oops

* typo

Co-authored-by: Veritius <veritiusgaming@gmail.com>
2022-05-27 00:41:18 -07:00

117 lines
4.3 KiB
C#

using System.Linq;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Pointing.Components;
using Content.Shared.MobState.Components;
using Content.Shared.Pointing.Components;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Random;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Server.Pointing.EntitySystems
{
[UsedImplicitly]
internal sealed class RoguePointingSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ExplosionSystem _explosion = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RoguePointingArrowComponent, ComponentStartup>(OnStartup);
}
private void OnStartup(EntityUid uid, RoguePointingArrowComponent component, ComponentStartup args)
{
if (EntityManager.TryGetComponent(uid, out SpriteComponent? sprite))
{
sprite.DrawDepth = (int) DrawDepth.Overlays;
}
}
private EntityUid? RandomNearbyPlayer(EntityUid uid, RoguePointingArrowComponent? component = null, TransformComponent? transform = null)
{
if (!Resolve(uid, ref component, ref transform))
return null;
var targets = EntityQuery<PointingArrowAngeringComponent>().ToList();
if (targets.Count == 0)
return null;
var angering = _random.Pick(targets);
angering.RemainingAnger -= 1;
if (angering.RemainingAnger <= 0)
RemComp<PointingArrowAngeringComponent>(uid);
return angering.Owner;
}
private void UpdateAppearance(EntityUid uid, RoguePointingArrowComponent? component = null, TransformComponent? transform = null, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref component, ref transform, ref appearance) || component.Chasing == null)
return;
appearance.SetData(RoguePointingArrowVisuals.Rotation, transform.LocalRotation.Degrees);
}
public void SetTarget(EntityUid arrow, EntityUid target, RoguePointingArrowComponent? component = null)
{
if (!Resolve(arrow, ref component))
throw new ArgumentException("Input was not a rogue pointing arrow!", nameof(arrow));
component.Chasing = target;
}
public override void Update(float frameTime)
{
foreach (var (component, transform) in EntityManager.EntityQuery<RoguePointingArrowComponent, TransformComponent>())
{
var uid = component.Owner;
component.Chasing ??= RandomNearbyPlayer(uid, component, transform);
if (component.Chasing is not {Valid: true} chasing || Deleted(chasing))
{
EntityManager.QueueDeleteEntity(uid);
return;
}
component.TurningDelay -= frameTime;
if (component.TurningDelay > 0)
{
var difference = EntityManager.GetComponent<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
var angle = difference.ToAngle();
var adjusted = angle.Degrees + 90;
var newAngle = Angle.FromDegrees(adjusted);
transform.LocalRotation = newAngle;
UpdateAppearance(uid, component, transform);
return;
}
transform.WorldRotation += Angle.FromDegrees(20);
UpdateAppearance(uid, component, transform);
var toChased = EntityManager.GetComponent<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
transform.WorldPosition += toChased * frameTime * component.ChasingSpeed;
component.ChasingTime -= frameTime;
if (component.ChasingTime > 0)
{
return;
}
_explosion.QueueExplosion(uid, ExplosionSystem.DefaultExplosionPrototypeId, 50, 3, 10);
EntityManager.QueueDeleteEntity(uid);
}
}
}
}