add boxes for characters

This commit is contained in:
Mister_Nebula 2020-10-24 11:17:52 +01:00
parent 3742e36248
commit e9d39634ab
6 changed files with 40 additions and 18 deletions

Binary file not shown.

View File

@ -1,22 +1,16 @@
ManifestFileVersion: 0
CRC: 674027210
CRC: 3469869292
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 207385c19798113635f73bd17e7c2e5c
Hash: 86686b50f40f37c15d0bca36dcaff7af
TypeTreeHash:
serializedVersion: 2
Hash: 27971550fda62b1a0371f7196924aa6c
Hash: 6ce89620af51ba381c9e4f226a2ebb1b
HashAppended: 0
ClassTypes:
- Class: 1
Script: {instanceID: 0}
- Class: 21
Script: {instanceID: 0}
- Class: 28
Script: {instanceID: 0}
- Class: 48
Script: {instanceID: 0}
- Class: 114
Script: {fileID: 1741964061, guid: f70555f144d8491a825f0804e09c671c, type: 3}
- Class: 114
@ -27,8 +21,6 @@ ClassTypes:
Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
- Class: 115
Script: {instanceID: 0}
- Class: 128
Script: {instanceID: 0}
- Class: 222
Script: {instanceID: 0}
- Class: 223

View File

@ -1,5 +1,7 @@
using QSB.Events;
using QSB.Messaging;
using QSB.Utility;
using QSB.WorldSync;
namespace QSB.ConversationSync
{
@ -23,6 +25,7 @@ namespace QSB.ConversationSync
public override void OnReceiveRemote(ConversationMessage message)
{
DebugLog.DebugWrite($"Conv. type {message.Type} id {message.ObjectId} text {message.Message}");
switch (message.Type)
{
case ConversationType.Character:
@ -33,6 +36,7 @@ namespace QSB.ConversationSync
ConversationManager.Instance.DisplayPlayerConversationBox((uint)message.ObjectId, message.Message);
break;
case ConversationType.EndCharacter:
UnityEngine.Object.Destroy(ConversationManager.Instance.BoxMappings[WorldRegistry.OldDialogueTrees[message.ObjectId]]);
break;
case ConversationType.EndPlayer:
UnityEngine.Object.Destroy(PlayerRegistry.GetPlayer((uint)message.ObjectId).CurrentDialogueBox);

View File

@ -2,6 +2,8 @@
using OWML.ModHelper.Events;
using QSB.Events;
using QSB.Utility;
using QSB.WorldSync;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@ -12,6 +14,7 @@ namespace QSB.ConversationSync
public static ConversationManager Instance { get; private set; }
public AssetBundle ConversationAssetBundle { get; private set; }
private GameObject BoxPrefab;
public Dictionary<CharacterDialogueTree, GameObject> BoxMappings = new Dictionary<CharacterDialogueTree, GameObject>();
private void Start()
{
@ -21,7 +24,7 @@ namespace QSB.ConversationSync
DebugLog.LogState("ConversationBundle", ConversationAssetBundle);
BoxPrefab = ConversationAssetBundle.LoadAsset<GameObject>("assets/dialoguebubble.prefab");
var font = (Font)Resources.Load(@"fonts\english - latin\SpaceMono-Bold");
var font = (Font)Resources.Load(@"fonts\english - latin\spacemono-bold");
if (font == null)
{
DebugLog.ToConsole("Error - Font is null!", MessageType.Error);
@ -32,21 +35,25 @@ namespace QSB.ConversationSync
public void SendPlayerOption(string text)
{
DebugLog.DebugWrite("sending player option - " + text);
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, text, ConversationType.Player);
}
public void SendCharacterDialogue(int id, string text)
{
DebugLog.DebugWrite("sending char dialoge - " + text);
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, (uint)id, text, ConversationType.Character);
}
public void EndConversationPlayer()
{
DebugLog.DebugWrite("Ending conversation -- player");
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, "", ConversationType.EndPlayer);
}
public void EndConversationCharacter(int id)
{
DebugLog.DebugWrite("Ending conversation -- character");
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, (uint)id, "", ConversationType.EndCharacter);
}
@ -63,7 +70,6 @@ namespace QSB.ConversationSync
newBox.transform.parent = PlayerRegistry.GetPlayer(playerId).Body.transform;
newBox.transform.localPosition = new Vector3(0, 25, 0);
newBox.transform.rotation = PlayerRegistry.GetPlayer(playerId).Body.transform.rotation;
//newBox.transform.LookAt(PlayerRegistry.LocalPlayer.Camera.transform, PlayerRegistry.GetPlayer(playerId).Body.transform.up);
var lookAt = newBox.AddComponent<FaceActiveCamera>();
lookAt.SetValue("_useLookAt", false);
lookAt.SetValue("_localFacingVector", Vector3.back);
@ -76,7 +82,26 @@ namespace QSB.ConversationSync
public void DisplayCharacterConversationBox(int index, string text)
{
var oldDialogueTree = WorldRegistry.OldDialogueTrees[index];
if (BoxMappings.ContainsKey(oldDialogueTree))
{
Destroy(BoxMappings[oldDialogueTree]);
BoxMappings.Remove(oldDialogueTree);
}
var newBox = Instantiate(BoxPrefab);
newBox.SetActive(false);
newBox.transform.parent = oldDialogueTree.gameObject.transform;
newBox.transform.localPosition = new Vector3(0, 2, 0);
newBox.transform.rotation = oldDialogueTree.gameObject.transform.rotation;
var lookAt = newBox.AddComponent<FaceActiveCamera>();
lookAt.SetValue("_useLookAt", false);
lookAt.SetValue("_localFacingVector", Vector3.back);
lookAt.SetValue("_localRotationAxis", Vector3.up);
newBox.GetComponent<Text>().text = text;
newBox.SetActive(true);
BoxMappings.Add(oldDialogueTree, newBox);
}
}
}

View File

@ -15,6 +15,7 @@ namespace QSB.ConversationSync
public static void EndConversation()
{
ConversationManager.Instance.EndConversationCharacter(PlayerRegistry.LocalPlayer.CurrentDialogueID);
PlayerRegistry.LocalPlayer.CurrentDialogueID = -1;
ConversationManager.Instance.EndConversationPlayer();
}
@ -24,7 +25,7 @@ namespace QSB.ConversationSync
if (optionIndex < 0)
{
// in a page where there is no selectable options
PlayerRegistry.LocalPlayer.CurrentDialogueID = -1;
//PlayerRegistry.LocalPlayer.CurrentDialogueID = -1;
ConversationManager.Instance.EndConversationPlayer();
return true;
}

View File

@ -60,7 +60,7 @@ MonoBehaviour:
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: fff59d5e06ad5b74497d7cc1dddc5e28, type: 2}
m_Material: {fileID: 2100000, guid: 08e1a88dddd41604db20b0dcb92d17d8, type: 2}
m_Color: {r: 1, g: 0.68275857, b: 0, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
@ -69,7 +69,7 @@ MonoBehaviour:
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Font: {fileID: 12800000, guid: 67f35d66c98319540bc681e5a18105d2, type: 2}
m_FontSize: 1
m_FontStyle: 0
m_BestFit: 0
@ -120,7 +120,7 @@ MonoBehaviour:
m_Script: {fileID: 1741964061, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!114 &114670735829080676
MonoBehaviour:
@ -205,7 +205,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: 25, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224902966460615240
RectTransform: