-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better prefab registering for jukebox tracks
add console command to manually unlock tracks make the tracks sound like they're coming from the jukebox instead of just magically going full stereo once you're close enough to it
- Loading branch information
Showing
5 changed files
with
82 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,65 @@ | ||
using System.Collections.Generic; | ||
using Nautilus.Assets; | ||
using Nautilus.Assets.Gadgets; | ||
using Nautilus.Assets.PrefabTemplates; | ||
using Nautilus.Utility; | ||
using SCHIZO.Creatures.Components; | ||
using SCHIZO.Helpers; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Jukebox; | ||
|
||
public sealed class CustomJukeboxDisk : JukeboxDisk | ||
public sealed class JukeboxDiskPrefab | ||
{ | ||
public new void Start() | ||
// prefab path "Misc/JukeboxDisk8.prefab" | ||
private const string DISK_CLASSID = "5108080f-242b-49e8-9b91-d01d6bbe138c"; | ||
|
||
internal static Dictionary<string, JukeboxDiskPrefab> Prefabs = []; | ||
|
||
public CustomPrefab NautilusPrefab { get; } | ||
private JukeboxDiskPrefab(CustomJukeboxTrack track) | ||
{ | ||
if (track == default) | ||
string prefabName = $"{nameof(CustomJukeboxTrack)}_{track.identifier}"; | ||
|
||
NautilusPrefab = new CustomPrefab(prefabName, null, null); | ||
|
||
NautilusPrefab.SetSpawns(new SpawnLocation(track.diskSpawnLocation.position, track.diskSpawnLocation.rotation)); | ||
|
||
NautilusPrefab.SetGameObject(new CloneTemplate(NautilusPrefab.Info, DISK_CLASSID) | ||
{ | ||
LOGGER.LogError($"Jukebox disk {name} at {transform.position} was not assigned a track, self-destructing"); | ||
Destroy(this); | ||
} | ||
ModifyPrefab = prefab => | ||
{ | ||
prefab.SetActive(false); | ||
if (track.diskPrefab) | ||
{ | ||
Renderer[] renderers = prefab.GetComponentsInChildren<Renderer>(); | ||
renderers.ForEach(r => r.gameObject.SetActive(false)); | ||
|
||
GameObject customModel = GameObject.Instantiate(track.diskPrefab, prefab.transform, false); | ||
customModel.transform.localPosition = Vector3.zero; | ||
|
||
base.Start(); | ||
MaterialUtils.ApplySNShaders(customModel, 1); | ||
} | ||
|
||
JukeboxDisk diskComp = prefab.EnsureComponent<JukeboxDisk>(); | ||
diskComp.track = track; | ||
if (!string.IsNullOrEmpty(track.unlockFmodEvent)) | ||
diskComp.acquireSound = AudioUtils.GetFmodAsset(track.unlockFmodEvent, FMODHelpers.GetId(track.unlockFmodEvent)); | ||
|
||
DisableUntilStoryGoal storyGate = prefab.EnsureComponent<DisableUntilStoryGoal>(); | ||
storyGate.storyGoalBZ = "SanctuaryCompleted"; | ||
} | ||
}); | ||
NautilusPrefab.Register(); | ||
} | ||
|
||
public static void Register(CustomJukeboxTrack track) | ||
{ | ||
if (Prefabs.ContainsKey(track.identifier)) | ||
{ | ||
LOGGER.LogWarning($"Track {track.identifier} already registered, skipping prefab registration"); | ||
return; | ||
} | ||
Prefabs[track.identifier] = new JukeboxDiskPrefab(track); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters