Aetheria/Assets/Scripts/ServerShared/Agents/States/MoveTo.cs
Meta Vens cc7f2c8877 Remove dead code, unused plugins, and multiplayer remnants
Delete Economy.Server/Economy.Shared, LiteNetLib, network message types,
the texture-based Gravity duplicate, unreferenced scripts and agent
states, and unused plugins (MSAGL, NaughtyAttributes, AsyncAwaitUtil,
Allegorithmic, Localization samples, MrtTest, ThinkGear, QuickGraph),
plus vendored sample scenes, root zips/logs, and the stray Obsidian
folder. MainMenu logs faulted galaxy-generation tasks directly instead of
AsyncAwaitUtil's WrapErrors. Stop tracking UserSettings and the Wwise
.backup folder; ignore generated .sln/.csproj by pattern.

Game-system test scenes are kept. Playdead stays: VolumeCloudRenderer
derives from its EffectBase.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-11 22:14:57 +02:00

36 lines
1 KiB
C#

using System;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
public abstract class MoveToState : BaseState
{
private VelocityLimit _velocityLimit;
protected abstract float2 TargetPosition { get; }
public float Distance { get; private set; }
protected MoveToState(Agent agent) : base(agent)
{
}
public override void Update(float delta)
{
var diff = TargetPosition - _agent.Ship.Position.xz;
var dir = normalize(diff);
Distance = length(diff);
// We want to go top speed in the direction of our target
var desiredVelocity = dir * _agent.TopSpeed;
_agent.Ship.LookDirection = float3(dir.x, 0, dir.y);
_agent.Accelerate(desiredVelocity);
}
}
public class MoveToOrbitState : MoveToState
{
public Guid Orbit { get; set; }
public MoveToOrbitState(Agent agent) : base(agent) { }
protected override float2 TargetPosition => _agent.Ship.Zone.GetOrbitPosition(Orbit);
}