Implement Bubble controller, sprite and VR01 body behavior
This commit is contained in:
1 parent
9ea578492d
commit
1ae5f4251c
51 files changed
+2811
-54
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
public readonly record struct Vr01FloorEffect(bool Entered, bool Damaged);
|
||||
|
||||
/// <summary>Textured retained-support callback for actual VR01 IDs0..4/111.
|
||||
/// Other damage flags, floor classes and footstep-loop playback remain outside.</summary>
|
||||
public sealed class Vr01FloorState
|
||||
{
|
||||
public bool InLava { get; private set; }
|
||||
public bool Flashing { get; private set; }
|
||||
public float Timer { get; private set; }
|
||||
public int SoundSelector { get; private set; } = 5;
|
||||
public Vr01FloorEffect Visit(int? material, int rawMode)
|
||||
{
|
||||
//Null means no eligible textured support. The actual VR01 profile's
|
||||
//used material IDs all have source-verified texture links.
|
||||
if (material == null) return default;
|
||||
if (material is not (0 or 1 or 2 or 3 or 4 or 111))
|
||||
throw new NotSupportedException("Outside the recovered VR01 floor profile");
|
||||
var lava = material == 111;
|
||||
var entered = lava && !InLava;
|
||||
var damaged = lava && !Flashing && rawMode != 0;
|
||||
InLava = lava; SoundSelector = lava ? 35 : 5;
|
||||
if (damaged) { Flashing=true; Timer=0; }
|
||||
return new(entered,damaged);
|
||||
}
|
||||
public void Step(float seconds, Action<Vector4> color)
|
||||
{
|
||||
if (!float.IsFinite(seconds) || seconds<0 || seconds>=1) throw new ArgumentOutOfRangeException(nameof(seconds));
|
||||
ArgumentNullException.ThrowIfNull(color);
|
||||
if (!Flashing) return;
|
||||
var sum = (double)Timer + seconds;
|
||||
Timer = (float)sum;
|
||||
if (sum>4) { Flashing=false; color(Vector4.One); return; }
|
||||
var pulse = (float)((Math.Sin(sum*20)+1)*.5);
|
||||
color(new(pulse,1,pulse,1));
|
||||
}
|
||||
public void Reset() { InLava=Flashing=false; Timer=0; SoundSelector=5; }
|
||||
}
|
||||
Reference in new issue
Block a user