Exemple #1
0
        private void OnPlayerInput(PlayerSession session, InputControls input)
        {
            if (!players.ContainsKey(session) || !players[session].IsFlying)
            {
                return;
            }

            CharacterMotorSimple motor = session.WorldPlayerEntity.GetComponent <CharacterMotorSimple>();
            EntityStats          stats = session.WorldPlayerEntity.GetComponent <EntityStats>();

            if (!motor)
            {
                return;
            }

            Vector3 direction = new Vector3(IntFromBool(input.StrafeLeft) * -1 + IntFromBool(input.StrafeRight), 0f, IntFromBool(input.Backward) * -1 + IntFromBool(input.Forward));
            float   speed     = players[session].BaseSpeed;

            motor.IsGrounded = true;
            direction        = motor.RotationToAimDirectionCache * direction.normalized;

            if (input.Forward)
            {
                direction.y = input.DirectionVector.y;
            }

            if (input.Backward)
            {
                direction.y = -input.DirectionVector.y;
            }

            if (input.Sprint)
            {
                speed *= 2;
            }

            if (motor._state.IsCrouching)
            {
                speed /= 2;
            }

            motor.Set_currentVelocity(motor.Accelerate(direction, speed, motor.GetVelocity(), 5, 5));

            if (!stats)
            {
                return;
            }

            Dictionary <EntityFluidEffectKey, IEntityFluidEffect> effects = stats.GetFluidEffects();

            foreach (KeyValuePair <EntityFluidEffectKey, IEntityFluidEffect> effect in effects)
            {
                effect.Value.Reset(true);
            }
        }
Exemple #2
0
        private void Heal(PlayerSession player)
        {
            EntityStats stats = player.WorldPlayerEntity.GetComponent <EntityStats>();
            Dictionary <EntityFluidEffectKey, IEntityFluidEffect> effects = stats.GetFluidEffects();

            foreach (KeyValuePair <EntityFluidEffectKey, IEntityFluidEffect> effect in effects)
            {
                if (!effect.Key.name.Contains("Inventory") && !effect.Key.name.Contains("Armor"))
                {
                    effect.Value.Reset(true);
                }
            }
        }