Beispiel #1
0
 private void UpdatePushing()
 {
     if (!UpdateAnimation)
     {
         return;
     }
     if (IsPushing() && PushSensor.IsColliding())
     {
         var collider = PushSensor.GetCollider() as IPushable;
         collider?.Push(Facing);
     }
 }
Beispiel #2
0
        public override void _Process(float delta)
        {
            if (IsFrozen)
            {
                PlayerAnimation.Stop();
            }
            else
            {
                PlayerAnimation.Play();
            }

            base._Process(delta);

            if (!IsFrozen && IsAlive)
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (PlayerInput.MoveVector.Length() == 1)
                {
                    Facing = PlayerInput.MoveVector;
                }

                PushSensor.CastTo = Facing * 6;
                PushSensor.ForceRaycastUpdate();

                UpdatePlayerAnimation();
                UpdatePushing();

                if (DamageArea.Monitoring)
                {
                    foreach (var body in DamageArea.GetOverlappingBodies().Cast <Node>())
                    {
                        /* Allow sword to pick up items */
                        _on_ItemDetector_body_entered(body);

                        if (!(body is IDamageable damageable))
                        {
                            continue;
                        }
                        damageable.Damage(Facing);
                    }
                }
            }
        }