Files
wwdpublic/Content.Shared/_Shitcode/Wizard/Projectiles/HomingProjectileSystem.cs
Kai5 091a8ff433 [GoobPort] WIZ REAL (#465)
* Уэээээээ

* Почти настрадались

* Скоро конец....

* СКОРО

* Мышки плакали, кололись, но продолжали упорно жрать кактус

* Все ближе!

* Это такой конец?

* Книжка говна

* фиксики

* ОНО ЖИВОЕ

* Телепорт

* разное

* Added byond

* ивенты теперь работают

* Разфикс телепорта

* Свет мой зеркальце скажи, да всю правду доложи - Я ль робастней всех на свете?

* Разное

* Еще многа всего

* Многа разнава

* Скоро конец....

* ЭТО КОНЕЦ

* Фикс линтера (ну, или я на это надеюсь)

* Еще один фикс линтера

* Победа!

* фиксики

* пу пу пу

* Фикс подмастерья

* Мисклик

* Высокочастотный меч

* Неймспейсы

* Пул способностей мага
2025-04-26 10:18:58 +03:00

75 lines
2.6 KiB
C#

// SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 Aviu00 <93730715+Aviu00@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 Misandry <mary@thughunt.ing>
// SPDX-FileCopyrightText: 2025 gus <august.eymann@gmail.com>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
using Content.Shared._Shitcode.Wizard.TimeStop;
using Content.Shared.Interaction;
using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
namespace Content.Shared._Shitcode.Wizard.Projectiles;
public sealed class HomingProjectileSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly RotateToFaceSystem _rotate = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly INetManager _net = default!;
private EntityQuery<TransformComponent> _xformQuery;
private EntityQuery<FrozenComponent> _frozenQuery;
public override void Initialize()
{
base.Initialize();
_xformQuery = GetEntityQuery<TransformComponent>();
_frozenQuery = GetEntityQuery<FrozenComponent>();
}
public override void Update(float frameTime)
{
base.Update(frameTime);
if (_net.IsClient)
return;
var query =
EntityQueryEnumerator<HomingProjectileComponent, PhysicsComponent, TransformComponent, FixturesComponent>();
while (query.MoveNext(out var uid, out var homing, out var physics, out var xform, out var fix))
{
homing.HomingAccumulator -= frameTime;
if (homing.HomingAccumulator >= 0)
continue;
homing.HomingAccumulator = homing.HomingTime;
if (_frozenQuery.HasComp(uid))
continue;
if (!_xformQuery.TryComp(homing.Target, out var targetXform))
continue;
var goalAngle = (_transform.GetMapCoordinates(targetXform).Position -
_transform.GetMapCoordinates(xform).Position).ToWorldAngle();
var speed = float.MaxValue;
if (homing.HomingSpeed != null)
speed = MathHelper.DegreesToRadians(homing.HomingSpeed.Value);
_rotate.TryRotateTo(uid, goalAngle, frameTime, homing.Tolerance, speed, xform);
var projectileSpeed = physics.LinearVelocity.Length();
var velocity = _transform.GetWorldRotation(xform).ToWorldVec() * projectileSpeed;
_physics.SetLinearVelocity(uid, velocity, true, true, fix, physics);
}
}
}