public void OnTriggerExit(Collider other) { var portal = other.GetComponent <Portal>(); if (portal == null) { return; } PortalExit?.Invoke(portal); }
public static void OutputPortal(Player p, BlockID block, ushort x, ushort y, ushort z) { if (!p.level.Props[block].IsPortal) { return; } PortalExit exit = Portal.Get(p.level.MapName, x, y, z); if (exit == null) { return; } p.Message("Portal destination: ({0}, {1}, {2}) in {3}", exit.X, exit.Y, exit.Z, exit.Map); }
void MovePortals(Player p, int x, int y, int z) { List <Vec3U16> coords = Portal.GetAllCoords(p.level.MapName); int count = 0; foreach (Vec3U16 pos in coords) { if (!Portal.ExistsInDB(p.level.MapName)) { continue; } PortalExit exit = Portal.Get(p.level.MapName, pos.X, pos.Y, pos.Z); BlockID block = p.level.FastGetBlock(pos.X, pos.Y, pos.Z); int x2 = pos.X + x; int y2 = pos.Y + y; int z2 = pos.Z + z; int dx = exit.X + x; int dy = exit.Y + y; int dz = exit.Z + z; if (!p.level.IsValidPos(x2, y2, z2)) { p.Message("%cPortal at %b" + pos.X + " " + pos.Y + " " + pos.Z + " %cwas outside of the map bounds, deleting."); Portal.Delete(p.level.name, pos.X, pos.Y, pos.Z); p.level.UpdateBlock(p, pos.X, pos.Y, pos.Z, Block.Air); continue; } // Create new portals Portal.Set(p.level.name, (ushort)x2, (ushort)y2, (ushort)z2, (ushort)dx, (ushort)dy, (ushort)dz, exit.Map); p.level.UpdateBlock(p, (ushort)x2, (ushort)y2, (ushort)z2, block); // Delete old portals Portal.Delete(p.level.name, pos.X, pos.Y, pos.Z); p.level.UpdateBlock(p, pos.X, pos.Y, pos.Z, Block.Air); count++; } p.Message("%SSuccessfully moved %b" + count + " %Sportals."); }