/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="location">The location to track.</param> public LocationTracker(GameLocation location) { this.Location = location; // init watchers this.BuildingsWatcher = location is BuildableGameLocation buildableLocation ? WatcherFactory.ForNetCollection(buildableLocation.buildings) : (ICollectionWatcher <Building>)WatcherFactory.ForObservableCollection(new ObservableCollection <Building>()); this.DebrisWatcher = WatcherFactory.ForNetCollection(location.debris); this.LargeTerrainFeaturesWatcher = WatcherFactory.ForNetCollection(location.largeTerrainFeatures); this.NpcsWatcher = WatcherFactory.ForNetCollection(location.characters); this.ObjectsWatcher = WatcherFactory.ForNetDictionary(location.netObjects); this.TerrainFeaturesWatcher = WatcherFactory.ForNetDictionary(location.terrainFeatures); this.Watchers.AddRange(new IWatcher[] { this.BuildingsWatcher, this.DebrisWatcher, this.LargeTerrainFeaturesWatcher, this.NpcsWatcher, this.ObjectsWatcher, this.TerrainFeaturesWatcher }); }
/// <summary>Get object changes to the player's current location if they there as of the last reset.</summary> /// <param name="watcher">The object change watcher.</param> /// <returns>Returns whether it changed.</returns> public bool TryGetLocationChanges(out IDictionaryWatcher <Vector2, SObject> watcher) { if (this.LocationWatcher.IsChanged) { watcher = null; return(false); } watcher = this.LocationObjectsWatcher; return(watcher.IsChanged); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="location">The location to track.</param> public LocationTracker(GameLocation location) { this.Location = location; // init watchers this.ObjectsWatcher = WatcherFactory.ForNetDictionary(location.netObjects); this.BuildingsWatcher = location is BuildableGameLocation buildableLocation ? WatcherFactory.ForNetCollection(buildableLocation.buildings) : (ICollectionWatcher <Building>)WatcherFactory.ForObservableCollection(new ObservableCollection <Building>()); this.Watchers.AddRange(new IWatcher[] { this.BuildingsWatcher, this.ObjectsWatcher }); }