fish-station/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs
Rinary b6920aec99
Рефактор мехов, правки в системе медицины (#507)
* mech system, fix hands, fix fraction

* fix

* fix fake hypo

* fix triple airlocks big sizing

* fix

* upd clown hulk

* xd fix 2

* bigger exit delay

* mechs reflect changes

* guns changes

* draike up

* mechs in another category

* add equipment

* Revert "upd clown hulk"

This reverts commit b8084967040be5d442b2d4770cf7fdece1daa2a8.

* SPIN MY MECH ASS

* mech no rot

* some resprite

* no injections in hardsuits

* some species can not be injectable

* medipans can ignore armor, admeme hypospray ignore armor

* fix

* fix admeme hypo

* mob fraction fix

* rover + nt gygax add

* fix description

* fix id

* some better dome effects

* если пустая гильза в стволе -> Кнопки "казнь" не будет

* phazon added

* fix server crashes

* full rework mechs on mobstates, coils fix mechs, diagnostic hud show health bar for mechs, mechs fastest repair, add mech analyzer

* some fixes

* configure health of all mechs

* upd

* add rover to uplink

* translate bundle

* change price

* phazon construction

* fix

* fix

* Finish phazon construction

* add phazon research and recipes

* phazon construction translate

* fix

* Mech lights

* fix

* translate light action

* Mech sounds, fix damage

* fix

* fix hello sound

* upd

* fix linter

* change damagePercentage

* fix

* fix hello sound

* temp disable damage sounds

* fix battery needed on construct

* some changes

* add mech painting system as DEBUG(in dev)

* Fix yaml, durand paintings

* mech spray cans textures

* change sprite

* fix

* ripley, clarke new textures

* ripley,clarke paints

* fix

* sec pod texture

---------

Co-authored-by: Vigers Ray <60344369+VigersRay@users.noreply.github.com>
2024-10-30 10:53:00 +03:00

70 lines
2.3 KiB
C#

using Content.Shared.Interaction;
using Content.Shared.Mech.Components;
namespace Content.Shared.MouseRotator;
/// <summary>
/// This handles rotating an entity based on mouse location
/// </summary>
/// <see cref="MouseRotatorComponent"/>
public abstract class SharedMouseRotatorSystem : EntitySystem
{
[Dependency] private readonly RotateToFaceSystem _rotate = default!;
public override void Initialize()
{
base.Initialize();
SubscribeAllEvent<RequestMouseRotatorRotationEvent>(OnRequestRotation);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
// TODO maybe `ActiveMouseRotatorComponent` to avoid querying over more entities than we need?
// (if this is added to players)
// (but arch makes these fast anyway, so)
var query = EntityQueryEnumerator<MouseRotatorComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var rotator, out var xform))
{
if (rotator.GoalRotation == null)
continue;
var target = uid;
if (TryComp<MechPilotComponent>(uid, out var mechPilot))
{
target = mechPilot.Mech;
xform = Transform(mechPilot.Mech);
}
if (_rotate.TryRotateTo(
target,
rotator.GoalRotation.Value,
frameTime,
rotator.AngleTolerance,
MathHelper.DegreesToRadians(rotator.RotationSpeed),
xform))
{
// Stop rotating if we finished
rotator.GoalRotation = null;
Dirty(uid, rotator);
}
}
}
private void OnRequestRotation(RequestMouseRotatorRotationEvent msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not { } ent
|| !TryComp<MouseRotatorComponent>(ent, out var rotator))
{
Log.Error($"User {args.SenderSession.Name} ({args.SenderSession.UserId}) tried setting local rotation directly without a valid mouse rotator component attached!");
return;
}
rotator.GoalRotation = msg.Rotation;
Dirty(ent, rotator);
}
}