Example #1
0
        /// <summary>
        /// Clones from the other component.
        /// </summary>
        /// <param name="other">The component to clone from.</param>
        public void CloneFrom(IHeightNavigator other)
        {
            var rhs = other as DefaultHeightNavigator;

            if (rhs == null)
            {
                return;
            }

            _gravity      = rhs.gravity;
            _providerType = rhs._providerType;
            this.groundStickynessFactor = rhs.groundStickynessFactor;
            this.terminalVelocity       = rhs.terminalVelocity;
        }
        private void Awake()
        {
            this.WarnIfMultipleInstances();

            _transform = this.transform;
            var rb = this.GetComponent <Rigidbody>();

            //Resolve the mover
            _mover = this.As <IMoveUnits>();
            if (_mover == null)
            {
                var fact           = this.As <IMoveUnitsFactory>();
                var charController = this.GetComponent <CharacterController>();

                if (fact != null)
                {
                    _mover = fact.Create();
                }
                else if (charController != null)
                {
                    _mover = new CharacterControllerMover(charController);
                }
                else if (rb != null)
                {
                    _mover = new RigidBodyMover(rb);
                }
                else
                {
                    _mover = new DefaultMover(_transform);
                }
            }

            //Height resolver
            _heights = this.As <IHeightNavigator>();
            if (_heights == null)
            {
                _heights = NoHeightNavigator.Instance;
            }

            //Assign unit ref, container for components and steering visitors
            _steeringComponents    = new List <ISteeringBehaviour>();
            _orientationComponents = new List <IOrientationBehaviour>();
            _steering      = new SteeringOutput();
            _orientation   = new OrientationOutput();
            _steeringInput = new SteeringInput();
        }
        private void Awake()
        {
            this.WarnIfMultipleInstances();

            _transform = this.transform;
            var rb = this.GetComponent<Rigidbody>();

            //Resolve the mover
            _mover = this.As<IMoveUnits>();
            if (_mover == null)
            {
                var fact = this.As<IMoveUnitsFactory>();
                var charController = this.GetComponent<CharacterController>();

                if (fact != null)
                {
                    _mover = fact.Create();
                }
                else if (charController != null)
                {
                    _mover = new CharacterControllerMover(charController);
                }
                else if (rb != null)
                {
                    _mover = new RigidBodyMover(rb);
                }
                else
                {
                    _mover = new DefaultMover(_transform);
                }
            }

            //Height resolver
            _heights = this.As<IHeightNavigator>();
            if (_heights == null)
            {
                _heights = NoHeightNavigator.Instance;
            }

            //Assign unit ref, container for components and steering visitors
            _steeringComponents = new List<ISteeringBehaviour>();
            _orientationComponents = new List<IOrientationBehaviour>();
            _steering = new SteeringOutput();
            _orientation = new OrientationOutput();
            _steeringInput = new SteeringInput();
        }
 public void CloneFrom(IHeightNavigator other)
 {
     /* NOOP */
 }
        /// <summary>
        /// Clones from the other component.
        /// </summary>
        /// <param name="other">The component to clone from.</param>
        public void CloneFrom(IHeightNavigator other)
        {
            var rhs = other as DefaultHeightNavigator;
            if (rhs == null)
            {
                return;
            }

            _gravity = rhs.gravity;
            _providerType = rhs._providerType;
            this.groundStickynessFactor = rhs.groundStickynessFactor;
            this.terminalVelocity = rhs.terminalVelocity;
        }
Example #6
0
 /// <summary>
 /// Clones from the other component.
 /// </summary>
 /// <param name="other">The component to clone from.</param>
 public void CloneFrom(IHeightNavigator other)
 {
     /* NOOP */
 }