Files
Neutron/src/GamePort/Application/JetpackVisuals.cs
T

32 lines
1.1 KiB
C#

using System.Numerics;
using GamePort.Assets;
using GamePort.Game;
namespace GamePort.Application;
/// <summary>Original C3DJetpackFire DEFAULT shape/texture, following the owner root/Euler.</summary>
public sealed class JetpackVisuals
{
private readonly MorphAnimation clip;
private readonly int offset;
private readonly MeshDraw draw;
public Mesh Mesh { get; }
public JetpackVisuals(Mesh combined, string preparedRoot)
{
clip = new MorphAnimation(Path.Combine(preparedRoot, "actors/jetpack/fire/animation.json"));
offset = combined.Vertices.Length;
Mesh = clip.AppendTo(combined, int.MinValue + 10_000);
draw = Mesh.Draws[^1]; draw.Visible = false;
}
public void Update(Mesh destination, LabSimulation owner)
{
draw.Visible = owner.JetpackEffectVisible;
if (!draw.Visible) return;
var model = Matrix4x4.CreateRotationY(-owner.Yaw * MathF.PI / 180)
* Matrix4x4.CreateTranslation(owner.ActorRoot);
clip.Sample(owner.Steps / 60d, destination.Vertices.AsSpan(offset, clip.Base.Vertices.Length), model);
}
}