Esempio n. 1
0
        public override void Spawn()
        {
            base.Spawn();

            SetupPhysicsFromModel(PhysicsMotionType.Keyframed);

            if (SpawnFlags.Has(Flags.NonSolid))
            {
                EnableSolidCollisions = false;
            }

            Locked = SpawnFlags.Has(Flags.StartsLocked);

            TxOff = Transform;

            var dir       = MoveAngle.Direction;
            var boundSize = OOBBox.Size;
            var delta     = dir * (MathF.Abs(boundSize.Dot(dir)) - Lip);

            if (Speed <= 0)
            {
                Speed = 0.01f;
            }
            SecondsToTake = delta.Length / Speed;

            TxOn = TxOff.Add(delta, false);
        }
Esempio n. 2
0
        public override void Spawn()
        {
            base.Spawn();

            RotationA = Rot.Angles();

            var degrees = RotationDegrees - Lip;

            if (SpawnFlags.Has(Flags.RotateBackwards))
            {
                degrees *= -1.0f;
            }

            if (SpawnFlags.Has(Flags.Pitch))
            {
                RotationB = RotationA + new Angles(degrees, 0, 0);
            }
            else if (SpawnFlags.Has(Flags.Roll))
            {
                RotationB = RotationA + new Angles(0, 0, degrees);
            }
            else
            {
                RotationB = RotationA + new Angles(0, degrees, 0);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// A player has pressed this
        /// </summary>
        public virtual bool OnUse(Entity user)
        {
            if (SpawnFlags.Has(Flags.Use))
            {
                Toggle();
            }

            return(false);
        }
Esempio n. 4
0
        public bool OnUse(Entity user)
        {
            if (SpawnFlags.Has(Flags.Use))
            {
                Toggle(user);
            }

            Log.Info("Door Used");
            return(false);
        }
Esempio n. 5
0
        public override void TakeDamage(DamageInfo info)
        {
            base.TakeDamage(info);

            FireOutput("OnDamaged", info.Attacker, this);

            if (SpawnFlags.Has(Flags.DamageActivates))
            {
                DoPress(info.Attacker);
            }
        }
Esempio n. 6
0
        internal void DoPress(Entity activator)
        {
            if (Locked)
            {
                return;
            }

            State = !State;
            FireOutput("OnPressed", activator, this);

            if (!SpawnFlags.Has(Flags.NoMoving))
            {
                _ = MoveToPosition(State, activator);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// A player has pressed this
        /// </summary>
        public virtual bool OnUse(Entity user)
        {
            if (Locked)
            {
                FireOutput("OnUseLocked", user, this);
                return(false);
            }

            if (SpawnFlags.Has(Flags.UseActivates))
            {
                DoPress(user);
            }

            return(false);
        }
Esempio n. 8
0
        public override void Spawn()
        {
            base.Spawn();

            SetupPhysicsFromModel(PhysicsMotionType.Keyframed);

            if (SpawnFlags.Has(Flags.NonSolid))
            {
                EnableSolidCollisions = false;
            }

            Locked = SpawnFlags.Has(Flags.StartsLocked);

            TxOff = Transform;

            if (SpawnFlags.Has(Flags.Reverse))
            {
                Degrees *= -1;
            }

            var angle = new Angles(0, 1, 0);

            if (SpawnFlags.Has(Flags.Roll))
            {
                angle = new Angles(0, 0, 1);
            }
            else if (SpawnFlags.Has(Flags.Pitch))
            {
                angle = new Angles(1, 0, 0);
            }

            var delta = Rotation.From(angle * Degrees);

            if (Speed <= 0)
            {
                Speed = 0.01f;
            }
            SecondsToTake = Degrees / Speed;

            TxOn     = TxOff;
            TxOn.Rot = delta * TxOn.Rot;
        }
Esempio n. 9
0
 public virtual bool IsUsable(Entity user) => SpawnFlags.Has(Flags.Use) && !SpawnFlags.Has(Flags.IgnoreUse);
Esempio n. 10
0
        public override void Spawn()
        {
            base.Spawn();

            SetupPhysicsFromModel(PhysicsMotionType.Keyframed);

            // Setup run-thru trigger
            trigger          = new();
            trigger.Position = Position;
            trigger.Rotation = Rotation;
            trigger.Owner    = this;
            trigger.SetupPhysics();

            PositionA = Position;
            // Get the direction we want to move
            var dir = Rotation.From(MoveDir).Forward;

            if (MoveDirIsLocal)
            {
                dir = Transform.NormalToWorld(dir);
            }

            // Open position is the size of the bbox in the direction minus the lip size
            var boundSize = OOBBox.Size;

            PositionB = Position + dir * (MathF.Abs(boundSize.Dot(dir)) - Lip);

            State = DoorState.Closed;
            SpawnFlags.Add(Flags.Use);

            if (SpawnOpen)
            {
                Position = PositionB;
                State    = DoorState.Open;
            }

            RotationClosed = Rotation.Angles();

            var degrees = RotationDegrees - Lip;

            if (SpawnFlags.Has(Flags.RotateBackwards))
            {
                degrees *= -1.0f;
            }

            // Setup back rotation
            if (SpawnFlags.Has(Flags.Pitch))
            {
                RotationBack = RotationClosed + new Angles(degrees, 0, 0);
            }
            else if (SpawnFlags.Has(Flags.Roll))
            {
                RotationBack = RotationClosed + new Angles(0, 0, degrees);
            }
            else
            {
                RotationBack = RotationClosed + new Angles(0, degrees, 0);
            }

            // Setup front rotation
            if (SpawnFlags.Has(Flags.Pitch))
            {
                RotationFront = RotationClosed - new Angles(degrees, 0, 0);
            }
            else if (SpawnFlags.Has(Flags.Roll))
            {
                RotationFront = RotationClosed - new Angles(0, 0, degrees);
            }
            else
            {
                RotationFront = RotationClosed - new Angles(0, degrees, 0);
            }
        }
Esempio n. 11
0
 public virtual bool IsUsable(Entity user) => !Moving && SpawnFlags.Has(Flags.UseActivates);