void FixedUpdate()
 {
     if (OnFixedUpdate != null)
     {
         OnFixedUpdate.Invoke();
     }
 }
Example #2
0
    public void FixedUpdate()
    {
        OnFixedUpdate?.Invoke();

        foreach (Entity entity in _entities.ToList())
        {
            entity.FixedUpdate();
        }

        foreach (Entity entity in _entities.ToList())
        {
            entity.GetCommands();
        }

        foreach (Entity entity in _entities.ToList())
        {
            entity.ExecuteCommands();
        }

        foreach (Entity entity in _entities.ToList())
        {
            entity.UpdatePhysics();
        }
        UpdatePhysics?.Invoke();
    }
 protected virtual void FixedUpdate()
 {
     if (GameManager.playing)
     {
         OnFixedUpdate?.Invoke();
     }
 }
 private void FixedUpdate()
 {
     if (OnFixedUpdate != null)
     {
         OnFixedUpdate.Invoke(Time.deltaTime);
     }
 }
Example #5
0
        /// <summary>
        ///     Adds the current deltaTime to update ticks and processes simulated fixed update.
        /// </summary>
        private void UpdateTicks(float deltaTime)
        {
            updateTicks += deltaTime;
            while (updateTicks >= adjustedFixedUpdate)
            {
                updateTicks -= adjustedFixedUpdate;

                //If at maximum value then reset fixed frame.
                //This would probably break the game but even at 128t/s
                //it would take over a year of the server running straight to ever reach this value!
                if (FixedFrame == uint.MaxValue)
                {
                    FixedFrame = 0;
                }

                FixedFrame++;

                OnPreFixedUpdate?.Invoke();
                OnFixedUpdate?.Invoke();

                Physics2D.Simulate(Time.fixedDeltaTime);
                Physics.Simulate(Time.fixedDeltaTime);

                OnPostFixedUpdate?.Invoke();
            }

            //Recover timing towards default fixedDeltaTime.
            adjustedFixedUpdate =
                Mathf.MoveTowards(adjustedFixedUpdate, Time.fixedDeltaTime, TIMING_RECOVER_RATE * deltaTime);
        }
    /// <summary>
    /// fixed update cycle called by the state
    /// stores velocity of body into Velocity at start
    /// and sets body velocity at end to current Velocity
    /// </summary>
    public void FixedUpdate()
    {
        Velocity = body.velocity;

        OnFixedUpdate?.Invoke();

        body.velocity = Velocity;
    }
Example #7
0
 public void Tick()
 {
     while ((lastUpdate + _updateFrequency) < Time)
     {
         OnFixedUpdate.Invoke();
         lastUpdate += _updateFrequency;
     }
 }
Example #8
0
    private void FixedUpdate()
    {
        m_FixedTime += Time.deltaTime;
        if (m_FixedTime >= 1)
        {
            m_FixedTime--;
            OnTick?.Invoke();
        }

        OnFixedUpdate?.Invoke();
    }
Example #9
0
 public void FixedUpdate()
 {
     if (_invincibilityTimer == 0)
     {
         IsInvincible = false;
     }
     else
     {
         _invincibilityTimer--;
     }
     OnFixedUpdate?.Invoke(this);
 }
Example #10
0
        public RuntimeService()
        {
            _runtimeGameObject = new GameObject("RuntimeClients");

            Object.DontDestroyOnLoad(_runtimeGameObject);

            _runtimeClient = RegisterClient <RuntimeClient>();

            _runtimeClient.OnUpdate      += () => OnUpdate?.Invoke();
            _runtimeClient.OnFixedUpdate += () => OnFixedUpdate?.Invoke();
            _runtimeClient.OnLateUpdate  += () => OnLateUpdate?.Invoke();
            _runtimeClient.OnQuit        += () => OnQuit?.Invoke();
            _runtimeClient.OnPause       += pause => OnPause?.Invoke(pause);
        }
Example #11
0
    private void ManualFixedUpdate()
    {
        switch (Type)
        {
        case PlayerObjectType.ThisPlayer:
            Tick++;
            UserInput           = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
            _inputHistory[Tick] = UserInput;
            OnFixedUpdate?.Invoke(UserInput, Tick);

            _oldPosition       = _position;
            _position         += UserInput * Consts.ClientSpeed * Time.fixedDeltaTime;
            transform.position = _position;
            break;
        }
    }
Example #12
0
        internal void FixedUpdateInternal()
        {
            if (PhysicsEnabled)
            {
                float   deg = MathHelper.ToDegrees(PhysicsBody.Rotation);
                Vector2 pos = (PhysicsBody.Position - (PhysicsShapeOffset * Physics.UPP)) / Physics.UPP;

                Position = pos;
                Rotation = deg;

                if (VelocityDampingX != 0 || VelocityDampingY != 0)
                {
                    float velocityDampLerpX = MathHelper.Lerp(PhysicsBody.LinearVelocity.X, 0.0f, VelocityDampingX);
                    float velocityDampLerpY = MathHelper.Lerp(PhysicsBody.LinearVelocity.Y, 0.0f, VelocityDampingY);
                    PhysicsBody.LinearVelocity = new Vector2(velocityDampLerpX, velocityDampLerpY);
                }
            }

            FixedUpdate();
            OnFixedUpdate.Invoke();
        }
Example #13
0
 public virtual void FixedUpdateCallback()
 {
     OnFixedUpdate?.Invoke();
 }
 private void FixedUpdate()
 {
     OnFixedUpdate?.Invoke();
 }
Example #15
0
 private void FixedUpdate()
 {
     OnFixedUpdate.SafeInvoke();
 }
Example #16
0
 protected virtual void FixedUpdate()
 {
     OnFixedUpdate?.Invoke();
 }
Example #17
0
 protected virtual void FixedUpdate()
 {
     OnFixedUpdate?.Invoke(Time.fixedDeltaTime);
 }
Example #18
0
 protected override void StateFixedUpdate()
 {
     base.StateFixedUpdate();
     OnFixedUpdate?.Invoke(this);
 }
 void FixedUpdate()
 {
     OnFixedUpdate?.Invoke(Time.fixedDeltaTime);
 }
 void FixedUpdate() => OnFixedUpdate?.Invoke();
Example #21
0
 public void InvokeOnFixedUpdate(float fDelta)
 {
     OnFixedUpdate?.Invoke(this, fDelta);
 }