/// <summary> /// Creates guild and sets up events /// </summary> /// <param name="guild"></param> public ConfigChallengeHelper(IModHelper helper, ModConfig config) { modHelper = helper; Config = config; ChallengeList = new List <SlayerChallenge>(); adventureGuild = new AdventureGuild(CustomAdventureGuild.StandardMapPath, CustomAdventureGuild.StandardMapName); customAdventureGuild = new CustomAdventureGuild(); if (ChallengeList == null || ChallengeList.Count == 0) { foreach (var info in config.Challenges) { ChallengeList.Add(new SlayerChallenge() { Info = info }); } } SaveEvents.AfterCreate += SetupMonsterKilledEvent; SaveEvents.AfterLoad += SetupMonsterKilledEvent; SaveEvents.BeforeSave += PresaveData; SaveEvents.AfterSave += InjectGuild; SaveEvents.AfterLoad += InjectGuild; SaveEvents.AfterCreate += InjectGuild; MonsterKilled += Events_MonsterKilled; }
/// <summary> /// Creates guild and sets up events /// </summary> /// <param name="guild"></param> public ConfigChallengeHelper(IModHelper helper, ModConfig config, IMonitor monitor) { Helper = helper; Monitor = monitor; Config = config; ChallengeList = new List <SlayerChallenge>(); adventureGuild = new AdventureGuild(CustomAdventureGuild.StandardMapPath, CustomAdventureGuild.StandardMapName); customAdventureGuild = new CustomAdventureGuild(); if (ChallengeList == null || ChallengeList.Count == 0) { foreach (var info in config.Challenges) { ChallengeList.Add(new SlayerChallenge() { Info = info }); } } helper.Events.GameLoop.SaveCreated += SetupMonsterKilledEvent; helper.Events.GameLoop.SaveLoaded += SetupMonsterKilledEvent; helper.Events.GameLoop.Saving += PresaveData; helper.Events.GameLoop.Saved += InjectGuild; helper.Events.GameLoop.SaveLoaded += InjectGuild; helper.Events.GameLoop.SaveCreated += InjectGuild; MonsterKilled += Events_MonsterKilled; }
private void InitLocations() { if (Game1.locations == null) { throw new InvalidOperationException("Can't access Adventure Guild before the game is initialised."); } if (_adventureGuild == null) { _adventureGuild = new AdventureGuild(CustomAdventureGuild.StandardMapPath, CustomAdventureGuild.StandardMapName); _customAdventureGuild = new CustomAdventureGuild(); } }