public RangeFilterer(IRangeCreator <TRange> creator, IRangeFilteringPolicy <TRange> policy, IRangeAccessor <TRange> accessor) { _creator = creator; _policy = policy; _accessor = accessor; _intersector = _policy.AreZeroLengthRangesAllowed ? (Func <TimeRange, TimeRange, bool>)RangeTouchesRange : RangeIntersectsRange; }
/// <summary>Updates the range the mod is currently showing.</summary> /// <param name="location">The location to search for objects in.</param> private void RefreshRangeItems(GameLocation location) { if (!Context.IsWorldReady || location == null) { return; } Vector2 mouseTile = new Vector2((Game1.getMouseX() + Game1.viewport.X) / Game1.tileSize, (Game1.getMouseY() + Game1.viewport.Y) / Game1.tileSize); this.displayManager.Clear(); // Objects in the world foreach (KeyValuePair <Vector2, SObject> item in location.Objects.Pairs) { IRangeCreator <SObject> creator = this.objectRangeCreators.FirstOrDefault(elem => elem.CanCreateRangeFor(item.Value)); if (creator != null) { this.displayManager.AddTilesToDisplay(creator.HandledRangeItem, creator.CreateRange(item.Value, item.Key, location), mouseTile.Equals(item.Key) && this.isModifierKeyDown); } } // Buildings in the world if (location is BuildableGameLocation buildableGameLocation) { foreach (Building building in buildableGameLocation.buildings) { IRangeCreator <Building> creator = this.buildingRangeCreators.FirstOrDefault(elem => elem.CanCreateRangeFor(building)); if (creator != null) { bool buildingContainsMouse = ModEntry.AreaContainsPoint(building.tileX.Value, building.tileY.Value, building.tilesWide.Value, building.tilesHigh.Value, (int)mouseTile.X, (int)mouseTile.Y); this.displayManager.AddTilesToDisplay(creator.HandledRangeItem, creator.CreateRange(building, new Vector2(building.tileX.Value, building.tileY.Value), location), buildingContainsMouse && this.isModifierKeyDown); } } } // Held item if (this.activeObject != null && this.config.ShowRangeOfHeldItem) { IRangeCreator <SObject> creator = this.objectRangeCreators.FirstOrDefault(elem => elem.CanCreateRangeFor(this.activeObject)); if (creator != null) { this.displayManager.AddTilesToDisplay(creator.HandledRangeItem, creator.CreateRange(this.activeObject, mouseTile, location), true); } } }
public RangeJoiner(IRangeCreator <TRange> creator, IRangeAccessor <TRange> accessor, ILogger <RangeJoiner <TRange> > logger) { _creator = creator; _accessor = accessor; _logger = logger; }