Ejemplo n.º 1
0
        public virtual void Update(InputComponent input, PlayerFieldCharacter character)
        {
            var characterCollider = character.CharacterComponent;

            if (input.Interact && RequiresInteraction)
            {
                var startPos   = character.Entity.Transform.Position + new Vector3(0, 0.5f, 0);
                var forwardvec = startPos + (character.GetForwardVector() * 2.0f);
                var hitresult  = this.GetSimulation().Raycast(startPos, forwardvec, CollisionFilterGroups.SensorTrigger, CollisionFilterGroupFlags.SensorTrigger);
                if (hitresult.Collider == _collider && (this.Entity.Transform.Position - character.Entity.Transform.Position).LengthSquared() < _minimumDistance)
                {
                    //Ensure character and eventbox are facing each other when interacting.
                    forwardvec.Normalize();
                    var eventNormal     = Entity.Transform.RotationEulerXYZ.Forward();
                    var characterNormal = forwardvec;
                    var isFacing        = Vector3.Dot(eventNormal, characterNormal).RoughlyEquals(-1.0f);
                    if (isFacing)
                    {
                        Execute(input, character);
                    }
                }
            }
            else
            {
                foreach (var collision in _collider.Collisions)
                {
                    if ((collision.ColliderA == characterCollider || collision.ColliderB == characterCollider) && !RequiresInteraction)
                    {
                        Execute(input, character);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void Execute(InputComponent input, PlayerFieldCharacter character)
        {
            base.Execute(input, character);
            if (this.NextSceneName.NullIfEmpty() == null)
            {
                return;
            }
            Core.Instance.UpdateScene(new SceneChangeArgs()

            {
                SceneName            = NextSceneName,
                SceneChangeId        = NextSceneChangeId,
                PlayerFieldCharacter = character.Serialize()
            });
        }
Ejemplo n.º 3
0
 public override void Update(InputComponent input, PlayerFieldCharacter character)
 {
     base.Update(input, character);
 }
Ejemplo n.º 4
0
 protected virtual void Execute(InputComponent input, PlayerFieldCharacter character)
 {
 }