Example #1
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="player">The player to track.</param>
        public PlayerTracker(Farmer player)
        {
            // init player data
            this.Player            = player;
            this.PreviousInventory = this.GetInventory();

            // init trackers
            this.LocationWatcher  = WatcherFactory.ForReference(this.GetCurrentLocation);
            this.MineLevelWatcher = WatcherFactory.ForEquatable(() => this.LastValidLocation is MineShaft mine ? mine.mineLevel : 0);
            this.SkillWatchers    = new Dictionary <EventArgsLevelUp.LevelType, IValueWatcher <int> >
            {
                [EventArgsLevelUp.LevelType.Combat]   = WatcherFactory.ForNetValue(player.combatLevel),
                [EventArgsLevelUp.LevelType.Farming]  = WatcherFactory.ForNetValue(player.farmingLevel),
                [EventArgsLevelUp.LevelType.Fishing]  = WatcherFactory.ForNetValue(player.fishingLevel),
                [EventArgsLevelUp.LevelType.Foraging] = WatcherFactory.ForNetValue(player.foragingLevel),
                [EventArgsLevelUp.LevelType.Luck]     = WatcherFactory.ForNetValue(player.luckLevel),
                [EventArgsLevelUp.LevelType.Mining]   = WatcherFactory.ForNetValue(player.miningLevel)
            };

            // track watchers for convenience
            this.Watchers.AddRange(new IWatcher[]
            {
                this.LocationWatcher,
                this.MineLevelWatcher
            });
            this.Watchers.AddRange(this.SkillWatchers.Values);
        }
Example #2
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="player">The player to track.</param>
        public PlayerTracker(Farmer player)
        {
            // init player data
            this.Player            = player;
            this.PreviousInventory = this.GetInventory();

            // init trackers
            this.LocationWatcher = WatcherFactory.ForReference(this.GetCurrentLocation);
            this.SkillWatchers   = new Dictionary <SkillType, IValueWatcher <int> >
            {
                [SkillType.Combat]   = WatcherFactory.ForNetValue(player.combatLevel),
                [SkillType.Farming]  = WatcherFactory.ForNetValue(player.farmingLevel),
                [SkillType.Fishing]  = WatcherFactory.ForNetValue(player.fishingLevel),
                [SkillType.Foraging] = WatcherFactory.ForNetValue(player.foragingLevel),
                [SkillType.Luck]     = WatcherFactory.ForNetValue(player.luckLevel),
                [SkillType.Mining]   = WatcherFactory.ForNetValue(player.miningLevel)
            };

            // track watchers for convenience
            this.Watchers.Add(this.LocationWatcher);
            this.Watchers.AddRange(this.SkillWatchers.Values);
        }