protected virtual IEnumerator Walk(WalkCommand cmd)
 {
     if (cmd.destination == null)
     {
         Debug.LogError("Has no destination: " + cmd.ToString());
         yield break;
     }
     yield return(StartCoroutine(Walk(cmd, cmd.destination, cmd.endingStyle, cmd.updatePosition, cmd.stoppingDistance, cmd.lerpAtEndPrecisely)));
 }
 protected virtual IEnumerator CommitWalk(WalkCommand cmd)
 {
     // if sitting, must standup
     if (SeatState != null)
     {
         // is this neccessary?
         Log.Write(name + " received Walk, but is sitting. StandingUp.", LogRecordType.Commander);
         yield return(StartCoroutine(StandUp()));
     }
     yield return(StartCoroutine(Walk(cmd)));
 }
        private static WalkCommand WalkFromString(Commander Owner, int Priority, CommandState State, float Delay, ushort SyncId, ushort Successor, ushort Predecesssor, List <ushort> SyncsWithList, string[] parsed)
        {
            GameObject Destination = null;

            WalkCommand.WalkCommandEndingStyle EndStyle = WalkCommand.WalkCommandEndingStyle.None;
            bool  LerpAtEnd = true;
            float StopDist  = DefaultStoppingDistance;
            bool  Catching  = false;
            float Speed     = DefaultWalkSpeed;

            foreach (string s in parsed)
            {
                string attribute;
                string value;
                GetAttributeAndValue(s, out attribute, out value);
                switch (attribute)
                {
                case "dest": Destination = ObjectIdentifier.Find(value).gameObject; break;

                case "spd": Speed = float.Parse(value); break;

                case "end": EndStyle = (WalkCommand.WalkCommandEndingStyle) int.Parse(value); break;

                case "lrp": LerpAtEnd = bool.Parse(value); break;

                case "ctc": Catching = bool.Parse(value); break;

                case "stdst": StopDist = float.Parse(value); break;
                }
            }

            WalkCommand wc = Walk(Owner, Destination, Priority, Delay, EndStyle, LerpAtEnd, Speed, Catching, StopDist);

            wc.syncId      = SyncId;
            wc.predecessor = Predecesssor;
            wc.successor   = Successor;
            wc.syncsWith   = SyncsWithList;
            wc.state       = State;
            return(wc);
        }
        /// <summary>
        /// Creates a WalkCommand.
        /// </summary>
        /// <param name="Owner">Subject commander</param>
        /// <param name="Destination">Destination transform to reach.</param>
        /// <param name="EndStyle">Style of aligning at the end. Default: none</param>
        /// <param name="PrecisionAlignAtEnd">Will lerp to the transform's position precisely. Default: false</param>
        /// <param name="Speed">Maximum value of the animator blend tree parameter.</param>
        /// <param name="Priority">Command priority</param>
        /// <param name="Catch">Update NMA target destination for a moving target. Default: false</param>
        /// <param name="StoppingDistance">Stops at the distance from the target. Default: see constant in Command class</param>
        /// <param name="Delay">Delay to wait before commiting this command.</param>
        /// <returns></returns>
        public static WalkCommand Walk(
            Commander Owner,
            GameObject Destination,
            int?Priority = null,
            float?Delay  = null,
            WalkCommand.WalkCommandEndingStyle EndStyle = WalkCommand.WalkCommandEndingStyle.None,
            bool?PrecisionAlignAtEnd = null,
            float?Speed            = null,
            bool?Catch             = null,
            float?StoppingDistance = null
            )
        {
            if (Owner == null || Destination == null)
            {
                Log.Write("WalkCommand without an owner of a destination!", LogRecordType.Error);
            }
            WalkCommand c = new WalkCommand()
            {
                owner              = Owner,
                state              = CommandState.New,
                priority           = Priority == null ? DefaultCommandPriority : Priority.Value,
                delay              = Delay == null ? 0 : Delay.Value,
                speed              = Speed == null ? DefaultWalkSpeed : Speed.Value,
                destination        = Destination,
                endingStyle        = EndStyle,
                lerpAtEndPrecisely = PrecisionAlignAtEnd == null ? false : PrecisionAlignAtEnd.Value,
                updatePosition     = Catch == null ? false : Catch.Value,
                stoppingDistance   = StoppingDistance == null ? DefaultStoppingDistance : StoppingDistance.Value
            };

            if (Destination.GetObjectIdentifier() == null)
            {
                Log.Write("Walk command destination has no ObjectIdentifier. This is problematic over network and in other cases. " + c.ToString(), LogRecordType.Warning);
            }
            return(c);
        }