Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
83b09c1
feat: ground steeper than a guild's SLIDE_ANGLE slides like in Gothic…
BoroBongo Nov 29, 2026
0f74ca8
fix: the VR hero can't climb a steep slope by jumping again and again…
BoroBongo Nov 29, 2026
31581a4
feat: the sliding VR hero body plays S_SLIDE facing downhill and S_SL…
BoroBongo Nov 29, 2026
261df31
feat: NPCs and monsters slide down steep slopes too - their own guild…
BoroBongo Nov 29, 2026
187c47f
docs: the slope slide decision record - Gothic's slide angles, no jum…
BoroBongo Nov 29, 2026
22ecc12
fix: a vertical wall is never slide ground - near-vertical normals (y…
BoroBongo Nov 29, 2026
436cba9
fix: the hero's slide check no longer builds a string every frame whi…
BoroBongo Nov 29, 2026
390b42f
fix: an NPC that dies or swims mid-slide gets its physics back unless…
BoroBongo Nov 29, 2026
aeba428
fix: short walks over the same steep spot no longer add up to an NPC …
BoroBongo Nov 29, 2026
29c0393
fix: an NPC sliding across a slope is no longer stopped by the slope …
BoroBongo Nov 29, 2026
463fd33
fix: NPCs, monsters and items under the VR hero's feet no longer bloc…
BoroBongo Nov 29, 2026
601ea7d
refactor: the slide animation choice with its fallback (S_SLIDEB, els…
BoroBongo Nov 29, 2026
8406e6e
refactor: how much of the stick's step up the slope a slide takes bac…
BoroBongo Nov 29, 2026
a56c8fe
refactor: a platform must say whether there's ground under the hero a…
BoroBongo Nov 29, 2026
a7beec6
docs: why SLIDE_ANGLE2 is clamped instead of falling back to the huma…
BoroBongo Nov 29, 2026
2ccc367
docs: the slope slide decision record - only world ground blocks the …
BoroBongo Nov 29, 2026
5502466
style: drop VrHeroLocomotion's unused Domain.Movement using - the sli…
BoroBongo Nov 29, 2026
ff96373
chore: meta files of the slope slide scripts (generated by Unity on i…
BoroBongo Nov 29, 2026
f1a0339
refactor: an NPC's slide is its own worker (NpcSlopeSlide) owned by N…
BoroBongo Nov 29, 2026
7aaa011
refactor: an NPC's ledge and ladder climbs are their own worker (NpcL…
BoroBongo Nov 29, 2026
e8ea4bc
refactor: HeroFallSample is HeroBodySample - one frame's measurement …
BoroBongo Nov 29, 2026
4f5e69f
refactor: one Core entry point for the hero's body each frame (HeroBo…
BoroBongo Nov 29, 2026
64584c3
docs: a map of the hero and NPC movement (Docs/hero-movement.md) - wh…
BoroBongo Nov 29, 2026
ed4c62e
docs: the slope slide decision record names HeroBodyService (the fall…
BoroBongo Nov 29, 2026
a959d3f
chore: meta files of the NPC movement workers and HeroBodyService (ge…
BoroBongo Nov 29, 2026
1e7cc87
Merge feature/hero-jump-fall into feature/slope-slide - the hero's sp…
BoroBongo Nov 29, 2026
5066d03
docs: CLAUDE.md allows a stateless Domain rule set as a static class …
BoroBongo Nov 29, 2026
83f3583
fix: the hero's slide rules all in Core - BS_STAND while sliding is H…
BoroBongo Nov 29, 2026
125e95e
fix: XriSlopeSlide isn't sliding without a body transformer - nothing…
BoroBongo Nov 29, 2026
b656225
fix: one wall test for an NPC's fall and slide (NpcMoveBody.IsWallAhe…
BoroBongo Nov 29, 2026
ad4d83f
refactor: NpcJumpFall's workers (NpcMoveBody, NpcSlopeSlide, NpcLedge…
BoroBongo Nov 29, 2026
22d68e7
test: a slide off an edge falls from the edge (HeroAirborneDomainTest…
BoroBongo Nov 29, 2026
2d92847
Merge branch 'feature/hero-jump-fall' into feature/slope-slide
BoroBongo Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions Assets/Gothic-Core/Scripts/Adapters/Npc/NpcAnimationSequence.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using UnityEngine;

namespace Gothic.Core.Adapters.Npc
{
/// <summary>
/// Animations played on an NPC one after another, each for its own duration - a landing (NpcJumpFall) or a climb
/// (NpcLedgeClimb). Animations the model doesn't have are skipped. Can't move any more (died, swimming): the rest
/// plays none of them (the death's or swimming's animations take over), the time still runs to the end.
/// </summary>
internal class NpcAnimationSequence
{
private readonly NpcMoveBody _body;

public NpcAnimationSequence(NpcMoveBody body)
{
_body = body;
}

public string[] Animations { get; private set; }

/// <summary>
/// s per animation, 0 for one the model doesn't have.
/// </summary>
public float[] Durations { get; private set; }

/// <summary>
/// The animation playing now; Animations.Length when all are done.
/// </summary>
public int Index { get; private set; }

/// <summary>
/// s since the current animation began.
/// </summary>
public float AnimationTime { get; private set; }

/// <summary>
/// s since the sequence began.
/// </summary>
public float Elapsed { get; private set; }

/// <summary>
/// s the whole sequence lasts - the sum of the animations, a climb may set its own.
/// </summary>
public float Duration { get; set; }

public bool IsDone => Elapsed >= Duration;

/// <summary>
/// 0..1 of Duration.
/// </summary>
public float Progress => Mathf.Clamp01(Elapsed / Duration);

public void Start(string[] animations)
{
Animations = animations;
Durations = new float[animations.Length];
Duration = 0f;
for (var i = 0; i < animations.Length; i++)
{
Durations[i] = _body.HasTrack(animations[i])
? _body.Animations.GetAnimationDuration(animations[i])
: 0f;
Duration += Durations[i];
}

Index = -1;
AnimationTime = 0f;
Elapsed = 0f;
Next();
}

public void Tick(float deltaTime)
{
Elapsed += deltaTime;
AnimationTime += deltaTime;
if (Index < Animations.Length && AnimationTime >= Durations[Index])
Next();
}

/// <summary>
/// Stops the animation playing now - the sequence is over.
/// </summary>
public void Stop()
{
if (Animations != null && Index >= 0 && Index < Animations.Length)
_body.Animations.StopAnimation(Animations[Index]);
Animations = null;
}

private void Next()
{
if (Index >= 0 && Index < Animations.Length)
_body.Animations.StopAnimation(Animations[Index]);

Index++;
AnimationTime = 0f;
while (Index < Animations.Length && Durations[Index] <= 0f)
Index++;

// Can't move any more: the move ends without our animations (the death's or swimming's play).
if (Index < Animations.Length && _body.CanMove())
_body.Animations.PlayAnimation(Animations[Index]);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading