diff --git a/QSB/Audio/Patches/PlayerAudioControllerPatches.cs b/QSB/Audio/Patches/PlayerAudioControllerPatches.cs index 7432baaa..e1fa115a 100644 --- a/QSB/Audio/Patches/PlayerAudioControllerPatches.cs +++ b/QSB/Audio/Patches/PlayerAudioControllerPatches.cs @@ -33,4 +33,20 @@ internal class PlayerAudioControllerPatches : QSBPatch [HarmonyPostfix] [HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.PlayRefuel))] public static void PlayerAudioController_PlayRefuel() => PlayOneShot(AudioType.ShipCabinUseRefueller); + + [HarmonyPostfix] + [HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.OnArtifactFocus))] + public static void PlayerAudioController_OnArtifactFocus() => PlayOneShot(AudioType.Artifact_Focus); + + [HarmonyPostfix] + [HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.OnArtifactUnfocus))] + public static void PlayerAudioController_OnArtifactUnfocus() => PlayOneShot(AudioType.Artifact_Unfocus); + + [HarmonyPostfix] + [HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.OnArtifactConceal))] + public static void PlayerAudioController_OnArtifactConceal() => PlayOneShot(AudioType.Artifact_Conceal); + + [HarmonyPostfix] + [HarmonyPatch(typeof(PlayerAudioController), nameof(PlayerAudioController.OnArtifactUnconceal))] + public static void PlayerAudioController_OnArtifactUnconceal() => PlayOneShot(AudioType.Artifact_Unconceal); } \ No newline at end of file diff --git a/QSB/EchoesOfTheEye/DreamLantern/DreamLanternManager.cs b/QSB/EchoesOfTheEye/DreamLantern/DreamLanternManager.cs index 700f0865..bdb6d5b4 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/DreamLanternManager.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/DreamLanternManager.cs @@ -11,5 +11,5 @@ public class DreamLanternManager : WorldObjectManager public override bool DlcOnly => true; public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) => - QSBWorldSync.Init(); + QSBWorldSync.Init(); } diff --git a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetConcealedMessage.cs b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetConcealedMessage.cs index 8c194afc..802606a6 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetConcealedMessage.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetConcealedMessage.cs @@ -3,10 +3,10 @@ using QSB.Messaging; namespace QSB.EchoesOfTheEye.DreamLantern.Messages; -internal class SetConcealedMessage : QSBWorldObjectMessage +internal class SetConcealedMessage : QSBWorldObjectMessage { public SetConcealedMessage(bool concealed) : base(concealed) { } - public override void OnReceiveRemote() - => WorldObject.AttachedObject.SetConcealed(Data); + public override void OnReceiveRemote() => + WorldObject.AttachedObject.SetConcealed(Data); } diff --git a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetFocusMessage.cs b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetFocusMessage.cs index 0384185d..762820f7 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetFocusMessage.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetFocusMessage.cs @@ -3,7 +3,7 @@ using QSB.Messaging; namespace QSB.EchoesOfTheEye.DreamLantern.Messages; -internal class SetFocusMessage : QSBWorldObjectMessage +internal class SetFocusMessage : QSBWorldObjectMessage { public SetFocusMessage(float focus) : base(focus) { } diff --git a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetLitMessage.cs b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetLitMessage.cs index 77ee9363..94ddbc89 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetLitMessage.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetLitMessage.cs @@ -1,12 +1,16 @@ using QSB.EchoesOfTheEye.DreamLantern.WorldObjects; using QSB.Messaging; +using System.Collections.Generic; namespace QSB.EchoesOfTheEye.DreamLantern.Messages; -internal class SetLitMessage : QSBWorldObjectMessage +internal class SetLitMessage : QSBWorldObjectMessage { public SetLitMessage(bool lit) : base(lit) { } public override void OnReceiveRemote() - => WorldObject.AttachedObject.SetLit(Data); + { + WorldObject.AttachedObject.SetLit(Data); + WorldObject.DreamLanternItem._oneShotSource.PlayOneShot(Data ? AudioType.Artifact_Light : AudioType.Artifact_Extinguish, 1f); + } } diff --git a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetRangeMessage.cs b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetRangeMessage.cs index 62c0dffd..b5e7cdb9 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/Messages/SetRangeMessage.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/Messages/SetRangeMessage.cs @@ -3,7 +3,7 @@ using QSB.Messaging; namespace QSB.EchoesOfTheEye.DreamLantern.Messages; -internal class SetRangeMessage : QSBWorldObjectMessage +internal class SetRangeMessage : QSBWorldObjectMessage { public SetRangeMessage(float minRange, float maxRange) : base((minRange, maxRange)) { } diff --git a/QSB/EchoesOfTheEye/DreamLantern/Patches/DreamLanternPatches.cs b/QSB/EchoesOfTheEye/DreamLantern/Patches/DreamLanternPatches.cs index 7bfe18a4..3dd8c6f3 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/Patches/DreamLanternPatches.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/Patches/DreamLanternPatches.cs @@ -31,7 +31,7 @@ internal class DreamLanternPatches : QSBPatch return; } - var qsbDreamLantern = __instance.GetWorldObject(); + var qsbDreamLantern = __instance.GetWorldObject(); // ghost lanterns should only be controlled by the host if (qsbDreamLantern.IsGhostLantern && !QSBCore.IsHost) { @@ -59,7 +59,7 @@ internal class DreamLanternPatches : QSBPatch return; } - var qsbDreamLantern = __instance.GetWorldObject(); + var qsbDreamLantern = __instance.GetWorldObject(); // ghost lanterns should only be controlled by the host if (qsbDreamLantern.IsGhostLantern && !QSBCore.IsHost) { @@ -88,7 +88,7 @@ internal class DreamLanternPatches : QSBPatch return; } - var qsbDreamLantern = __instance.GetWorldObject(); + var qsbDreamLantern = __instance.GetWorldObject(); // ghost lanterns should only be controlled by the host if (qsbDreamLantern.IsGhostLantern && !QSBCore.IsHost) { @@ -116,7 +116,7 @@ internal class DreamLanternPatches : QSBPatch return; } - var qsbDreamLantern = __instance.GetWorldObject(); + var qsbDreamLantern = __instance.GetWorldObject(); // ghost lanterns should only be controlled by the host if (qsbDreamLantern.IsGhostLantern && !QSBCore.IsHost) { diff --git a/QSB/EchoesOfTheEye/DreamLantern/WorldObjects/QSBDreamLantern.cs b/QSB/EchoesOfTheEye/DreamLantern/WorldObjects/QSBDreamLanternController.cs similarity index 53% rename from QSB/EchoesOfTheEye/DreamLantern/WorldObjects/QSBDreamLantern.cs rename to QSB/EchoesOfTheEye/DreamLantern/WorldObjects/QSBDreamLanternController.cs index 84721115..796425dc 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/WorldObjects/QSBDreamLantern.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/WorldObjects/QSBDreamLanternController.cs @@ -1,11 +1,26 @@ -using QSB.EchoesOfTheEye.DreamLantern.Messages; +using Cysharp.Threading.Tasks; +using QSB.EchoesOfTheEye.DreamLantern.Messages; using QSB.Messaging; using QSB.WorldSync; +using System.Threading; namespace QSB.EchoesOfTheEye.DreamLantern.WorldObjects; -public class QSBDreamLantern : WorldObject +public class QSBDreamLanternController : WorldObject { + public DreamLanternItem DreamLanternItem { get; private set; } + + public override async UniTask Init(CancellationToken ct) + { + await base.Init(ct); + + // Ghosts don't have the item and instead the effects are controlled by GhostEffects + if (!IsGhostLantern) + { + DreamLanternItem = AttachedObject.GetComponent(); + } + } + public override void SendInitialState(uint to) { this.SendMessage(new SetLitMessage(AttachedObject._lit) { To = to }); diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatingLanternsMessage.cs b/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatingLanternsMessage.cs index f557cbf6..a9b657ad 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatingLanternsMessage.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatingLanternsMessage.cs @@ -10,12 +10,12 @@ namespace QSB.EchoesOfTheEye.LightSensorSync.Messages; internal class IlluminatingLanternsMessage : QSBWorldObjectMessage { public IlluminatingLanternsMessage(IEnumerable lanterns) : - base(lanterns.Select(x => x.GetWorldObject().ObjectId).ToArray()) { } + base(lanterns.Select(x => x.GetWorldObject().ObjectId).ToArray()) { } public override void OnReceiveRemote() { WorldObject.AttachedObject._illuminatingDreamLanternList.Clear(); WorldObject.AttachedObject._illuminatingDreamLanternList.AddRange( - Data.Select(x => x.GetWorldObject().AttachedObject)); + Data.Select(x => x.GetWorldObject().AttachedObject)); } } diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs b/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs index 4cc78e69..40bde54f 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatingLanternsMessage.cs @@ -12,7 +12,7 @@ internal class PlayerIlluminatingLanternsMessage : QSBMessage<(uint playerId, in public PlayerIlluminatingLanternsMessage(uint playerId, IEnumerable lanterns) : base(( playerId, - lanterns.Select(x => x.GetWorldObject().ObjectId).ToArray() + lanterns.Select(x => x.GetWorldObject().ObjectId).ToArray() )) { } public override void OnReceiveRemote() @@ -21,6 +21,6 @@ internal class PlayerIlluminatingLanternsMessage : QSBMessage<(uint playerId, in lightSensor._illuminatingDreamLanternList.Clear(); lightSensor._illuminatingDreamLanternList.AddRange( - Data.lanterns.Select(x => x.GetWorldObject().AttachedObject)); + Data.lanterns.Select(x => x.GetWorldObject().AttachedObject)); } }