add picking up instruments, starting instruments playing

fixed #419
fixed #418
This commit is contained in:
Mister_Nebula 2021-12-19 12:37:44 +00:00
parent 82d5e1ee91
commit a2a4d5d709
16 changed files with 93 additions and 14 deletions

View File

@ -13,6 +13,7 @@ namespace QSB.Animation.NPC
QSBWorldSync.Init<QSBSolanumController, NomaiConversationManager>();
QSBWorldSync.Init<QSBSolanumAnimController, SolanumAnimController>();
QSBWorldSync.Init<QSBHearthianRecorderEffects, HearthianRecorderEffects>();
QSBWorldSync.Init<QSBTravelerEyeController, TravelerEyeController>();
//MOVE : this is the wrong place to put this... move it to Conversations?
QSBWorldSync.OldDialogueTrees.Clear();

View File

@ -15,6 +15,7 @@ namespace QSB.Animation.NPC.WorldObjects
public virtual void EndConversation()
=> GetDialogueTree().RaiseEvent("OnEndConversation");
public abstract bool InConversation();
public virtual bool InConversation()
=> false;
}
}

View File

@ -2,9 +2,6 @@
{
internal class QSBHearthianRecorderEffects : NpcAnimController<HearthianRecorderEffects>
{
public override bool InConversation()
=> AttachedObject._characterDialogueTree.InConversation();
public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._characterDialogueTree;
}

View File

@ -4,8 +4,5 @@
{
public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._characterDialogueTree;
public override bool InConversation()
=> AttachedObject._solanumAnimController._animator.GetBool("ListeningToPlayer");
}
}

View File

@ -4,8 +4,5 @@
{
public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._dialogueSystem;
public override bool InConversation()
=> AttachedObject._talking;
}
}

View File

@ -0,0 +1,8 @@
namespace QSB.Animation.NPC.WorldObjects
{
internal class QSBTravelerEyeController : NpcAnimController<TravelerEyeController>
{
public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._dialogueTree;
}
}

View File

@ -105,5 +105,6 @@
public const string QSBTornadoFormState = nameof(QSBTornadoFormState);
public const string QSBRequestGameDetails = nameof(QSBRequestGameDetails);
public const string QSBGameDetails = nameof(QSBGameDetails);
public const string QSBGatherInstrument = nameof(QSBGatherInstrument);
}
}

View File

@ -8,6 +8,7 @@ using QSB.ClientServerStateSync.Events;
using QSB.ConversationSync.Events;
using QSB.DeathSync.Events;
using QSB.ElevatorSync.Events;
using QSB.EyeOfTheUniverse.InstrumentSync.Event;
using QSB.GeyserSync.Events;
using QSB.ItemSync.Events;
using QSB.JellyfishSync.Events;
@ -111,6 +112,7 @@ namespace QSB.Events
new FragmentResyncEvent(),
new JellyfishRisingEvent(),
new TornadoFormStateEvent(),
new GatherInstrumentEvent(),
// Conversation/dialogue/exploration
new ConversationEvent(),
new ConversationStartEndEvent(),

View File

@ -0,0 +1,30 @@
using OWML.Common.Menus;
using QSB.Events;
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.EyeOfTheUniverse.InstrumentSync.Event
{
internal class GatherInstrumentEvent : QSBEvent<WorldObjectMessage>
{
public override bool RequireWorldObjectsReady => true;
public override void SetupListener() => GlobalMessenger<QSBQuantumInstrument>.AddListener(EventNames.QSBGatherInstrument, Handler);
public override void CloseListener() => GlobalMessenger<QSBQuantumInstrument>.RemoveListener(EventNames.QSBGatherInstrument, Handler);
private void Handler(QSBQuantumInstrument instrument) => SendEvent(CreateMessage(instrument));
private BoolWorldObjectMessage CreateMessage(QSBQuantumInstrument instrument) => new()
{
AboutId = LocalPlayerId,
ObjectId = instrument.ObjectId
};
public override void OnReceiveRemote(bool isHost, WorldObjectMessage message)
{
var qsbObj = QSBWorldSync.GetWorldFromId<QSBQuantumInstrument>(message.ObjectId);
qsbObj.AttachedObject.Gather();
}
}
}

View File

@ -0,0 +1,17 @@
using HarmonyLib;
using QSB.Events;
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
using QSB.Patches;
using QSB.WorldSync;
namespace QSB.EyeOfTheUniverse.InstrumentSync.Patches
{
internal class QuantumInstrumentPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPostfix]
[HarmonyPatch(typeof(QuantumInstrument), nameof(QuantumInstrument.OnPressInteract))]
public static void Gather(QuantumInstrument __instance)
=> QSBEventManager.FireEvent(EventNames.QSBGatherInstrument, QSBWorldSync.GetWorldFromUnity<QSBQuantumInstrument>(__instance));
}
}

View File

@ -0,0 +1,11 @@
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
using QSB.WorldSync;
namespace QSB.EyeOfTheUniverse.InstrumentSync
{
internal class QuantumInstrumentManager : WorldObjectManager
{
protected override void RebuildWorldObjects(OWScene scene)
=> QSBWorldSync.Init<QSBQuantumInstrument, QuantumInstrument>();
}
}

View File

@ -0,0 +1,13 @@
using QSB.WorldSync;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects
{
internal class QSBQuantumInstrument : WorldObject<QuantumInstrument>
{
}
}

View File

@ -15,7 +15,7 @@ namespace QSB.MeteorSync
QSBCore.UnityEvents.RunWhen(() => LateInitializerManager.s_lateInitializers.Count == 0, () =>
{
FinishDelayedReady();
WhiteHoleVolume = QSBWorldSync.GetUnityObjects<WhiteHoleVolume>().First();
WhiteHoleVolume = QSBWorldSync.GetUnityObjects<WhiteHoleVolume>().FirstOrDefault();
QSBWorldSync.Init<QSBMeteorLauncher, MeteorLauncher>();
QSBWorldSync.Init<QSBMeteor, MeteorController>();
QSBWorldSync.Init<QSBFragment, FragmentIntegrity>();

View File

@ -8,6 +8,7 @@ using QSB.ConversationSync.Patches;
using QSB.DeathSync.Patches;
using QSB.EchoesOfTheEye.LightSensorSync.Patches;
using QSB.ElevatorSync.Patches;
using QSB.EyeOfTheUniverse.InstrumentSync.Patches;
using QSB.GeyserSync.Patches;
using QSB.Inputs.Patches;
using QSB.ItemSync.Patches;
@ -83,7 +84,8 @@ namespace QSB.Patches
new JellyfishPatches(),
new TravelerControllerPatches(),
new ZeroGCavePatches(),
new TornadoPatches()
new TornadoPatches(),
new QuantumInstrumentPatches()
};
TypeToInstance = new Dictionary<QSBPatchTypes, Harmony>

View File

@ -8,6 +8,7 @@ using QSB.ConversationSync;
using QSB.EchoesOfTheEye.AirlockSync;
using QSB.EchoesOfTheEye.LightSensorSync;
using QSB.ElevatorSync;
using QSB.EyeOfTheUniverse.InstrumentSync;
using QSB.GeyserSync;
using QSB.Inputs;
using QSB.ItemSync;
@ -145,6 +146,7 @@ namespace QSB
gameObject.AddComponent<JellyfishManager>();
gameObject.AddComponent<ZeroGCaveManager>();
gameObject.AddComponent<TornadoManager>();
gameObject.AddComponent<QuantumInstrumentManager>();
DebugBoxManager.Init();

View File

@ -1,8 +1,8 @@
{
"debugMode": true,
"drawLines": false,
"showQuantumVisibilityObjects": false,
"showQuantumDebugBoxes": false,
"showQuantumVisibilityObjects": true,
"showQuantumDebugBoxes": true,
"avoidTimeSync": false,
"skipTitleScreen": true
}