This commit is contained in:
Aleksander Waage 2020-09-29 20:42:45 +02:00
parent d736d0fdf7
commit c435ca4074
6 changed files with 19 additions and 17 deletions

View File

@ -4,7 +4,7 @@ using QSB.Utility;
namespace QSB.ConversationSync namespace QSB.ConversationSync
{ {
class ConversationEvent : QSBEvent<ConversationMessage> public class ConversationEvent : QSBEvent<ConversationMessage>
{ {
public override EventType Type => EventType.Conversation; public override EventType Type => EventType.Conversation;

View File

@ -7,19 +7,19 @@ namespace QSB.ConversationSync
{ {
public static ConversationManager Instance { get; private set; } public static ConversationManager Instance { get; private set; }
void Start() private void Start()
{ {
Instance = this; Instance = this;
} }
public void SendPlayerOption(string text) public void SendPlayerOption(string text)
{ {
GlobalMessenger<int, string, ConversationType>.FireEvent(EventNames.QSBConversation, -1, text, ConversationType.PLAYER); GlobalMessenger<int, string, ConversationType>.FireEvent(EventNames.QSBConversation, -1, text, ConversationType.Player);
} }
public void SendCharacterDialogue(int id, string text) public void SendCharacterDialogue(int id, string text)
{ {
GlobalMessenger<int, string, ConversationType>.FireEvent(EventNames.QSBConversation, id, text, ConversationType.CHARACTER); GlobalMessenger<int, string, ConversationType>.FireEvent(EventNames.QSBConversation, id, text, ConversationType.Character);
} }
} }
} }

View File

@ -14,11 +14,13 @@ namespace QSB.ConversationSync
public static bool InputDialogueOption(int optionIndex, DialogueBoxVer2 ____currentDialogueBox) public static bool InputDialogueOption(int optionIndex, DialogueBoxVer2 ____currentDialogueBox)
{ {
if (optionIndex >= 0) if (optionIndex < 0)
{ {
var selectedOption = ____currentDialogueBox.OptionFromUIIndex(optionIndex); return true;
ConversationManager.Instance.SendPlayerOption(selectedOption.Text);
} }
var selectedOption = ____currentDialogueBox.OptionFromUIIndex(optionIndex);
ConversationManager.Instance.SendPlayerOption(selectedOption.Text);
return true; return true;
} }

View File

@ -2,7 +2,7 @@
{ {
public enum ConversationType public enum ConversationType
{ {
CHARACTER, Character,
PLAYER Player
} }
} }

View File

@ -33,7 +33,7 @@ namespace QSB
private GameObject _shipPrefab; private GameObject _shipPrefab;
private GameObject _cameraPrefab; private GameObject _cameraPrefab;
private GameObject _probePrefab; private GameObject _probePrefab;
public GameObject OrbPrefab { get; private set; } private GameObject _orbPrefab;
private void Awake() private void Awake()
{ {
@ -63,13 +63,13 @@ namespace QSB
spawnPrefabs.Add(_probePrefab); spawnPrefabs.Add(_probePrefab);
DebugLog.LogState("ProbePrefab", _probePrefab); DebugLog.LogState("ProbePrefab", _probePrefab);
OrbPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkorb.prefab"); _orbPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkorb.prefab");
OrbPrefab.AddComponent<NomaiOrbTransformSync>(); _orbPrefab.AddComponent<NomaiOrbTransformSync>();
spawnPrefabs.Add(OrbPrefab); spawnPrefabs.Add(_orbPrefab);
DebugLog.LogState("OrbPrefab", OrbPrefab); DebugLog.LogState("OrbPrefab", _orbPrefab);
ConfigureNetworkManager(); ConfigureNetworkManager();
QSBSceneManager.OnSceneLoaded += WorldRegistry.InitOnSceneLoaded; QSBSceneManager.OnSceneLoaded += (scene, b) => WorldRegistry.InitOnSceneLoaded(_orbPrefab);
} }
private void ConfigureNetworkManager() private void ConfigureNetworkManager()

View File

@ -16,12 +16,12 @@ namespace QSB.WorldSync
public static List<NomaiInterfaceOrb> OldOrbList = new List<NomaiInterfaceOrb>(); public static List<NomaiInterfaceOrb> OldOrbList = new List<NomaiInterfaceOrb>();
public static List<CharacterDialogueTree> OldDialogueTrees = new List<CharacterDialogueTree>(); public static List<CharacterDialogueTree> OldDialogueTrees = new List<CharacterDialogueTree>();
public static void InitOnSceneLoaded(OWScene scene, bool inUniverse) public static void InitOnSceneLoaded(GameObject orbPrefab)
{ {
OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList(); OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList();
if (NetworkServer.active) if (NetworkServer.active)
{ {
OldOrbList.ForEach(x => NetworkServer.Spawn(UnityEngine.Object.Instantiate(QSBNetworkManager.Instance.OrbPrefab))); OldOrbList.ForEach(x => NetworkServer.Spawn(UnityEngine.Object.Instantiate(orbPrefab)));
} }
OldDialogueTrees = Resources.FindObjectsOfTypeAll<CharacterDialogueTree>().ToList(); OldDialogueTrees = Resources.FindObjectsOfTypeAll<CharacterDialogueTree>().ToList();