private void DestroyComponents() { this.sceneObjectForComponents?.Destroy(); this.sceneObjectForComponents = null; this.blueprintRenderer = null; this.tilesBlueprint = null; ClientLandClaimAreaManager.RemoveBlueprintRenderer(); }
public ClientWorldMapLandClaimVisualizer(WorldMapController worldMapController) { this.worldMapController = worldMapController; ClientLandClaimAreaManager.AreaAdded += this.AreaAddedHandler; ClientLandClaimAreaManager.AreaRemoved += this.AreaRemovedHandler; foreach (var area in ClientLandClaimAreaManager.EnumerateAreaObjects()) { this.AreaAddedHandler(area); } }
public static void SetupBlueprint( Tile tile, IClientBlueprint blueprint, IProtoObjectLandClaim protoObjectLandClaim) { if (!blueprint.IsEnabled) { return; } var sceneObject = blueprint.SceneObject; var world = Api.Client.World; var rendering = Api.Client.Rendering; var character = ClientCurrentCharacterHelper.Character; var startTilePosition = LandClaimSystem.SharedCalculateLandClaimObjectCenterTilePosition( tile.Position, protoObjectLandClaim); var sizeWithGraceArea = protoObjectLandClaim.LandClaimWithGraceAreaSize; var blueprintAreaBounds = LandClaimSystem.SharedCalculateLandClaimAreaBounds(startTilePosition, sizeWithGraceArea); SetupBoundsForLandClaimsInScope(sceneObject, sceneObjectPosition: tile.Position.ToVector2D(), startTilePosition, blueprintAreaBounds, protoObjectLandClaim); using var tempListExceptBounds = Api.Shared.GetTempList <RectangleInt>(); CollectLabelExclusionBoundsForBlueprint(blueprintAreaBounds, tempListExceptBounds.AsList()); ClientLandClaimAreaManager.AddBlueprintRenderer(startTilePosition, protoObjectLandClaim); // additionally highlight the restricted tiles var halfSize = sizeWithGraceArea / 2; for (var x = 1 - halfSize; x <= halfSize; x++) { for (var y = 1 - halfSize; y <= halfSize; y++) { var checkTile = world.GetTile(startTilePosition.X + x, startTilePosition.Y + y, logOutOfBounds: false); ProcessFutureLandClaimAreaTile(checkTile, x, y); } } AddBoundSquares(sceneObject, protoObjectLandClaim, positionOffset: (0, 0)); AddBoundLabels(sceneObject, sceneObjectPosition: tile.Position.ToVector2D(), exceptBounds: tempListExceptBounds.AsList(), protoObjectLandClaim, positionOffset: (0, 0)); void ProcessFutureLandClaimAreaTile(Tile checkTile, int offsetX, int offsetY) { if (!checkTile.IsValidTile) { return; } var isRestrictedTile = IsRestrictedTile(checkTile); if (!isRestrictedTile) { foreach (var neighborTile in checkTile.EightNeighborTiles) { if (IsRestrictedTile(neighborTile)) { isRestrictedTile = true; break; } } } if (!isRestrictedTile) { return; } // display red tile as player cannot construct there var tileRenderer = rendering.CreateSpriteRenderer( sceneObject, ClientLandClaimGroupRenderer.TextureResourceLandClaimAreaCell, DrawOrder.Overlay); tileRenderer.RenderingMaterial = ClientBlueprintRestrictedTileRenderingMaterial; tileRenderer.SortByWorldPosition = false; tileRenderer.Scale = 1; tileRenderer.PositionOffset = (offsetX + 1, offsetY + 1); } bool IsRestrictedTile(Tile t) => t.IsCliffOrSlope || t.ProtoTile.Kind != TileKind.Solid || t.ProtoTile.IsRestrictingConstruction || !LandClaimSystem.SharedIsPositionInsideOwnedOrFreeArea( t.Position, character, addGracePaddingWithoutBuffer: true); }