mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-22 21:40:39 +00:00
cleanup
This commit is contained in:
parent
2d8ea703e2
commit
a707d5f9e0
@ -38,7 +38,8 @@ namespace QSB.ConversationSync
|
||||
{
|
||||
break;
|
||||
}
|
||||
UnityEngine.Object.Destroy(ConversationManager.Instance.BoxMappings[WorldRegistry.OldDialogueTrees[message.ObjectId]]);
|
||||
var tree = WorldRegistry.OldDialogueTrees[message.ObjectId];
|
||||
UnityEngine.Object.Destroy(ConversationManager.Instance.BoxMappings[tree]);
|
||||
break;
|
||||
case ConversationType.ClosePlayer:
|
||||
UnityEngine.Object.Destroy(PlayerRegistry.GetPlayer((uint)message.ObjectId).CurrentDialogueBox);
|
||||
|
@ -40,14 +40,17 @@ namespace QSB.ConversationSync
|
||||
var treeIndex = WorldRegistry.OldDialogueTrees.IndexOf(tree);
|
||||
if (!PlayerRegistry.PlayerList.Any(x => x.CurrentDialogueID == treeIndex))
|
||||
{
|
||||
// No player talking to tree
|
||||
return uint.MaxValue;
|
||||
}
|
||||
// .First() should be fine here as only one player should be talking to a character.
|
||||
return PlayerRegistry.PlayerList.First(x => x.CurrentDialogueID == treeIndex).PlayerId;
|
||||
}
|
||||
|
||||
public void SendPlayerOption(string text)
|
||||
{
|
||||
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, text, ConversationType.Player);
|
||||
GlobalMessenger<uint, string, ConversationType>
|
||||
.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, text, ConversationType.Player);
|
||||
}
|
||||
|
||||
public void SendCharacterDialogue(int id, string text)
|
||||
@ -57,37 +60,31 @@ namespace QSB.ConversationSync
|
||||
DebugLog.ToConsole("Warning - Tried to send conv. event with char id -1.", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, (uint)id, text, ConversationType.Character);
|
||||
GlobalMessenger<uint, string, ConversationType>
|
||||
.FireEvent(EventNames.QSBConversation, (uint)id, text, ConversationType.Character);
|
||||
}
|
||||
|
||||
public void CloseBoxPlayer()
|
||||
{
|
||||
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, "", ConversationType.ClosePlayer);
|
||||
GlobalMessenger<uint, string, ConversationType>
|
||||
.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, "", ConversationType.ClosePlayer);
|
||||
}
|
||||
|
||||
public void CloseBoxCharacter(int id)
|
||||
{
|
||||
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, (uint)id, "", ConversationType.CloseCharacter);
|
||||
GlobalMessenger<uint, string, ConversationType>
|
||||
.FireEvent(EventNames.QSBConversation, (uint)id, "", ConversationType.CloseCharacter);
|
||||
}
|
||||
|
||||
public void SendStart(int charId)
|
||||
public void SendConvState(int charId, bool state)
|
||||
{
|
||||
if (charId == -1)
|
||||
{
|
||||
DebugLog.ToConsole("Warning - Tried to send conv. start event with char id -1.", MessageType.Warning);
|
||||
DebugLog.ToConsole("Warning - Tried to send conv. start/end event with char id -1.", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
GlobalMessenger<int, uint, bool>.FireEvent(EventNames.QSBConversationStartEnd, charId, PlayerRegistry.LocalPlayerId, true);
|
||||
}
|
||||
|
||||
public void SendEnd(int charId)
|
||||
{
|
||||
if (charId == -1)
|
||||
{
|
||||
DebugLog.ToConsole("Warning - Tried to send conv. end event with char id -1.", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
GlobalMessenger<int, uint, bool>.FireEvent(EventNames.QSBConversationStartEnd, charId, PlayerRegistry.LocalPlayerId, false);
|
||||
GlobalMessenger<int, uint, bool>
|
||||
.FireEvent(EventNames.QSBConversationStartEnd, charId, PlayerRegistry.LocalPlayerId, state);
|
||||
}
|
||||
|
||||
public void DisplayPlayerConversationBox(uint playerId, string text)
|
||||
|
@ -16,7 +16,7 @@ namespace QSB.ConversationSync
|
||||
DebugLog.ToConsole($"Warning - Index for tree {__instance.name} was -1.", MessageType.Warning);
|
||||
}
|
||||
PlayerRegistry.LocalPlayer.CurrentDialogueID = index;
|
||||
ConversationManager.Instance.SendStart(index);
|
||||
ConversationManager.Instance.SendConvState(index, true);
|
||||
}
|
||||
|
||||
public static bool EndConversation(CharacterDialogueTree __instance)
|
||||
@ -30,7 +30,7 @@ namespace QSB.ConversationSync
|
||||
DebugLog.ToConsole($"Warning - Ending conversation with CurrentDialogueId of -1! Called from {__instance.name}", MessageType.Warning);
|
||||
return false;
|
||||
}
|
||||
ConversationManager.Instance.SendEnd(PlayerRegistry.LocalPlayer.CurrentDialogueID);
|
||||
ConversationManager.Instance.SendConvState(PlayerRegistry.LocalPlayer.CurrentDialogueID, false);
|
||||
ConversationManager.Instance.CloseBoxCharacter(PlayerRegistry.LocalPlayer.CurrentDialogueID);
|
||||
PlayerRegistry.LocalPlayer.CurrentDialogueID = -1;
|
||||
ConversationManager.Instance.CloseBoxPlayer();
|
||||
|
@ -35,10 +35,13 @@ namespace QSB.ConversationSync
|
||||
}
|
||||
var dialogueTree = WorldRegistry.OldDialogueTrees[message.CharacterId];
|
||||
var animController = Resources.FindObjectsOfTypeAll<CharacterAnimController>().FirstOrDefault(x => x.GetValue<CharacterDialogueTree>("_dialogueTree") == dialogueTree);
|
||||
|
||||
// Make character face player and talk
|
||||
if (animController != default(CharacterAnimController))
|
||||
{
|
||||
if (message.State)
|
||||
{
|
||||
// Start talking
|
||||
PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = message.CharacterId;
|
||||
animController.SetValue("_inConversation", true);
|
||||
animController.SetValue("_playerInHeadZone", true);
|
||||
@ -47,10 +50,10 @@ namespace QSB.ConversationSync
|
||||
animController.GetValue<Animator>("_animator").SetTrigger("Talking");
|
||||
}
|
||||
dialogueTree.GetComponent<InteractVolume>().DisableInteraction();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stop talking
|
||||
PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = -1;
|
||||
animController.SetValue("_inConversation", false);
|
||||
animController.SetValue("_playerInHeadZone", false);
|
||||
@ -62,21 +65,20 @@ namespace QSB.ConversationSync
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
var qsbFacePlayer = dialogueTree.GetComponent<QSBFacePlayerWhenTalking>();
|
||||
if (qsbFacePlayer == null)
|
||||
// Make character turn to player (if they're meant to)
|
||||
var qsbFacePlayer = dialogueTree.GetComponentInParent<QSBFacePlayerWhenTalking>();
|
||||
if (qsbFacePlayer != null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - QSBFacePlayerWhenTalking not found for object ID {message.CharacterId}!", MessageType.Error);
|
||||
if (message.State)
|
||||
{
|
||||
DebugLog.DebugWrite("start convo faceplayer for " + message.CharacterId);
|
||||
qsbFacePlayer.StartConversation(PlayerRegistry.GetPlayer(message.PlayerId).Body.transform.position);
|
||||
}
|
||||
else
|
||||
{
|
||||
qsbFacePlayer.EndConversation();
|
||||
}
|
||||
}
|
||||
if (message.State)
|
||||
{
|
||||
qsbFacePlayer.StartConversation(PlayerRegistry.GetPlayer(message.PlayerId).Camera.transform.position);
|
||||
}
|
||||
else
|
||||
{
|
||||
qsbFacePlayer.EndConversation();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user