private void PlacementSuccesfull() { Tile t = WorldController.GetMouseOverTile(); Entity newObjectEntity = WorldController.SCENE.createEntity("Building at x: " + t.GetPosition().X + " y: " + t.GetPosition().Y); List <Tile> tilesAffected = new List <Tile>(); for (int x = 0; x < primitiveBuilding.GetSize().X; x++) { for (int y = 0; y < primitiveBuilding.GetSize().Y; y++) { Tile tile = WorldController.GetTileAt((int)lastTile.GetTileNumber().X + x, (int)lastTile.GetTileNumber().Y + y); if (tile != null) { tilesAffected.Add(tile); } } } Building building = new Building(); newObjectEntity.addComponent(building); building.SetPrimitiveBuilding(primitiveBuilding); building.AttachToTile(tilesAffected); building.SetPosition(entitySprite.position + sprite.localOffset, true); building.SetTileSize(primitiveBuilding.GetSize()); }
public void StartPlacing(PrimitiveBuilding primitiveBuilding) { if (BuildingController.IsDragging() || Zoning.ZoneController.IsDragging()) { Nez.Console.DebugConsole.instance.log("We are already building, placing or zoning."); return; } this.primitiveBuilding = primitiveBuilding; placingComponent.StartPlacing(primitiveBuilding.GetSize(), primitiveBuilding.CarryOnBuildingAfterPlacement(), false); if (entitySprite == null) { entitySprite = WorldController.SCENE.createEntity("GameplayItemPlacement sprite"); sprite = new Sprite(); entitySprite.addComponent(sprite); } entitySprite.setEnabled(true); sprite.setSubtexture((primitiveBuilding as IBuildingStandardGameplayRenderer).GetTexture()); sprite.setLocalOffset(new Vector2(sprite.width / 2, 0) - new Vector2(50, 0)); placingComponent.ShouldCarryOnAfterPlaced(primitiveBuilding.CarryOnBuildingAfterPlacement()); }