Skip to content

Commit

Permalink
Merge pull request #351 from GothicVRProject/bugfix/lab-errors
Browse files Browse the repository at this point in the history
Bugfix/lab errors
  • Loading branch information
JaXt0r authored Apr 28, 2024
2 parents 3065a34 + b85c5dc commit ddb8994
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
9 changes: 3 additions & 6 deletions Assets/GothicVR-Lab/Scripts/Handler/LabNpcDialogHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ public class LabNpcDialogHandler : MonoBehaviour, ILabHandler
{
public TMP_Dropdown animationsDropdown;
public GameObject bloodwynSlotGo;
public BloodwynInstanceId bloodwynInstanceId;
private string bloodwynInstanceId = "GRD_233_Bloodwyn";

public enum BloodwynInstanceId
{
Deu = 6596
}

private NpcInstance bloodwynInstance;
private string[] animations = {
Expand All @@ -34,13 +30,14 @@ public void Bootstrap()

BootstrapBloodwyn();
}


private void BootstrapBloodwyn()
{
var newNpc = PrefabCache.TryGetObject(PrefabCache.PrefabType.Npc);
newNpc.SetParent(bloodwynSlotGo);

var npcSymbol = GameData.GothicVm.GetSymbolByIndex((int)bloodwynInstanceId);
var npcSymbol = GameData.GothicVm.GetSymbolByName(bloodwynInstanceId);
bloodwynInstance = GameData.GothicVm.AllocInstance<NpcInstance>(npcSymbol!);
var properties = newNpc.GetComponent<NpcProperties>();
LookupCache.NpcCache[bloodwynInstance.Index] = properties;
Expand Down
21 changes: 10 additions & 11 deletions Assets/GothicVR-Lab/Scripts/LabBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,32 @@
using GVR.Manager;
using GVR.Manager.Settings;
using UnityEngine;
using UnityEngine.Serialization;

namespace GVR.GothicVR_Lab.Scripts
{
public class LabBootstrapper : MonoBehaviour
{
[Header("Bootstrapping")]
public bool bootLabMusicHandler;
public bool bootNpcHandler;
public bool bootLockableHandler;
public bool bootLadderHandler;
public bool bootAttachPointHandler;

public LabMusicHandler labMusicHandler;
public LabNpcDialogHandler npcDialogHandler;
public LabLockableLabHandler lockableLabHandler;
public LabLadderLabHandler ladderLabHandler;
public LabVobHandAttachPointsLabHandler vobHandAttachPointsLabHandler;
public LabNpcAnimationHandler labNpcAnimationHandler;

private bool isBooted;
private bool _isBooted;
/// <summary>
/// It's easiest to wait for Start() to initialize all the MonoBehaviours first.
/// </summary>
private void Update()
{
if (isBooted)
if (_isBooted)
return;
isBooted = true;
_isBooted = true;

GvrBootstrapper.BootGothicVR(SettingsManager.GameSettings.GothicIPath);

BootLab();

labNpcAnimationHandler.Bootstrap();
labMusicHandler.Bootstrap();
npcDialogHandler.Bootstrap();
Expand All @@ -44,6 +38,11 @@ private void Update()
vobHandAttachPointsLabHandler.Bootstrap();
}

private void BootLab()
{
NpcHelper.CacheHero();
}

private void OnDestroy()
{
GameData.Dispose();
Expand Down
3 changes: 3 additions & 0 deletions Assets/GothicVR/Scripts/Creator/Sounds/SoundCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ private enum BitDepth
[CanBeNull]
public static SoundData GetSoundArrayFromVfs(string name)
{
if (GameData.Vfs == null)
return null;

var node = GameData.Vfs.Find(name);
if (node == null)
return null;
Expand Down
5 changes: 5 additions & 0 deletions Assets/GothicVR/Scripts/Manager/NpcHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ static NpcHelper()
}

private static void GeneralSceneLoaded()
{
CacheHero();
}

public static void CacheHero()
{
var heroIndex = GameData.GothicVm.GlobalHero!.Index;
var playerGo = GameObject.FindWithTag(Constants.PlayerTag);
Expand Down
1 change: 0 additions & 1 deletion Assets/GothicVR/Scripts/Manager/VobHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public static AudioClip GetSoundClip(string soundName)

if (soundData == null)
{
Debug.LogError($"No .wav data returned for {soundName}");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public override bool IsFinished()

if (audioPlaySeconds <= 0f)
{
AnimationCreator.StopHeadMorphAnimation(Props);
// NPC
if (speakerId != 0)
AnimationCreator.StopHeadMorphAnimation(Props);

return true;
}
Expand Down

0 comments on commit ddb8994

Please sign in to comment.