public override void Build(World world, Chunk chunk, Vector3Int pos, TerrainLayer layer) { int noise = layer.GetNoise(pos.x, pos.y, pos.z, 1f, 3, 1); int leavesRange = noise + 3; int leavesRange2 = leavesRange * leavesRange; int trunkHeight = posY - noise; float a2inv = 1.0f / leavesRange2; float b2inv = 1.0f / ((leavesRange - 1) * (leavesRange - 1)); for (int y = -leavesRange + 1; y <= leavesRange - 1; y++) { for (int z = -leavesRange; z <= leavesRange; z++) { for (int x = -leavesRange; x <= leavesRange; x++) { if (x * x * a2inv + z * z * a2inv + y * y * b2inv <= 1.0f) // An ellipsoid flattened on the y axis { blocks.Set(pos.Add(x, y + trunkHeight, z), leaves); } } } } blocks.Set(pos, log); for (int y = 1; y <= trunkHeight; y++) { blocks.Set(pos.Add(0, y, 0), log); } }
public override void GenerateStructures(Chunk chunk) { int minX = chunk.pos.x - structure.negX; int maxX = chunk.pos.x + Env.ChunkSize + structure.posX; int minZ = chunk.pos.z - structure.negZ; int maxZ = chunk.pos.z + Env.ChunkSize + structure.posZ; for (int x = minX; x < maxX; x++) { for (int z = minZ; z < maxZ; z++) { Vector3Int pos = new Vector3Int(x, 0, z); float chanceAtPos = Randomization.Random(pos.GetHashCode(), 44, true); if (chance > chanceAtPos) { if (Randomization.Random(pos.Add(1, 0, 0).GetHashCode(), 44, true) > chanceAtPos && Randomization.Random(pos.Add(-1, 0, 0).GetHashCode(), 44, true) > chanceAtPos && Randomization.Random(pos.Add(0, 0, 1).GetHashCode(), 44, true) > chanceAtPos && Randomization.Random(pos.Add(0, 0, -1).GetHashCode(), 44, true) > chanceAtPos) { int height = terrainGen.GenerateTerrainForBlockColumn(chunk, x, z, true); structure.Build(world, chunk, new Vector3Int(x, height, z), this); } } } } }
bool CreateFieldAndJob(Vector3Int center) { if (!IsClear(center.Add(-5, 0, -5), 11, 2, 11)) { return(false); } var crateZ = -4 + Random.Next(10); BlockPlacementHelper.PlaceBlock(center.Add(-5, 0, crateZ), BuiltinBlocks.Crate, Owner); BlockPlacementHelper.PlaceBlock(center.Add(-5, 1, crateZ), BuiltinBlocks.TorchYP, Owner); var min = center.Add(-4, 0, -4); var max = center.Add(5, 0, 5); for (int x = min.x; x < max.x; x++) { for (int z = min.z; z < max.z; z++) { bool solid; if (!World.TryIsSolid(new Vector3Int(x, center.y - 1, z), out solid) || !solid) { return(false); } } } AreaJobTracker.CreateNewAreaJob("pipliz.wheatfarm", Owner, min, max); return(true); }
private static bool IsHappy(Vector3Int currentPos, Vector3Int ignorePos) { int count = 0; int touchingBeds = 0; var currentN = currentPos.Add(1, 0, 0); var currentS = currentPos.Add(-1, 0, 0); var currentE = currentPos.Add(0, 0, -1); var currentW = currentPos.Add(0, 0, 1); var ignoreN = ignorePos.Add(1, 0, 0); var ignoreS = ignorePos.Add(-1, 0, 0); var ignoreE = ignorePos.Add(0, 0, -1); var ignoreW = ignorePos.Add(0, 0, 1); EvaluateSpot(ignorePos, ref count, ref touchingBeds, currentN); EvaluateSpot(ignorePos, ref count, ref touchingBeds, currentS); EvaluateSpot(ignorePos, ref count, ref touchingBeds, currentE); EvaluateSpot(ignorePos, ref count, ref touchingBeds, currentW); EvaluateSpot(currentPos, ref count, ref touchingBeds, ignoreN); EvaluateSpot(currentPos, ref count, ref touchingBeds, ignoreS); EvaluateSpot(currentPos, ref count, ref touchingBeds, ignoreE); EvaluateSpot(currentPos, ref count, ref touchingBeds, ignoreW); return(count > 0 && touchingBeds < 3); }
public override Vector3Int GetPositionNPC(Vector3Int position) { Vector3Int positionNPC; if (blockType == BuiltinBlocks.OvenUnlitXP || blockType == BuiltinBlocks.OvenLitXP) { positionNPC = position.Add(1, 0, 0); } else if (blockType == BuiltinBlocks.OvenUnlitXN || blockType == BuiltinBlocks.OvenLitXN) { positionNPC = position.Add(-1, 0, 0); } else if (blockType == BuiltinBlocks.OvenUnlitZP || blockType == BuiltinBlocks.OvenLitZP) { positionNPC = position.Add(0, 0, 1); } else if (blockType == BuiltinBlocks.OvenUnlitZN || blockType == BuiltinBlocks.OvenLitZN) { positionNPC = position.Add(0, 0, -1); } else { positionNPC = position; } return(positionNPC); }
private bool IsSpacesEmpty(Vector3Int position, int x, int z) { World.TryIsSolid(position.Add(x, 0, z), out bool result1); World.TryIsSolid(position.Add(x, 1, z), out bool result2); if (result1 || result2) { return(false); } else { return(true); } }
public static void Circle(Vector3Int center, int diameter, ushort type, Players.Player player) { int radius = diameter / 2; for (int c = 0; c < diameter; c++) { PlaceBlock(center.Add(-radius, 0, -radius + c), type, player); PlaceBlock(center.Add(radius, 0, -radius + c), type, player); } for (int c = 0; c < diameter - 2; c++) { PlaceBlock(center.Add(-radius + 1 + c, 0, -radius), type, player); PlaceBlock(center.Add(-radius + 1 + c, 0, radius), type, player); } }
public static bool IsWithinBounds(this Vector3Int pos, Vector3Int boundsPos, BoundsInt bounds) { var boundsMax = boundsPos.Add(bounds.Size.x, bounds.Size.y, bounds.Size.z); return(pos.x >= boundsPos.x && pos.y >= boundsPos.y && pos.z >= boundsPos.z && pos.x <= boundsMax.x && pos.y <= boundsMax.y && pos.z <= boundsMax.z); }
// Run on add to world (also runs when added by game - ie: when a crop grows to the next stage) public void OnAddAction(Vector3Int position, ushort newType, Players.Player causedBy) { ushort num; // check if the block below is fertile if (World.TryGetTypeAt(position.Add(0, -1, 0), out num) && ItemTypes.IsFertile(num)) { CropManager.trackCrop(position, this); } else { // Tell the user you can't do this Pipliz.Chatting.Chat.Send(causedBy, string.Format("{0} can't grow here! It's not fertile!", ItemTypes.IndexLookup.GetName(newType))); // Get the air block, and replace the new crop with it ushort airBlockID = ItemTypes.IndexLookup.GetIndex("air"); ServerManager.TryChangeBlock(position, airBlockID); // Give the user the block Stockpile s = Stockpile.GetStockPile(causedBy); // Give them an item back? s.Add(newType, 1); // Update it? s.SendUpdate(); } }
public static void OpenMenu(Players.Player player, PlayerClickedData playerClickData) { if (ItemTypes.IndexLookup.TryGetIndex(SchematicTool.NAME, out var schematicItem) && playerClickData.TypeSelected == schematicItem) { if (player.ActiveColony == null) { PandaChat.Send(player, _localizationHelper, "ErrorOpening", ChatColor.red); return; } if (!_awaitingClick.ContainsKey(player)) { SendMainMenu(player); } else { var tuple = _awaitingClick[player]; _awaitingClick.Remove(player); switch (tuple.Item1) { case SchematicClickType.Build: Vector3Int location = playerClickData.GetVoxelHit().BlockHit.Add(0, 1, 0); var args = new JSONNode(); args.SetAs("constructionType", GameLoader.NAMESPACE + ".SchematicBuilder"); args.SetAs(SchematicBuilderLoader.NAME + ".SchematicName", tuple.Item2); args.SetAs(SchematicBuilderLoader.NAME + ".Rotation", tuple.Item3); if (SchematicReader.TryGetSchematic(tuple.Item2, player.ActiveColony.ColonyID, location, out var schematic)) { if (tuple.Item3 >= Schematic.Rotation.Right) { schematic.Rotate(); } if (tuple.Item3 >= Schematic.Rotation.Back) { schematic.Rotate(); } if (tuple.Item3 >= Schematic.Rotation.Left) { schematic.Rotate(); } var maxSize = location.Add(schematic.XMax - 1, schematic.YMax - 1, schematic.ZMax - 1); AreaJobTracker.CreateNewAreaJob("pipliz.constructionarea", args, player.ActiveColony, location, maxSize); AreaJobTracker.SendData(player); } break; case SchematicClickType.Archetect: break; } } } }
public Vector3Int GetWorldPosition(string typeBasename, Vector3Int position, ushort bluetype) { ushort hxm = ItemTypes.IndexLookup.GetIndex(typeBasename + "x-"); ushort hzp = ItemTypes.IndexLookup.GetIndex(typeBasename + "z+"); ushort hzm = ItemTypes.IndexLookup.GetIndex(typeBasename + "z-"); int realx = this.offsetz + 1; int realz = -this.offsetx; if (bluetype == hxm) { realx = -this.offsetz - 1; realz = this.offsetx; } else if (bluetype == hzp) { realx = this.offsetx; realz = this.offsetz + 1; } else if (bluetype == hzm) { realx = -this.offsetx; realz = -this.offsetz - 1; } return(position.Add(realx, this.offsety, realz)); }
public bool MoveNext() { var next = cursor.Add(1, 0, 0); if (next.x > positionMax.x) { next.x = positionMin.x; next = next.Add(0, 0, 1); } if (next.z > positionMax.z) { next.z = positionMin.z; next = next.Add(0, 1, 0); } PreviousPosition = cursor; cursor = next; if (IsInBounds(cursor)) { return(true); } else { return(false); } }
public static Vector3Int GetClosestPositionWithinY(this Vector3Int goalPosition, Vector3Int currentPosition, int minMaxY) { var pos = currentPosition; if (PathingManager.TryCanStandNear(goalPosition, out var canStand, out pos) && !canStand) { var y = -1; var negY = minMaxY * -1; while (PathingManager.TryCanStandNear(goalPosition.Add(0, y, 0), out var canStandNow, out pos) && !canStandNow) { if (y > 0) { y++; if (y > minMaxY) { break; } } else { y--; if (y < negY) { y = 1; } } } } return(pos); }
// On random Update spread grass to any nearby dirt blocks on the surface public override void RandomUpdate(Chunk chunk, Vector3Int localPos) { ChunkBlocks blocks = chunk.blocks; int minX = localPos.x <= 0 ? 0 : 1; int maxX = localPos.x >= Env.ChunkMask ? 0 : 1; int minY = localPos.y <= 0 ? 0 : 1; int maxY = localPos.y >= Env.ChunkMask ? 0 : 1; int minZ = localPos.z <= 0 ? 0 : 1; int maxZ = localPos.z >= Env.ChunkMask ? 0 : 1; for (int x = -minX; x <= maxX; x++) { for (int y = -minY; y <= maxY; y++) { for (int z = -minZ; z <= maxZ; z++) { Vector3Int newPos = localPos.Add(x, y, z); if (!blocks.Get(newPos).Equals(dirt)) { continue; } // Let's turn air about dirt into grass if (blocks.Get(newPos.Add(0, 1, 0)).Equals(air)) { blocks.Modify(newPos, grass, true); } } } } }
public static bool AddDoor(Vector3Int position, ushort type, Players.Player causedBy) { string typename = ItemTypes.IndexLookup.GetName(type); ushort upperType; ushort actualType; string topname = typename.Substring(0, typename.Length - 2) + "top" + typename.Substring(typename.Length - 2); if (ItemTypes.IndexLookup.TryGetIndex(topname, out upperType)) { Vector3Int upperPos = position.Add(0, 1, 0); if (World.TryGetTypeAt(upperPos, out actualType) && actualType != BuiltinBlocks.Air) { return(false); } if (ServerManager.TryChangeBlock(upperPos, upperType)) { doorParts.Add(position, upperPos); doorParts.Add(upperPos, position); return(true); } else { return(false); } } else { doorParts.Add(position, Vector3Int.invalidPos); return(true); } }
// On random Update spread grass to any nearby dirt blocks on the surface public override void RandomUpdate(Chunk chunk, Vector3Int localPos, Vector3Int globalPos) { ChunkBlocks blocks = chunk.blocks; WorldBlocks blocksW = chunk.world.blocks; int minX = localPos.x <= 0 ? 0 : 1; int maxX = localPos.x >= Env.ChunkMask ? 0 : 1; int minY = localPos.y <= 0 ? 0 : 1; int maxY = localPos.y >= Env.ChunkMask ? 0 : 1; int minZ = localPos.z <= 0 ? 0 : 1; int maxZ = localPos.z >= Env.ChunkMask ? 0 : 1; for (int x = -minX; x <= maxX; x++) { for (int y = -minY; y <= maxY; y++) { for (int z = -minZ; z <= maxZ; z++) { Vector3Int newPos = localPos.Add(x, y, z); if (blocks.Get(newPos).Equals(dirt) && blocksW.Get(globalPos.Add(x, y + 1, z)).Equals(air)) { blocks.Modify(newPos, grass, true); } } } } }
void CreateFarmHouse() { Vector3Int houseOrigin = FarmOrigin.Add(-3, 0, -2); BlockPlacementHelper.FillPlane(houseOrigin.Add(0, -1, 0), 7, 8, BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.FillArea(houseOrigin, 1, 1, 8, BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(6, 0, 0), 1, 1, 8, BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(1, 0, 7), 5, 1, 1, BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(1, 0, 0), 2, 1, 1, BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(4, 0, 0), 2, 1, 1, BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(0, 1, 0), BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(6, 1, 0), BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(0, 1, 7), BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(6, 1, 7), BuiltinBlocks.StoneBricks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(0, 1, 1), BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(0, 1, 3), 1, 1, 2, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(0, 1, 6), BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(6, 1, 1), BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(6, 1, 3), 1, 1, 2, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(6, 1, 6), BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(1, 1, 7), BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(3, 1, 7), BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(5, 1, 7), BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(1, 1, 0), 2, 1, 1, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(1, 1, -1), BuiltinBlocks.TorchZP, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(4, 1, 0), 2, 1, 1, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.PlaceBlock(houseOrigin.Add(5, 1, -1), BuiltinBlocks.TorchZP, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(0, 2, 0), 1, 1, 8, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(6, 2, 0), 1, 1, 8, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(1, 2, 0), 5, 1, 1, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(1, 2, 7), 5, 1, 1, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(-1, 3, -1), 3, 1, 10, BuiltinBlocks.Straw, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(5, 3, -1), 3, 1, 10, BuiltinBlocks.Straw, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(2, 3, 0), 3, 1, 1, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(2, 3, 7), 3, 1, 1, BuiltinBlocks.Planks, Owner); BlockPlacementHelper.FillArea(houseOrigin.Add(0, 4, -1), 7, 1, 10, BuiltinBlocks.Straw, Owner); List <Vector3Int> possibleBedSpots = new List <Vector3Int> (); for (int c = 0; c < 6; c++) { possibleBedSpots.Add(houseOrigin.Add(1, 0, 1 + c)); possibleBedSpots.Add(houseOrigin.Add(4, 0, 1 + c)); LootSpots.Add(houseOrigin.Add(1, 0, 1 + c)); LootSpots.Add(houseOrigin.Add(5, 0, 1 + c)); } PlaceBeds(possibleBedSpots); }
public static void OnAdd(Vector3Int position, ushort type, Players.Player player) { ushort num; if (World.TryGetTypeAt(position.Add(0, -1, 0), out num) && ItemTypes.GetType(num).IsFertile) { BlockTracker.Add(new Herbs(position)); } }
private static void xyPos(PlayerState ps, Vector3Int startingPos, bool offset = false) { for (var i = Convert.ToInt32(offset); i < WAND_MAX_RANGE; i++) { if (Layout(startingPos.Add(i, 0, 0), ps, 0, 1, 0)) { break; } } for (var i = -1; i > WAND_MAX_RANGE_MIN; i--) { if (Layout(startingPos.Add(i, 0, 0), ps, 0, 1, 0)) { break; } } }
static Vector3Int GetRandomSpot(int maxRange) { var spawnLocation = new Vector3Int(TerrainGenerator.UsedGenerator.GetSpawnLocation(null)); var rx = -maxRange + 2 * Pipliz.Random.Next(maxRange); var rz = -maxRange + 2 * Pipliz.Random.Next(maxRange); var result = spawnLocation.Add(rx, 0, rz); result.y = ((int)TerrainGenerator.UsedGenerator.GetHeight(result.x, result.z)) + 1; return(result); }
public static void OnTryChangeBlockUser(ModLoader.OnTryChangeBlockData userData) { if (userData.TypeNew == ItemTypes.IndexLookup.GetIndex("Ulfric.ColonyAddOns.Blocks.AppleBasket") && userData.TypeOld == BuiltinBlocks.Air) { Logger.Log("Check if area is clear for AppleFarmer"); Vector3Int position = userData.Position; int xlen = 7; int zlen = 7; int radius = 3; //set NW corner Vector3Int nwcorner = new Vector3Int(position.x - radius, position.y, position.z - radius); Vector3Int secorner = new Vector3Int(position.x + radius, position.y, position.z + radius); bool blocked = false; for (int x = 0; x <= xlen; x++) { for (int z = 0; z <= zlen; z++) { if (World.TryGetTypeAt(nwcorner.Add(x, 0, z), out ushort val) && val != BuiltinBlocks.Air) { blocked = true; } } } if (blocked) { Chat.Send(userData.RequestedByPlayer, "Apple Farmer 9 x 9 area is blocked."); } else { AreaJobTracker.CreateNewAreaJob("Ulfric.ColonyAddOns.AreaJobs.AppleFarm", userData.RequestedByPlayer, nwcorner, secorner); ThreadManager.InvokeOnMainThread(delegate() { ServerManager.TryChangeBlock(position, userData.TypeNew); }, 0.1f); } } if (userData.TypeOld == ItemTypes.IndexLookup.GetIndex("Ulfric.ColonyAddOns.Blocks.AppleBasket") && userData.TypeNew == BuiltinBlocks.Air) { Logger.Log("Remove job"); Vector3Int position = userData.Position; int xlen = 7; int zlen = 7; int radius = 3; //set NW corner Vector3Int nwcorner = new Vector3Int(position.x - radius, position.y, position.z - radius); Vector3Int secorner = new Vector3Int(position.x + radius, position.y, position.z + radius); AreaJobTracker.RemoveJobAt(nwcorner, secorner); } }
/// <summary> /// Checks the last position in the specify direction. /// </summary> /// <returns> /// True if there is a last position and it isnt the. /// </returns> /// <param name='direction'> /// If set to <c>true</c> direction. /// </param> /// <param name='finalPosition'> /// If set to <c>true</c> final position. /// </param> /// /// /// <summary> /// Checks the last position in the specify direction. /// </summary> /// <returns> /// True if there is a last position and it isnt next to psition. /// </returns> /// <param name='position'> /// position to serch from /// </param> /// <param name='direction'> /// directin to serch /// </param> /// <param name='finalPosition'> /// out the las position. Vector3Int.zero return == false /// </param> /// public static bool CheckLastPosition(Vector3Int position ,Vector3Int direction, out Vector3Int finalPosition) { Vector3Int aux = new Vector3Int(position.ToVector3); aux = aux.Add(direction.ToVector3); aux = aux.Add(direction.ToVector3); Vector3Int c; for(int i = 0; i < 11; i++){ if(Level.Singleton.ContainsElement(aux)||aux.y==0){ if(i>0 || aux.y==0){ finalPosition = aux.Add(new Vector3(direction.x*-1,direction.y*-1,direction.z*-1)); return true; }else{ finalPosition = new Vector3Int(Vector3.zero); return false; } } aux = aux.Add(direction.ToVector3); } finalPosition = new Vector3Int(Vector3.zero); return false; }
public static Vector3Int RelativePos(Vector3Int pos, int h, int v, Direction forwards) { switch (forwards) { case Direction.up: return(pos.Add(v, 0, h)); case Direction.down: return(pos.Add(v, 0, -h)); case Direction.north: return(pos.Add(h, v, 0)); case Direction.south: return(pos.Add(-h, v, 0)); case Direction.east: return(pos.Add(0, v, -h)); case Direction.west: return(pos.Add(0, v, h)); default: return(pos); } }
public ITrackableBlock InitializeOnAdd(Vector3Int position, ushort type, Players.Player player) { if (World.TryGetTypeAt(position.Add(0, -1, 0), out typeBelow)) { JSONNode customDataNode = ItemTypes.GetType(typeBelow).CustomDataNode; if (customDataNode != null) { MiningCooldown = customDataNode.GetAsOrDefault("minerMiningTime", 8f); } } InitializeJob(player, position, 0); return(this); }
public static void FillArea(Vector3Int start, int width, int height, int depth, ushort type, Players.Player player) { for (int z = 0; z < height; z++) { for (int y = 0; y < depth; y++) { for (int x = 0; x < width; x++) { PlaceBlock(start.Add(x, 0, y), type, player); } } } }
public override Vector3Int GetPositionNPC(Vector3Int position) { if (blockType == BuiltinBlocks.OvenXP || blockType == BuiltinBlocks.OvenLitXP) { return(position.Add(1, 0, 0)); } else if (blockType == BuiltinBlocks.OvenXN || blockType == BuiltinBlocks.OvenLitXN) { return(position.Add(-1, 0, 0)); } else if (blockType == BuiltinBlocks.OvenZP || blockType == BuiltinBlocks.OvenLitZP) { return(position.Add(0, 0, 1)); } else if (blockType == BuiltinBlocks.OvenZN || blockType == BuiltinBlocks.OvenLitZN) { return(position.Add(0, 0, -1)); } else { return(position); } }
public override void BuildBlock(Chunk chunk, Vector3Int localPos, Vector3Int globalPos) { WorldBlocks blocks = chunk.world.blocks; for (int d = 0; d < 6; d++) { Direction dir = DirectionUtils.Get(d); Block adjacentBlock = blocks.GetBlock(globalPos.Add(dir)); if (CanBuildFaceWith(adjacentBlock, dir)) { BuildFace(chunk, localPos, globalPos, dir); } } }
public static Vector3Int GetBlockOffset(this Vector3Int vector, BlockSide blockSide) { var vectorValues = blockSide.GetAttribute <BlockSideVectorValuesAttribute>(); if (vectorValues != null) { return(vector.Add(vectorValues.X, vectorValues.Y, vectorValues.Z)); } else { PandaLogger.Log(ChatColor.yellow, "Unable to find BlockSideVectorValuesAttribute for {0}", blockSide.ToString()); return(vector); } }
public override Vector3Int GetPositionNPC(Vector3Int position) { if (blockType == BuiltinBlocks.FineryForgeLitXP || blockType == BuiltinBlocks.FineryForgeXP) { return(position.Add(1, 0, 0)); } else if (blockType == BuiltinBlocks.FineryForgeLitXN || blockType == BuiltinBlocks.FineryForgeXN) { return(position.Add(-1, 0, 0)); } else if (blockType == BuiltinBlocks.FineryForgeLitZP || blockType == BuiltinBlocks.FineryForgeZP) { return(position.Add(0, 0, 1)); } else if (blockType == BuiltinBlocks.FineryForgeLitZN || blockType == BuiltinBlocks.FineryForgeZN) { return(position.Add(0, 0, -1)); } else { Log.Write("Unexpect blocktype {0} for job {1} at {2}", ItemTypes.IndexLookup.GetName(blockType), NPCTypeKey, position); return(position); } }
internal static void RemoveTeleporter(int colonyID, Vector3Int pos) { if (portals.ContainsKey(colonyID)) { NewColonyAPI.Helpers.Chat.SendToAll("ID: " + colonyID + " exists!"); if (portals[colonyID].location == pos.Add(-1, 0, 0)) { portals.Remove(colonyID); } if (portals[colonyID].location == pos.Add(1, 0, 0)) { portals.Remove(colonyID); } if (portals[colonyID].location == pos.Add(0, 0, -1)) { portals.Remove(colonyID); } if (portals[colonyID].location == pos.Add(0, 0, 1)) { portals.Remove(colonyID); } } Save(); }
public override Vector3Int GetPositionNPC(Vector3Int position) { if (blockType == BuiltinBlocks.KilnXP) { return(position.Add(1, 0, 0)); } else if (blockType == BuiltinBlocks.KilnXN) { return(position.Add(-1, 0, 0)); } else if (blockType == BuiltinBlocks.KilnZP) { return(position.Add(0, 0, 1)); } else if (blockType == BuiltinBlocks.KilnZN) { return(position.Add(0, 0, -1)); } else { World.TryGetTypeAt(position, out blockType); return(position); } }