private void EnterInteractionArea(AreaBase area) { if (area.GetData("thMod_AddsFlag", out TreasureFlags flag)) { _interactionFlag = flag; } }
private void DestroyClueImmersive(TreasureFlags flag) { int index = FlagToIndex(flag); _props[index]?.MarkAsNoLongerNeeded(); DestroyAreas(index); DestroyBlips(index); }
private static void MakeDefaultSave() { Random random = new Random(); NoteIndex = random.Next(0, LocationManager.MaxLocations); ChestIndex = random.Next(0, LocationManager.MaxLocations); Flags = TreasureFlags.None; Save(); }
private int FlagToIndex(TreasureFlags flag) { switch (flag) { case TreasureFlags.FoundCorpse: return(0); case TreasureFlags.FoundShovel: return(1); case TreasureFlags.FoundEmptyChest: return(2); default: return(-1); } }
public static TreasureStage Load() { if (!Directory.Exists(SaveDirectory) || !File.Exists(SaveFile)) { MakeDefaultSave(); } XmlDocument doc = new XmlDocument(); doc.Load(SaveFile); int saveVersion = Convert.ToInt32(doc.SelectSingleNode("/TreasureHuntSave/@version")?.Value); if (SaveVersion != saveVersion) { throw new NotImplementedException("Save version handling is not implemented."); } // Load location data XmlNode locations = doc.SelectSingleNode("//LocationData"); if (locations != null) { NoteIndex = Convert.ToInt32(locations.Attributes["noteIndex"]?.Value); ChestIndex = Convert.ToInt32(locations.Attributes["chestIndex"]?.Value); } else { throw new Exception("LocationData not found in save file."); } // Load flags XmlNode flags = doc.SelectSingleNode("//Flags"); if (Enum.TryParse(flags?.InnerText, out TreasureFlags newFlags)) { Flags = newFlags; } else { throw new Exception("Failed to load Flags from save file."); } // Find current stage if (HasFlag(TreasureFlags.FoundNote)) { if (HasFlag(TreasureFlags.FoundFinalChest)) { return(TreasureStage.Found); } else if (HasFlag(TreasureFlags.FoundCorpse) && HasFlag(TreasureFlags.FoundShovel) && HasFlag(TreasureFlags.FoundEmptyChest)) { return(TreasureStage.SearchingChest); } else { return(TreasureStage.SearchingClues); } } else { return(TreasureStage.SearchingNote); } }
public static void RemoveFlag(TreasureFlags flag) { Flags &= ~flag; }
public static bool HasFlag(TreasureFlags flag) { return((Flags & flag) == flag); }
public static void AddFlag(TreasureFlags flag) { Flags |= flag; }
private void LeaveInteractionArea(AreaBase area) { CameraManager.Disable(); _interactionFlag = TreasureFlags.None; }
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); }