<commit_before>using System;
using UnityEngine;
using UnityEngine.Assertions;
using Zenject;

namespace Alensia.Core.Locomotion
{
    public abstract class Locomotion : ILocomotion, IInitializable, ITickable
    {
        public Transform Transform { get; private set; }

        public bool Active { get; private set; }

        private Vector3 _targetVelocity;

        private Vector3 _targetAngularVelocity;

        protected Locomotion(Transform transform)
        {
            Assert.IsNotNull(transform, "transform != null");

            Transform = transform;
        }

        public virtual void Initialize()
        {
            Activate();
        }

        public void Activate()
        {
            if (Active) return;

            Active = true;

            OnActivate();
        }

        public void Deactivate()
        {
            if (!Active) return;

            Active = false;

            OnDeactivate();
        }

        public float Move(Vector3 direction)
        {
            _targetVelocity = CalculateVelocity(direction.normalized);

            return _targetVelocity.magnitude;
        }

        public float MoveTowards(Vector3 position)
        {
            var offset = position - Transform.localPosition;

            var direction = offset.normalized;
            var distance = offset.magnitude;

            _targetVelocity = CalculateVelocity(direction, distance);

            return _targetVelocity.magnitude;
        }

        public float Rotate(Vector3 axis)
        {
            _targetAngularVelocity = CalculateAngularVelocity(axis.normalized);

            return _targetAngularVelocity.magnitude;
        }

        public float RotateTowards(Vector3 axis, float degree)
        {
            _targetAngularVelocity = CalculateAngularVelocity(axis.normalized, degree);

            return _targetAngularVelocity.magnitude * Math.Sign(degree);
        }

        private void Reset()
        {
            _targetVelocity = Vector3.zero;
            _targetAngularVelocity = Vector3.zero;
        }

        public virtual void Tick()
        {
            if (!Active) return;

            Update(_targetVelocity, _targetAngularVelocity);

            Reset();
        }

        protected virtual void OnActivate()
        {
            Reset();
        }

        protected virtual void OnDeactivate()
        {
            Reset();
        }

        protected abstract Vector3 CalculateVelocity(Vector3 direction, float? distance = null);

        protected abstract Vector3 CalculateAngularVelocity(Vector3 axis, float? degrees = null);

        protected virtual void Update(Vector3 velocity, Vector3 angularVelocity)
        {
            UpdateVelocity(velocity);
            UpdateRotation(angularVelocity);
        }

        protected abstract void UpdateVelocity(Vector3 velocity);

        protected abstract void UpdateRotation(Vector3 angularVelocity);
    }
}<commit_msg>Return 0 for projected speed when Locomotion is inactive<commit_after>using System;
using UnityEngine;
using UnityEngine.Assertions;
using Zenject;

namespace Alensia.Core.Locomotion
{
    public abstract class Locomotion : ILocomotion, IInitializable, ITickable
    {
        public Transform Transform { get; private set; }

        public bool Active { get; private set; }

        private Vector3 _targetVelocity;

        private Vector3 _targetAngularVelocity;

        protected Locomotion(Transform transform)
        {
            Assert.IsNotNull(transform, "transform != null");

            Transform = transform;
        }

        public virtual void Initialize()
        {
            Activate();
        }

        public void Activate()
        {
            if (Active) return;

            Active = true;

            OnActivate();
        }

        public void Deactivate()
        {
            if (!Active) return;

            Active = false;

            OnDeactivate();
        }

        public float Move(Vector3 direction)
        {
            if (!Active) return 0;

            _targetVelocity = CalculateVelocity(direction.normalized);

            return _targetVelocity.magnitude;
        }

        public float MoveTowards(Vector3 position)
        {
            if (!Active) return 0;

            var offset = position - Transform.localPosition;

            var direction = offset.normalized;
            var distance = offset.magnitude;

            _targetVelocity = CalculateVelocity(direction, distance);

            return _targetVelocity.magnitude;
        }

        public float Rotate(Vector3 axis)
        {
            if (!Active) return 0;

            _targetAngularVelocity = CalculateAngularVelocity(axis.normalized);

            return _targetAngularVelocity.magnitude;
        }

        public float RotateTowards(Vector3 axis, float degree)
        {
            if (!Active) return 0;

            _targetAngularVelocity = CalculateAngularVelocity(axis.normalized, degree);

            return _targetAngularVelocity.magnitude * Math.Sign(degree);
        }

        private void Reset()
        {
            _targetVelocity = Vector3.zero;
            _targetAngularVelocity = Vector3.zero;
        }

        public virtual void Tick()
        {
            if (!Active) return;

            Update(_targetVelocity, _targetAngularVelocity);

            Reset();
        }

        protected virtual void OnActivate()
        {
            Reset();
        }

        protected virtual void OnDeactivate()
        {
            Reset();
        }

        protected abstract Vector3 CalculateVelocity(Vector3 direction, float? distance = null);

        protected abstract Vector3 CalculateAngularVelocity(Vector3 axis, float? degrees = null);

        protected virtual void Update(Vector3 velocity, Vector3 angularVelocity)
        {
            UpdateVelocity(velocity);
            UpdateRotation(angularVelocity);
        }

        protected abstract void UpdateVelocity(Vector3 velocity);

        protected abstract void UpdateRotation(Vector3 angularVelocity);
    }
}
{'fraction_non_alphanumeric': 0.06886374815543532, 'fraction_numerical': 0.006066568289883587, 'mean_word_length': 1.8978622327790975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '403288', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1439, 'n_words': 374}