internal static bool Wall(Entity entity, int width, int height, out long tileCount, string tile = "staxel.tile.dirt.dirt") { var parseWidth = width <= 0 ? 0 : width; var parseHeight = height <= 0 ? 0 : height; tileCount = 0; if (!TileShortCodes.IsValidTile(tile)) { return(false); } var newTile = TileShortCodes.GetTile(tile); var facing = entity.PlayerEntityLogic.Heading().GetDirection(); Vector3I center; Vector3I start; Vector3I end; var position = entity.Physics.BottomPosition().From3Dto3I(); if (facing == Compass.NORTH || facing == Compass.SOUTH) { center = facing == Compass.NORTH ? new Vector3I(position.X, position.Y, position.Z - 1) : new Vector3I(position.X, position.Y, position.Z + 1); } else { center = facing == Compass.EAST ? new Vector3I(position.X + 1, position.Y, position.Z) : new Vector3I(position.X - 1, position.Y, position.Z); } var div = (float)parseWidth / 2; var side1 = (int)Math.Floor(div); var side2 = (int)Math.Floor(div); if (facing == Compass.NORTH || facing == Compass.SOUTH) { start = new Vector3I(center.X - side1, center.Y, center.Z); end = new Vector3I(center.X + side2, center.Y + parseHeight, center.Z); } else { start = new Vector3I(center.X, center.Y, center.Z - side1); end = new Vector3I(center.X, center.Y + parseHeight, center.Z + side2); } var vc = new VectorCubeI(start, end); SaveUndo(entity, vc.Start, vc.End, true, tile); var count = 0; var list = new List <RenderItem>(); tileCount = count; return(true); }
internal static bool Platform(Entity entity, int size, out long tileCount, string tile = "staxel.tile.dirt.dirt") { var parseSize = size <= 0 ? 0 : size; tileCount = 0; if (!TileShortCodes.IsValidTile(tile)) { return(false); } var newTile = TileShortCodes.GetTile(tile); var current = entity.Physics.BottomPosition().From3Dto3I(); var start = new Vector3I(current.X - parseSize, current.Y - 1, current.Z - parseSize); var end = new Vector3I(current.X + parseSize, current.Y - 1, current.Z + parseSize); var count = 0; var vc = new VectorCubeI(start, end); SaveUndo(entity, vc.Start, vc.End, true, tile); Helpers.VectorLoop(start, end, (x, y, z) => { Tile currentTile; if (FoxCore.WorldManager.World.ReadTile(new Vector3I(x, y, z), TileAccessFlags.SynchronousWait, out currentTile)) { if (string.Equals(currentTile.Configuration.Code, "staxel.tile.Sky", StringComparison.CurrentCultureIgnoreCase)) { if (FoxCore.WorldManager.World.PlaceTile(new Vector3I(x, y, z), newTile, TileAccessFlags.SynchronousWait)) { count++; } } } }); tileCount = count; return(true); }
internal void Remove(Guid key) { if (Regions.ContainsKey(key)) { while (CloneRegions()[key].Info.Any()) { foreach (var region in new List <FrameRegion.FrameRegionInfo>(CloneRegions()[key].Info)) { if (WorldEditManager.FoxCore.WorldManager.World.PlaceTile(region.Location, TileShortCodes.GetTile("staxel.tile.Sky"), TileAccessFlags.None)) { Regions[key].Info.Remove(region); } } } Regions.Remove(key); } }
static Tiles() { Default = new FrameTiles( TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.default.line.XZ"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.default.line.Y"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.default.l.Side"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.default.l.Up"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.default.l.Down"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.default.corner.Up"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.default.corner.down") ); Custom = new FrameTiles( TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.custom.line.XZ"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.custom.line.Y"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.custom.l.Side"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.custom.l.Up"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.custom.l.Down"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.custom.corner.Up"), TileShortCodes.GetTile("mods.NimbusFox.WorldEdit.Maxigregrze.frame.custom.corner.down") ); }