public static bool IsStrictSupersetOf(this SCBitFlags left, SCBitFlags right) { var ul = (ushort)left & 0x1FFF; var ur = (ushort)right & 0x1FFF; return((ur & ul) == ur && ul != ur); }
private void CheckUseLuteRodSanity(int x, int y, SCBitFlags check, ObjectId plate) { if ((CFlags & SCMapCheckFlags.NoUseTiles) > 0) { return; } if (tileSet.Tiles[map[y - 1, x]].SpBitFlags == check) { return; } if (tileSet.Tiles[map[y + 1, x]].SpBitFlags == check) { return; } if (tileSet.Tiles[map[y, x - 1]].SpBitFlags == check) { return; } if (tileSet.Tiles[map[y, x + 1]].SpBitFlags == check) { return; } throw new NopeException(MapId, "There is no " + check.ToString() + " tile next to " + plate.ToString()); }
public static bool IsSubsetOf(this SCBitFlags left, SCBitFlags right) { var ul = (ushort)left & 0x1FFF; var ur = (ushort)right & 0x1FFF; return((ur & ul) == ul); }
public SCTile(SCBitFlags bitflags) { Tile = bitflags; for (int i = 1; i < ExtFlagCount; i++) { ExtFlags[i] = (ushort)SCBitFlags.None; } }
public void AddExtFlag(SCBitFlags req) { for (int i = 1; i < ExtFlagCount; i++) { if (ExtFlags[i] == (ushort)SCBitFlags.None) { ExtFlags[i] = (ushort)req; return; } } }
private void CheckTile(SCCoords coords, SCBitFlags requirements) { var tile = Tiles[coords.X, coords.Y]; requirements |= tile.Tile; if (!tile.Tile.IsBlocked() && Tiles[coords.X, coords.Y].MergeFlag(requirements) && !tile.Tile.IsImpassable()) { todoset.Enqueue(new SCTileQueueEntry { BitFlags = requirements, Coords = coords }); } }
public bool IsSupersetOf(SCBitFlags req) { for (int i = 1; i < ExtFlagCount; i++) { var flags = (SCBitFlags)ExtFlags[i]; if (flags == SCBitFlags.None) { return(false); } if (flags.IsSupersetOf(req)) { return(true); } } return(false); }
public bool IsOrthogonalTo(SCBitFlags req) { for (int i = 1; i < ExtFlagCount; i++) { var flags = (SCBitFlags)ExtFlags[i]; if (flags == SCBitFlags.None) { return(true); } if (!flags.IsOrthogonalTo(req)) { return(false); } } return(true); }
private void CheckTile(SCCoords coords, short area, SCBitFlags tile) { if (Tiles[coords.X, coords.Y].Area >= 0) { return; } if (Tiles[coords.X, coords.Y].Tile == tile) { Tiles[coords.X, coords.Y].Area = area; immediatequeue.Enqueue(new SCOwTileQueueEntry { Coords = coords, Area = area, Tile = tile }); } else { deferredqueue.Enqueue(new SCOwTileQueueEntry { Coords = coords, Area = area }); } }
public bool MergeFlag(SCBitFlags req) { bool result = false; bool orthogonal = true; int i = 0; for (; i < ExtFlagCount; i++) { if (ExtFlags[i] == (ushort)SCBitFlags.None) { break; } if (((SCBitFlags)ExtFlags[i]).IsStrictSupersetOf(req)) { ExtFlags[i] = (ushort)req; result = true; } else if (!((SCBitFlags)ExtFlags[i]).IsOrthogonalTo(req)) { orthogonal = false; } } if (orthogonal && i >= ExtFlagCount) { i = CompactFlags(); } if (orthogonal && i < ExtFlagCount) { ExtFlags[i] = (ushort)req; result = true; } return(result); }
public SCOwTile(SCBitFlags tile) { Tile = tile; Area = -1; }
public SCOwArea(short index, SCBitFlags tile) { Index = index; Tile = tile; Links = new HashSet <short>(); }
public static bool IsImpassable(this SCBitFlags left) { return((left & SCBitFlags.Impassable) > 0); }
public static bool IsBlocked(this SCBitFlags left) { return((left & SCBitFlags.Blocked) > 0); }
public static bool IsDone(this SCBitFlags left) { return((left & SCBitFlags.Done) > 0); }
public static bool IsEqual(this SCBitFlags left, SCBitFlags right) { return(((ushort)left & 0x1FFF) == ((ushort)right & 0x1FFF)); }
public static bool IsOrthogonalTo(this SCBitFlags left, SCBitFlags right) { return(!left.IsSupersetOf(right) && !right.IsSupersetOf(left)); }