Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
679e961
refactor: the smoke blown out at the VR mouth takes the particle effe…
BoroBongo Nov 26, 2026
832a394
feat: the VR mouth tells a smoked part when it comes and goes and blo…
BoroBongo Nov 26, 2026
23e3ed9
feat: a water pipe's mouthpiece can be taken in VR - its hose bends t…
BoroBongo Nov 26, 2026
db6910b
feat: smoking a water pipe in VR - at the mouth it bubbles and smokes…
BoroBongo Nov 26, 2026
d96ef93
chore: meta files of the water pipe scripts (generated by Unity on im…
BoroBongo Nov 26, 2026
b1c98fa
fix: the water pipe's mouthpiece is easy to grab and smokes at the mo…
BoroBongo Nov 26, 2026
06c909b
fix: the water pipe bubbles and smokes while the mouthpiece is at the…
BoroBongo Nov 26, 2026
d9e3ac9
fix: breathing out the water pipe's smoke is heard - the joint's smok…
BoroBongo Nov 26, 2026
d24f2a9
fix: the water pipe's smoke is held for a second before it's breathed…
BoroBongo Nov 26, 2026
6d49e4d
fix: a water pipe saved while an NPC smoked it can be taken after a l…
BoroBongo Nov 26, 2026
f4d1bdb
refactor: whether an NPC uses a mob right now is decided in Core (Vob…
BoroBongo Nov 26, 2026
5f7d958
fix: a water pipe culled or unloaded at the VR mouth no longer breaks…
BoroBongo Nov 26, 2026
2e97894
fix: a water pipe's mouthpiece grabbed while an NPC smokes it (or wit…
BoroBongo Nov 26, 2026
895e6cf
fix: a water pipe's mouthpiece can be taken as soon as the NPC leaves…
BoroBongo Nov 26, 2026
8ee1124
refactor: smoking at the VR mouth is its own class (VRMouthSmoking) a…
BoroBongo Nov 26, 2026
96225c1
chore: meta file of VRMouthSmoking (generated by Unity on import)
BoroBongo Nov 26, 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
13 changes: 12 additions & 1 deletion Assets/Gothic-Core/Scripts/Services/Vobs/MobAnimationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public void Stop([CanBeNull] VobContainer mob, [CanBeNull] NpcContainer user)

/// <summary>
/// The hero uses a mob with a dialog (the anvil's smithing choices, the grindstone, a rune table): it works
/// like for a smith, S0 -> S1 and its loop, until StopHeroUse (the dialog closed). One at a time.
/// like for a smith, S0 -> S1 and its loop, until StopHeroUse (the dialog closed). One at a time. VR: a water
/// pipe's mouthpiece at the mouth too (VRWaterPipe) - it bubbles and smokes, nothing else.
/// </summary>
public void StartHeroUse([CanBeNull] VobContainer mob, [CanBeNull] NpcContainer hero)
{
Expand All @@ -156,6 +157,16 @@ public void StartHeroUse([CanBeNull] VobContainer mob, [CanBeNull] NpcContainer
OnStateChanged(mob, hero, 0, 1);
}

/// <summary>
/// Ends the hero's use only if it is this mob: a water pipe taken from the mouth doesn't stop the anvil whose
/// dialog opened meanwhile.
/// </summary>
public void StopHeroUse([CanBeNull] VobContainer mob)
{
if (mob != null && mob == _heroMob)
StopHeroUse();
}

public void StopHeroUse()
{
if (_heroMob == null)
Expand Down
10 changes: 10 additions & 0 deletions Assets/Gothic-Core/Scripts/Services/Vobs/VobService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,16 @@ public IEnumerable<NpcContainer> GetOtherMobUsers(VobContainer mob, NpcContainer
i.Props.CurrentAction is Gothic.Core.Domain.Npc.Actions.AnimationActions.UseMob));
}

/// <summary>
/// A living NPC other than except uses this mob right now or walks to it (GetOtherMobUsers) - "busy" for a
/// mob the hero takes hold of (a VR water pipe). Not MobState: above 0 it also means switched or open (levers,
/// lids), and a state saved while an NPC used the mob comes back with a load without that NPC at it.
/// </summary>
public bool IsUsedByOtherNpc(VobContainer mob, NpcContainer except)
{
return mob != null && GetOtherMobUsers(mob, except).Any(i => !i.Props.IsDead);
}

private int GetSlotCount(VobContainer mob)
{
var slots = GetSlots(mob.Go);
Expand Down
41 changes: 41 additions & 0 deletions Assets/Gothic-VR/Scripts/Adapters/Vob/HoseIk.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEngine;

namespace Gothic.VR.Adapters.Vob
{
/// <summary>
/// Bends a chain of a model's nodes (a water pipe's hose) so that its tip reaches a point: CCD (cyclic coordinate
/// descent) - from the last link to the first, each one turns the tip towards the target, a few rounds. Each turn
/// is limited, so the bend spreads over the whole hose instead of kinking at its end. Plain math on the
/// transforms, no allocations.
/// </summary>
public static class HoseIk
{
private const float _minDistanceSqr = 0.000001f;

/// <param name="links">The turning nodes, first = the one fixed to the model (BIP01 FLEX0).</param>
/// <param name="tip">The node that should reach target (BIP01 FLEXEND), below the last link.</param>
public static void Solve(Transform[] links, Transform tip, Vector3 target, int iterations,
float maxTurnDegrees, float tolerance)
{
var toleranceSqr = tolerance * tolerance;
for (var iteration = 0; iteration < iterations; iteration++)
{
for (var i = links.Length - 1; i >= 0; i--)
{
var link = links[i];
var linkPosition = link.position;
var toTip = tip.position - linkPosition;
var toTarget = target - linkPosition;
if (toTip.sqrMagnitude < _minDistanceSqr || toTarget.sqrMagnitude < _minDistanceSqr)
continue;

var turn = Quaternion.FromToRotation(toTip, toTarget);
link.rotation = Quaternion.RotateTowards(Quaternion.identity, turn, maxTurnDegrees) * link.rotation;
}

if ((tip.position - target).sqrMagnitude <= toleranceSqr)
return;
}
}
}
}
2 changes: 2 additions & 0 deletions Assets/Gothic-VR/Scripts/Adapters/Vob/HoseIk.cs.meta

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

10 changes: 9 additions & 1 deletion Assets/Gothic-VR/Scripts/Adapters/Vob/VRMobInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ public class VRMobInteraction : MonoBehaviour

private bool _mobActivated;
private VrInteractable _interactable;
// The mouthpiece of a water pipe (null for other mobs).
private VRWaterPipe _waterPipe;

/// <summary>
/// Subscribed in Start (not Awake), so that e.g. VRSeat handles a grab first (as before).
/// Subscribed in Start (not Awake), so that e.g. VRSeat handles a grab first (as before). The mob's model is
/// built by then: a water pipe's mouthpiece becomes a handle of its own (VRWaterPipe).
/// </summary>
private void Start()
{
Expand All @@ -34,6 +37,7 @@ private void Start()

_interactable.Grabbed += OnGrabbed;
_interactable.Released += OnReleased;
_waterPipe = VRWaterPipe.TryAdd(gameObject);
}

private void OnDestroy()
Expand All @@ -50,6 +54,10 @@ private void OnGrabbed(VrGrabArgs args)
if (_mobActivated)
return;

// The hand closed at a water pipe's mouthpiece but caught the pipe: it takes the mouthpiece instead.
if (_waterPipe != null && _waterPipe.TryTakeOverGrab(args))
return;

var vobLoader = GetComponentInParent<VobLoader>();
var vob = vobLoader?.Container?.Vob;
// A lidless container (mummy) is a plain mob here too: the grab toggles its loot (VRMobUseService).
Expand Down
Loading