コード例 #1
0
        public bool Lock()
        {
            if (deployAnimator == null)
            {
                return(true);
            }

            if (!fsm.currentStateName.StartsWith("deployed", StringComparison.InvariantCultureIgnoreCase) && !fsm.currentStateName.StartsWith("stowed", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            if (_lockCount == 0)
            {
                if (fsm.CurrentState == st_stowed)
                {
                    fsm.RunEvent(on_lock_stowed);
                }
                else if (fsm.CurrentState == st_deployed)
                {
                    fsm.RunEvent(on_lock_deployed);
                }
            }

            _lockCount += 1;
            return(true);
        }
コード例 #2
0
 public static void RunEvent(this KerbalFSM fsm, string name)
 {
     foreach (var kfsme in fsm.CurrentState.StateEvents)
     {
         if (kfsme.name == name)
         {
             fsm.RunEvent(kfsme);
         }
         else
         {
             Debug.LogError("[assembly: " + Assembly.GetExecutingAssembly().GetName().Name + "]:" + "Event " + name + " not found");
         }
     }
 }