Exemple #1
0
        public override void _Process(float delta)
        {
            base._Process(delta);

            DebugFloor.GlobalTransform = new Transform(new Basis(Vector3.Right, Mathf.Pi / 2f).Orthonormalized(), new Vector3((TileX + 0.5f) * Assets.WallWidth, 0f, (TileZ + 0.5f) * Assets.WallWidth));

            if (!Main.Room.Paused)
            {
                if (Main.ActionRoom.Level.GetActorAt(TileX, TileZ) == this)
                {
                    Main.ActionRoom.Level.SetActorAt(TileX, TileZ);
                }

                Seconds += delta;
                if (Seconds > State.Seconds)
                {
                    State = State.Next;
                }

                if (NewState)
                {
                    NewState = false;
                    if (!Settings.DigiSoundMuted &&
                        State?.XML?.Attribute("DigiSound")?.Value is string digiSound &&
                        Assets.DigiSoundSafe(digiSound) is AudioStreamSample audioStreamSample)
                    {
                        Play = audioStreamSample;
                    }
                    State?.Act?.Invoke(this, delta);                     // Act methods are called once per state
                }

                State?.Think?.Invoke(this, delta);                 // Think methods are called once per frame -- NOT per tic!
                if (Visible && State != null &&
                    State.Shape is short shape &&
                    (ushort)(shape + (State.Rotate ?
                                      Direction8.Modulus(
                                          Direction8.AngleToPoint(
                                              GlobalTransform.origin,
                                              GetViewport().GetCamera().GlobalTransform.origin
                                              ).MirrorZ + (Direction ?? 0),
                                          8)
                                        : 0)) is ushort newFrame &&
                    newFrame != Page)
                {
                    Page = newFrame;
                }

                // START DEBUGGING

                /*
                 * if (!State.Alive && SightPlayer())
                 * {
                 *      if (!Settings.DigiSoundMuted
                 * && ActorXML?.Attribute("DigiSound")?.Value is string digiSound
                 * && Assets.DigiSoundSafe(digiSound) is AudioStreamSample audioStreamSample)
                 *              Play = audioStreamSample;
                 *      if (Assets.States.TryGetValue(ActorXML?.Attribute("Chase")?.Value, out State chase))
                 *              State = chase;
                 * }
                 */
                // END DEBUGGING

                if (State.Mark)
                {
                    Main.ActionRoom.Level.SetActorAt(TileX, TileZ, this);
                }
            }
        }