protected override bool OnCharacterEnter(Character character) { Motile motile = null; if (character.worlditem.Is <Motile>(out motile)) { if (State.ClearActions) { motile.StopMotileActions(); } MotileAction newMotileAction = ObjectClone.Clone <MotileAction>(State.Action); if (State.SequenceNodes) { string targetName = newMotileAction.Target.FileName.Replace("[#]", State.NumTimesTriggered.ToString()); newMotileAction.Target.FileName = targetName; } motile.PushMotileAction(newMotileAction, State.Priority); return(true); } return(false); }
protected IEnumerator Burrow(bool unBurrow) { yield return(null); if (worlditem.Is(WIActiveState.Visible | WIActiveState.Active)) { OrbSpeak(unBurrow ? OrbSpeakUnit.BeginningRoutine : OrbSpeakUnit.DaylightDetected, worlditem.tr); //wait for a bit so this gets offset if (!unBurrow) { motile.StopMotileActions(); } double waitUntil = WorldClock.AdjustedRealTime + UnityEngine.Random.value * 2f; while (WorldClock.AdjustedRealTime < waitUntil) { yield return(null); } string animName = unBurrow ? "OrbUnburrowingAnimation" : "OrbBurrowingAnimation"; motile.IsImmobilized = true; MasterAudio.PlaySound(MasterAudio.SoundType.Machines, "BurrowingMachine"); Animation anim = creature.Body.RootBodyPart.GetComponent <Animation> (); anim [animName].normalizedTime = 0f; anim [animName].normalizedSpeed = 1f; anim.Play(animName, PlayMode.StopAll); double nextEffectTime = WorldClock.AdjustedRealTime + 0.1f; while (anim [animName].normalizedTime < 1f) { //we can be killed in the meantime if (BehaviorState != (unBurrow ? OrbBehaviorState.Awakening : OrbBehaviorState.Burrowing)) { motile.IsImmobilized = false; anim.Stop(); motile.Body.RootBodyPart.tr.localRotation = Quaternion.identity; yield break; } if (WorldClock.AdjustedRealTime > nextEffectTime) { nextEffectTime = WorldClock.AdjustedRealTime + 0.75f; FXManager.Get.SpawnFX(gameObject, "BurrowEffect"); } yield return(null); } motile.IsImmobilized = false; anim.Stop(); motile.Body.RootBodyPart.tr.localRotation = Quaternion.identity; waitUntil = WorldClock.AdjustedRealTime + 3f; while (WorldClock.AdjustedRealTime < waitUntil) { yield return(null); } } BehaviorState = unBurrow ? OrbBehaviorState.ConsideringOptions : OrbBehaviorState.Despawning; if (!unBurrow) { worlditem.RemoveFromGame(); GameObject.Destroy(motile.Body.gameObject); Finish(); } yield break; }