private void ExtractSpeech(ActionSpeech action, bool onlySeekNew, bool isInScene) { string speaker = ""; bool isPlayer = action.isPlayer; if (!isPlayer && action.speaker != null && action.speaker is Player) { isPlayer = true; } if (isPlayer) { speaker = "Player"; if (action.isPlayer && KickStarter.settingsManager != null && KickStarter.settingsManager.player) { speaker = KickStarter.settingsManager.player.name; } else if (action.speaker != null) { speaker = action.speaker.name; } } else { if (!isInScene) { action.SetSpeaker (); } if (action.speaker) { speaker = action.speaker.name; } else { speaker = "Narrator"; } } if (speaker != "" && action.messageText != "") { if (separateLines) { string[] messages = action.GetSpeechArray (); if (messages != null && messages.Length > 0) { action.lineID = ProcessSpeechLine (onlySeekNew, isInScene, action.lineID, speaker, messages[0], isPlayer); if (messages.Length > 1) { if (action.multiLineIDs == null || action.multiLineIDs.Length != (messages.Length - 1)) { List<int> lineIDs = new List<int>(); for (int i=1; i<messages.Length; i++) { if (action.multiLineIDs != null && action.multiLineIDs.Length > (i-1)) { lineIDs.Add (action.multiLineIDs[i-1]); } else { lineIDs.Add (-1); } } action.multiLineIDs = lineIDs.ToArray (); } for (int i=1; i<messages.Length; i++) { action.multiLineIDs [i-1] = ProcessSpeechLine (onlySeekNew, isInScene, action.multiLineIDs [i-1], speaker, messages[i], isPlayer); } } } } else { action.lineID = ProcessSpeechLine (onlySeekNew, isInScene, action.lineID, speaker, action.messageText, isPlayer); } } else { // Remove from SpeechManager action.lineID = -1; action.multiLineIDs = null; } }
private void ExtractSpeech(ActionSpeech action, bool onlySeekNew, bool isInScene) { string speaker = ""; bool isPlayer = action.isPlayer; if (action.isPlayer) { if (KickStarter.settingsManager && KickStarter.settingsManager.player) { speaker = KickStarter.settingsManager.player.name; } else { speaker = "Player"; } } else { if (!isInScene) { action.SetSpeaker (); } if (action.speaker) { speaker = action.speaker.name; } else { speaker = "Narrator"; } } if (speaker != "" && action.messageText != "") { if (onlySeekNew && action.lineID == -1) { // Assign a new ID on creation string _scene = ""; SpeechLine newLine; if (isInScene) { _scene = EditorApplication.currentScene; } newLine = new SpeechLine (GetIDArray(), _scene, speaker, action.messageText, languages.Count - 1, AC_TextType.Speech, isPlayer); action.lineID = newLine.lineID; lines.Add (newLine); } else if (!onlySeekNew && action.lineID > -1) { // Already has an ID, so don't replace string _scene = ""; SpeechLine existingLine; if (isInScene) { _scene = EditorApplication.currentScene; } existingLine = new SpeechLine (action.lineID, _scene, speaker, action.messageText, languages.Count - 1, AC_TextType.Speech, isPlayer); int lineID = SmartAddLine (existingLine); if (lineID >= 0) action.lineID = lineID; } } else { // Remove from SpeechManager action.lineID = -1; } }