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)));
 }
Пример #2
0
        /// <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);
        }