public override bool Update()
        {
            if (_interactArea != null && _interactArea.IsPlayerInside)
            {
                if (Game.Player.Character.IsInVehicle())
                {
                    Util.DisplayHelpTextThisFrame("TREA1_HINTB");
                    return(false);
                }

                Util.DisplayHelpTextThisFrame(CameraManager.IsActive ? "TREA1_EXIT" : "TREA1_HINT");

                if (Game.IsControlJustPressed(0, Control.Context))
                {
                    if (CameraManager.IsActive)
                    {
                        CameraManager.Disable();

                        SaveManager.AddFlag(TreasureFlags.FoundNote);
                        SaveManager.Save();

                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "clue_complete_shard", "dlc_xm_fm_th_sounds", false);
                        return(true);
                    }
                    else
                    {
                        _cam = World.CreateCamera(_camPos, _camRot, _camFov);
                        _cam.Shake(CameraShake.Hand, 0.19f);

                        CameraManager.SetCurrent(_cam);
                        StopSound();

                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "item_found", "dlc_xm_fm_th_sounds", false);
                    }
                }

                if (CameraManager.IsActive)
                {
                    Game.DisableAllControlsThisFrame(0);
                    Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME);
                }
            }

            return(false);
        }
        private void EnterRevealArea(AreaBase area)
        {
            if (_blip == null)
            {
                _blip = CreateBlip(_revealArea.Center);

                Function.Call(Hash.SET_BLIP_FLASHES, _blip.Handle, true);
                Function.Call(Hash.SET_BLIP_FLASH_TIMER, _blip.Handle, BlipFlashTime);
                Function.Call(Hash.FLASH_MINIMAP_DISPLAY);

                SaveManager.AddFlag(TreasureFlags.RevealedNote);
                SaveManager.Save();
            }

            if (_soundId == -1)
            {
                _soundId = Util.PlaySoundFromCoord(_revealArea.Center, "dlc_xm_fm_th_sounds", "item_close_loop");
            }
        }
        public override bool Update()
        {
            if (_helpTextHideAt > 0 && _interactionFlag == TreasureFlags.None && Game.GameTime < _helpTextHideAt)
            {
                Util.DisplayHelpTextThisFrame(_helpTextIsClue ? "TREA1_HELP" : "TREA2_HELP");
            }

            if (_interactionFlag != TreasureFlags.None)
            {
                // Disable other helptext, no longer needed
                if (_helpTextHideAt > 0)
                {
                    _helpTextHideAt = 0;
                    _helpTextIsClue = false;
                }

                if (Game.Player.Character.IsInVehicle())
                {
                    Util.DisplayHelpTextThisFrame("TREA1_HINTB");
                    return(false);
                }

                Util.DisplayHelpTextThisFrame(CameraManager.IsActive ? "TREA1_EXIT" : "TREA1_HINT");

                if (Game.IsControlJustPressed(0, Control.Context))
                {
                    if (CameraManager.IsActive)
                    {
                        CameraManager.Disable();
                        DestroyClueImmersive(_interactionFlag);

                        SaveManager.AddFlag(_interactionFlag);
                        SaveManager.Save();

                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "clue_complete_shard", "dlc_xm_fm_th_sounds", false);

                        int numFound = GetNumCluesFound();
                        Function.Call(Hash._SET_NOTIFICATION_TEXT_ENTRY, "TREASURE_COLLECT");
                        Function.Call(Hash.ADD_TEXT_COMPONENT_INTEGER, numFound);
                        Function.Call(Hash._DRAW_NOTIFICATION, false, true);

                        if (numFound == MaxClues)
                        {
                            return(true);
                        }

                        _interactionFlag = TreasureFlags.None;
                    }
                    else
                    {
                        CameraData cameraData = CameraManager.GetClueCamera(FlagToIndex(_interactionFlag));

                        _cam = World.CreateCamera(cameraData.Position, cameraData.Rotation, cameraData.FOV);
                        _cam.Shake(CameraShake.Hand, 0.19f);

                        CameraManager.SetCurrent(_cam);
                        StopSound();

                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "item_found", "dlc_xm_fm_th_sounds", false);
                    }
                }

                if (CameraManager.IsActive)
                {
                    Game.DisableAllControlsThisFrame(0);
                    Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME);
                }
            }

            return(false);
        }
        public override bool Update()
        {
            if (_helpTextHideAt > 0 && Game.GameTime < _helpTextHideAt)
            {
                Util.DisplayHelpTextThisFrame("TREASURE_COLLEZ");
            }

            if (_interactArea != null && _interactArea.IsPlayerInside)
            {
                // Helptext is no longer needed
                if (_helpTextHideAt > 0)
                {
                    _helpTextHideAt = 0;
                }

                if (!Function.Call <bool>(Hash.IS_SYNCHRONIZED_SCENE_RUNNING, _sceneId))
                {
                    if (Game.Player.Character.IsInVehicle())
                    {
                        Util.DisplayHelpTextThisFrame("TREA2_HINTB");
                        return(false);
                    }

                    Util.DisplayHelpTextThisFrame("TREA2_HINT");

                    if (Game.IsControlJustPressed(0, Control.Context))
                    {
                        Vector3 scenePos = _chest.Position + new Vector3(0.0f, 0.0f, 0.0077f);
                        Vector3 sceneRot = Function.Call <Vector3>(
                            Hash.GET_ANIM_INITIAL_OFFSET_ROTATION,
                            AnimDict, "Double_Action_PickUP",
                            _chest.Position.X, _chest.Position.Y, _chest.Position.Z,
                            _chest.Rotation.X, _chest.Rotation.Y, _chest.Rotation.Z,
                            0f, 2
                            );

                        _cam = Function.Call <Camera>(Hash.CREATE_CAM, "DEFAULT_ANIMATED_CAMERA", true);
                        CameraManager.SetCurrent(_cam);

                        _sceneId = Function.Call <int>(Hash.CREATE_SYNCHRONIZED_SCENE, scenePos.X, scenePos.Y, scenePos.Z, sceneRot.X, sceneRot.Y, sceneRot.Z, 2);

                        Function.Call(
                            Hash.TASK_SYNCHRONIZED_SCENE,
                            Game.Player.Character.Handle, _sceneId,
                            AnimDict, "Double_Action_PickUP",
                            1.5f, -1.5f, 262, 0
                            );

                        Function.Call(
                            Hash.PLAY_SYNCHRONIZED_ENTITY_ANIM,
                            _chest.Handle, _sceneId,
                            "Double_Action_PickUP_CHEST", AnimDict,
                            1.5f, -1.5f, 4
                            );

                        Function.Call(
                            Hash.PLAY_SYNCHRONIZED_CAM_ANIM,
                            _cam.Handle, _sceneId,
                            "Double_Action_PickUp_CAM", AnimDict
                            );

                        _receivedWeapon = false;

                        Game.Player.Character.Weapons.Select(WeaponHash.Unarmed);
                        StopSound();

                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "item_found", "dlc_xm_fm_th_sounds", false);
                    }
                }
                else
                {
                    Game.DisableAllControlsThisFrame(0);
                    Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME);

                    // Scene phase stuff
                    float phase = Function.Call <float>(Hash.GET_SYNCHRONIZED_SCENE_PHASE, _sceneId);

                    // A hack to make the weapon appear in the treasure chest, couldn't get it to work as a prop
                    if (!_receivedWeapon && phase >= 0.3f)
                    {
                        _receivedWeapon = true;
                        Game.Player.Character.Weapons.Give(WeaponHash.DoubleActionRevolver, 9999, true, true);
                    }

                    if (_receivedWeapon && phase >= 1.0f)
                    {
                        Game.Player.Character.Task.ClearAll();

                        GameplayCamera.RelativeHeading = 0.0f;
                        GameplayCamera.RelativePitch   = 0.0f;
                        CameraManager.Disable();

                        SaveManager.AddFlag(TreasureFlags.FoundFinalChest);
                        SaveManager.Save();

                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "clue_complete_shard", "dlc_xm_fm_th_sounds", false);

                        Function.Call(Hash._SET_NOTIFICATION_TEXT_ENTRY, "DAR_UNLOCK");
                        Function.Call(Hash._0xC8F3AAF93D0600BF, "WEAPON_UNLOCK", 2, "DAR_UNLOCK", 1);
                        return(true);
                    }
                }
            }

            return(false);
        }