protected IEnumerator InterruptSpeech(DispatchedSpeech speech) { State.LastSpeechInterrupted = WorldClock.AdjustedRealTime; //update the speech data and save it to disk //note: this might be a problem since multiple NPCs will be giving speeches... //the data could get messed up speech.speech.InterruptSpeech(worlditem.FileName); mSpeechBubble.InterruptSpeech(); Mods.Get.Runtime.SaveMod <Speech> (speech.speech, "Speech", speech.speech.Name); //if the speech has messages and we have listeners, send message now mSpeechBubble = null; yield break; }
protected IEnumerator StartSpeech(DispatchedSpeech speech) { if (speech.speech == null) { Debug.Log("Speech is null, breaking"); } State.LastSpeechName = speech.speech.Name; State.LastSpeechStarted = WorldClock.AdjustedRealTime; State.LastSpeechPage = -1; speech.speech.StartSpeech(worlditem.FileName); Mods.Get.Runtime.SaveMod <Speech> (speech.speech, "Speech", speech.speech.Name); //send motile action Transform listenerTarget = null; Motile motile = null; Debug.Log("Giving speech over time in character..."); if (worlditem.Is <Motile> (out motile)) //get the listener target = use focus object { listenerTarget = motile.GoalObject; //send a motile action to keep the character in place //the FocusObject will be moved around by the speech bubble each page if (mSpeechMotileAction == null) { mSpeechMotileAction = new MotileAction(); } mSpeechMotileAction.Reset(); mSpeechMotileAction.Type = MotileActionType.FocusOnTarget; mSpeechMotileAction.Expiration = MotileExpiration.Never; if (speech.speech.CanBeInterrupted) //if we can be interrupted, let the speech cut off { mSpeechMotileAction.YieldBehavior = MotileYieldBehavior.YieldAndFinish; } else //if it can't be interrupted, do not yield to other actions { mSpeechMotileAction.YieldBehavior = MotileYieldBehavior.DoNotYield; } mSpeechMotileAction.IdleAnimation = GameWorld.Get.FlagByName("IdleAnimation", "Talking"); //we want normal because we want to reach the action node first motile.PushMotileAction(mSpeechMotileAction, MotileActionPriority.Next); } else { listenerTarget = worlditem.tr; } //create speech bubble mSpeechBubble = CreateSpeechBubble(speech.speech, speech.dispatcher, listenerTarget); yield break; }
protected IEnumerator FinishSpeech(DispatchedSpeech speech) { if (speech.speech == null) { Debug.Log("Speech was null, breaking without finishing"); yield break; } State.LastSpeechFinished = WorldClock.AdjustedRealTime; //update the speech data and save it to disk //note: this might be a problem since multiple NPCs will be giving speeches... //the data could get messed up if (mSpeechMotileAction != null) //try to finish it manually { mSpeechMotileAction.TryToFinish(); } speech.speech.FinishSpeech(worlditem.FileName); mSpeechBubble.FinishSpeech(); if (speech.dispatcher != null) { speech.dispatcher.OnFinishSpeech(); } Mods.Get.Runtime.SaveMod <Speech> (speech.speech, "Speech", speech.speech.Name); //if the speech has messages and we have listeners, send message now mSpeechBubble = null; //if we still have our saved motile action if (!string.IsNullOrEmpty(speech.speech.OnFinishMessage)) { if (!string.IsNullOrEmpty(speech.speech.OnFinishMessageParam)) { gameObject.SendMessage(speech.speech.OnFinishMessage, speech.speech.OnFinishMessageParam, SendMessageOptions.DontRequireReceiver); } else { gameObject.SendMessage(speech.speech.OnFinishMessage, SendMessageOptions.DontRequireReceiver); } } yield break; }