Restore the stable legacy Unity project
This commit is contained in:
parent
56a156ee87
commit
7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions
|
|
@ -1,12 +1,13 @@
|
|||
|
||||
using System;
|
||||
using static CultMath.math;
|
||||
using cfloat2 = CultMath.float2;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
|
||||
public abstract class MoveToState : BaseState
|
||||
{
|
||||
private VelocityLimit _velocityLimit;
|
||||
protected abstract cfloat2 TargetPosition { get; }
|
||||
protected abstract float2 TargetPosition { get; }
|
||||
public float Distance { get; private set; }
|
||||
|
||||
protected MoveToState(Agent agent) : base(agent)
|
||||
|
|
@ -15,13 +16,13 @@ public abstract class MoveToState : BaseState
|
|||
|
||||
public override void Update(float delta)
|
||||
{
|
||||
var diff = TargetPosition - _agent.Ship.CultPositionXZ;
|
||||
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.CultLookDirectionXZ = dir;
|
||||
_agent.Ship.LookDirection = float3(dir.x, 0, dir.y);
|
||||
_agent.Accelerate(desiredVelocity);
|
||||
}
|
||||
}
|
||||
|
|
@ -29,15 +30,15 @@ public abstract class MoveToState : BaseState
|
|||
public class MoveToEntityState : MoveToState
|
||||
{
|
||||
public Entity TargetEntity { get; set; }
|
||||
protected override cfloat2 TargetPosition => TargetEntity != null ? TargetEntity.CultPositionXZ : cfloat2.zero;
|
||||
protected override float2 TargetPosition => TargetEntity?.Position.xz ?? float2.zero;
|
||||
|
||||
public MoveToEntityState(Agent agent) : base(agent) { }
|
||||
}
|
||||
|
||||
public class MoveToOrbitState : MoveToState
|
||||
{
|
||||
public string OrbitKey { get; set; } = "";
|
||||
public Guid Orbit { get; set; }
|
||||
public MoveToOrbitState(Agent agent) : base(agent) { }
|
||||
|
||||
protected override cfloat2 TargetPosition => AetheriaMath.ToCult(_agent.Ship.Zone.GetOrbitPosition(OrbitKey));
|
||||
protected override float2 TargetPosition => _agent.Ship.Zone.GetOrbitPosition(Orbit);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue