This commit is contained in:
Mister_Nebula 2020-09-22 21:11:29 +01:00
parent 3fe4faa0fa
commit 37323f6f58
15 changed files with 164 additions and 28 deletions

View File

@ -0,0 +1,28 @@
using QSB.Events;
using QSB.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QSB.ConversationSync
{
class ConversationEvent : QSBEvent<ConversationMessage>
{
public override EventType Type => EventType.Conversation;
public override void SetupListener() => GlobalMessenger<int, string, ConversationType>.AddListener(EventNames.QSBConversation, Handler);
public override void CloseListener() => GlobalMessenger<int, string, ConversationType>.RemoveListener(EventNames.QSBConversation, Handler);
private void Handler(int id, string message, ConversationType type) => SendEvent(CreateMessage(id, message, type));
private ConversationMessage CreateMessage(int id, string message, ConversationType type) => new ConversationMessage
{
AboutId = LocalPlayerId,
ObjectId = id,
Type = type,
Message = message
};
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace QSB.ConversationSync
{
public class ConversationManager : MonoBehaviour
{
public static ConversationManager Instance { get; private set; }
void Start()
{
Instance = this;
}
public void SendPlayerOption(string text)
{
}
public void SendCharacterDialogue(string text)
{
}
}
}

View File

@ -0,0 +1,28 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.ConversationSync
{
public class ConversationMessage : PlayerMessage
{
public ConversationType Type { get; set; }
public int ObjectId { get; set; }
public string Message { get; set; }
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
ObjectId = reader.ReadInt32();
Type = (ConversationType)reader.ReadInt32();
Message = reader.ReadString();
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(ObjectId);
writer.Write((int)Type);
writer.Write(Message);
}
}
}

View File

@ -1,5 +1,9 @@
using System;
using OWML.ModHelper.Events;
using QSB.Utility;
using QSB.WorldSync;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
@ -7,18 +11,36 @@ namespace QSB.ConversationSync
{
public static class ConversationPatches
{
public static class OrbPatches
public static void StartConversation(CharacterDialogueTree __instance)
{
public static void ZoneExit(CharacterAnimController __instance)
{
var index = WorldRegistry.OldDialogueTrees.FindIndex(x => x == __instance);
DebugLog.DebugWrite("START CONVO " + index);
}
}
public static void AddPatches()
public static bool InputDialogueOption(int optionIndex, DialogueBoxVer2 ____currentDialogueBox)
{
if (optionIndex >= 0)
{
QSB.Helper.HarmonyHelper.AddPostfix<NomaiInterfaceOrb>("StartDragFromPosition", typeof(OrbPatches), nameof(StartDragCallEvent));
QSB.Helper.HarmonyHelper.AddPrefix<NomaiInterfaceSlot>("CheckOrbCollision", typeof(OrbPatches), nameof(CheckOrbCollision));
var selectedOption = ____currentDialogueBox.OptionFromUIIndex(optionIndex);
ConversationManager.Instance.SendPlayerOption(selectedOption.Text);
}
return true;
}
public static void GetNextPage(DialogueNode __instance, string ____name, List<string> ____listPagesToDisplay, int ____currentPage)
{
DebugLog.DebugWrite("Name is : " + __instance.Name);
DebugLog.DebugWrite("Target Name is : " + __instance.TargetName);
var key = ____name + ____listPagesToDisplay[____currentPage];
var mainText = TextTranslation.Translate(key).Trim();
ConversationManager.Instance.SendCharacterDialogue(mainText);
}
public static void AddPatches()
{
QSB.Helper.HarmonyHelper.AddPostfix<DialogueNode>("GetNextPage", typeof(ConversationPatches), nameof(GetNextPage));
QSB.Helper.HarmonyHelper.AddPrefix<CharacterDialogueTree>("InputDialogueOption", typeof(ConversationPatches), nameof(InputDialogueOption));
QSB.Helper.HarmonyHelper.AddPostfix<CharacterDialogueTree>("StartConversation", typeof(ConversationPatches), nameof(StartConversation));
}
}
}

View File

@ -0,0 +1,5 @@
public enum ConversationType
{
CHARACTER,
PLAYER
}

View File

@ -1,4 +1,5 @@
using QSB.Animation;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.GeyserSync;
@ -40,7 +41,8 @@ namespace QSB.Events
new ServerTimeEvent(),
new AnimTriggerEvent(),
new OrbSlotEvent(),
new OrbUserEvent()
new OrbUserEvent(),
new ConversationEvent()
};
_eventList.ForEach(ev => ev.SetupListener());

View File

@ -32,5 +32,6 @@
public static string QSBAnimTrigger = "QSBAnimTrigger";
public static string QSBOrbSlot = "QSBOrbSlot";
public static string QSBOrbUser = "QSBOrbUser";
public static string QSBConversation = "QSBConversation";
}
}

View File

@ -21,6 +21,8 @@
Elevator,
Geyser,
OrbSlot,
OrbUser
OrbUser,
Conversation,
ConversationStatus
}
}

View File

@ -11,15 +11,19 @@ namespace QSB
{
public uint PlayerId { get; }
public GameObject Camera { get; set; }
// Tools
public GameObject ProbeBody { get; set; }
public QSBProbe Probe { get; set; }
public QSBFlashlight FlashLight => Camera?.GetComponentInChildren<QSBFlashlight>();
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
public QSBTool Translator => GetToolByType(ToolType.Translator);
public QSBTool ProbeLauncher => GetToolByType(ToolType.ProbeLauncher);
public PlayerHUDMarker HudMarker { get; set; }
public string Name { get; set; }
public bool IsReady { get; set; }
public int ConversationId { get; set; }
public State State { get; set; }
public PlayerInfo(uint id)

View File

@ -1,5 +1,6 @@
using OWML.Common;
using OWML.ModHelper;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.GeyserSync;
@ -47,6 +48,7 @@ namespace QSB
gameObject.AddComponent<GeyserManager>();
gameObject.AddComponent<OrbSlotManager>();
gameObject.AddComponent<QSBSectorManager>();
gameObject.AddComponent<ConversationManager>();
}
public override void Configure(IModConfig config)

View File

@ -126,6 +126,12 @@
<Compile Include="Animation\AnimTrigger.cs" />
<Compile Include="Animation\AnimTriggerMessage.cs" />
<Compile Include="Animation\CrouchSync.cs" />
<Compile Include="ConversationSync\ConversationEvent.cs" />
<Compile Include="ConversationSync\ConversationMessage.cs" />
<Compile Include="ConversationSync\ConversationPatches.cs" />
<Compile Include="ConversationSync\ConversationType.cs" />
<Compile Include="ConversationSync\ConversationManager.cs" />
<Compile Include="ConversationSync\QSBCharacterAnimController.cs" />
<Compile Include="DeathSync\DeathPatches.cs" />
<Compile Include="ElevatorSync\ElevatorDirection.cs" />
<Compile Include="ElevatorSync\QSBElevator.cs" />

View File

@ -3,5 +3,6 @@
<PropertyGroup>
<GameDir>D:\EpicGames\OuterWilds</GameDir>
<OwmlDir>C:\Users\Henry\AppData\Roaming\OuterWildsModManager\OWML</OwmlDir>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
</Project>

View File

@ -1,6 +1,7 @@
using OWML.Common;
using OWML.ModHelper.Events;
using QSB.Animation;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.Events;
@ -32,7 +33,7 @@ namespace QSB
private GameObject _shipPrefab;
private GameObject _cameraPrefab;
private GameObject _probePrefab;
private GameObject _orbPrefab;
public GameObject OrbPrefab { get; private set; }
private void Awake()
{
@ -62,22 +63,13 @@ namespace QSB
spawnPrefabs.Add(_probePrefab);
DebugLog.LogState("ProbePrefab", _probePrefab);
_orbPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkorb.prefab");
_orbPrefab.AddComponent<NomaiOrbTransformSync>();
spawnPrefabs.Add(_orbPrefab);
DebugLog.LogState("OrbPrefab", _orbPrefab);
OrbPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkorb.prefab");
OrbPrefab.AddComponent<NomaiOrbTransformSync>();
spawnPrefabs.Add(OrbPrefab);
DebugLog.LogState("OrbPrefab", OrbPrefab);
ConfigureNetworkManager();
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(OWScene scene, bool inUniverse)
{
WorldRegistry.OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList();
if (NetworkServer.active)
{
WorldRegistry.OldOrbList.ForEach(x => NetworkServer.Spawn(Instantiate(_orbPrefab)));
}
QSBSceneManager.OnSceneLoaded += WorldRegistry.InitOnSceneLoaded;
}
private void ConfigureNetworkManager()
@ -121,6 +113,7 @@ namespace QSB
}
OrbPatches.AddPatches();
ConversationPatches.AddPatches();
_lobby.CanEditName = false;

View File

@ -4,6 +4,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Networking;
namespace QSB.WorldSync
{
@ -12,6 +14,18 @@ namespace QSB.WorldSync
private static readonly List<WorldObject> WorldObjects = new List<WorldObject>();
public static List<NomaiOrbTransformSync> OrbSyncList = new List<NomaiOrbTransformSync>();
public static List<NomaiInterfaceOrb> OldOrbList = new List<NomaiInterfaceOrb>();
public static List<CharacterDialogueTree> OldDialogueTrees = new List<CharacterDialogueTree>();
public static void InitOnSceneLoaded(OWScene scene, bool inUniverse)
{
OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList();
if (NetworkServer.active)
{
OldOrbList.ForEach(x => NetworkServer.Spawn(UnityEngine.Object.Instantiate(QSBNetworkManager.Instance.OrbPrefab)));
}
OldDialogueTrees = Resources.FindObjectsOfTypeAll<CharacterDialogueTree>().ToList();
}
public static void AddObject(WorldObject worldObject)
{

View File

@ -3,6 +3,6 @@
"settings": {
"defaultServerIP": "localhost",
"port": 7777,
"debugMode": false
"debugMode": true
}
}