public static RailDirectionFlags ToRailDirectionFlags(IEnumerable <RailDirection> directions) { RailDirectionFlags rail = RailDirectionFlags.None; foreach (RailDirection dir in directions) { rail |= ToRailDirectionFlags(dir); } return(rail); }
public static IEnumerable <RailDirection> ToRailDirections(RailDirectionFlags rail) { foreach (RailDirection d in AllRailDirections) { if ((rail & ToRailDirectionFlags(d)) != 0) { yield return(d); } } }
private void Initialize(int count) { mIsFluid = new bool[count]; mIsWater = new bool[count]; mIsTransparent = new bool[count]; mIsValid = new bool[count]; mIsTransparentForLight = new bool[count]; mIsTransparentFully = new bool[count]; mIsEmptyForPhysics = new bool[count]; mTextureId = new int[count, 6]; mTextureIdForInventory = new int[count]; mIsBuildable = new bool[count]; mWhenPlayerPlacesGetsConvertedTo = new int[count]; mIsFlower = new bool[count]; mRail = new RailDirectionFlags[count]; mName = new string[count]; mWalkSpeed = new float[count]; for (int i = 0; i < count; i++) { mWalkSpeed[i] = 1; } mIsSlipperyWalk = new bool[count]; mWalkSound = new string[count][]; for (int i = 0; i < count; i++) { mWalkSound[i] = new string[0]; } mBreakSound = new string[count][]; for (int i = 0; i < count; i++) { mBreakSound[i] = new string[0]; } mBuildSound = new string[count][]; for (int i = 0; i < count; i++) { mBuildSound[i] = new string[0]; } mCloneSound = new string[count][]; for (int i = 0; i < count; i++) { mCloneSound[i] = new string[0]; } mLightRadius = new int[count]; mStartInventoryAmount = new int[count]; mStrength = new float[count]; mDefaultMaterialSlots = new int[10]; mLightLevels = new float[16]; mIsValid[0] = true; mIsEmptyForPhysics[0] = true; }
public RailSlope GetRailSlope(int x, int y, int z) { int tiletype = d_MapStorage.GetBlock(x, y, z); RailDirectionFlags rail = d_Data.Rail[tiletype]; int blocknear; if (x < d_MapStorage.MapSizeX - 1) { blocknear = d_MapStorage.GetBlock(x + 1, y, z); if (rail == RailDirectionFlags.Horizontal && blocknear != 0 && d_Data.Rail[blocknear] == RailDirectionFlags.None) { return(RailSlope.TwoRightRaised); } } if (x > 0) { blocknear = d_MapStorage.GetBlock(x - 1, y, z); if (rail == RailDirectionFlags.Horizontal && blocknear != 0 && d_Data.Rail[blocknear] == RailDirectionFlags.None) { return(RailSlope.TwoLeftRaised); } } if (y > 0) { blocknear = d_MapStorage.GetBlock(x, y - 1, z); if (rail == RailDirectionFlags.Vertical && blocknear != 0 && d_Data.Rail[blocknear] == RailDirectionFlags.None) { return(RailSlope.TwoUpRaised); } } if (y < d_MapStorage.MapSizeY - 1) { blocknear = d_MapStorage.GetBlock(x, y + 1, z); if (rail == RailDirectionFlags.Vertical && blocknear != 0 && d_Data.Rail[blocknear] == RailDirectionFlags.None) { return(RailSlope.TwoDownRaised); } } return(RailSlope.Flat); }
public VehicleDirection12Flags PossibleRails(TileEnterData enter) { Vector3 new_position = enter.BlockPosition; VehicleDirection12Flags possible_rails = VehicleDirection12Flags.None; if (MapUtil.IsValidPos(d_Map, (int)enter.BlockPosition.X, (int)enter.BlockPosition.Y, (int)enter.BlockPosition.Z)) { RailDirectionFlags newpositionrail = d_Data.Rail[ d_Map.GetBlock((int)enter.BlockPosition.X, (int)enter.BlockPosition.Y, (int)enter.BlockPosition.Z)]; List <VehicleDirection12> all_possible_rails = new List <VehicleDirection12>(); foreach (var z in DirectionUtils.PossibleNewRails(enter.EnterDirection)) { if ((newpositionrail & DirectionUtils.ToRailDirectionFlags(DirectionUtils.ToRailDirection(z))) != RailDirectionFlags.None) { all_possible_rails.Add(z); } } possible_rails = DirectionUtils.ToVehicleDirection12Flags(all_possible_rails); } return(possible_rails); }
public static IEnumerable<RailDirection> ToRailDirections(RailDirectionFlags rail) { foreach (RailDirection d in AllRailDirections) { if ((rail & ToRailDirectionFlags(d)) != 0) { yield return d; } } }
public static RailConfiguration GetRailConfiguration(RailDirectionFlags rail_direction) { if (rail_direction == RailDirectionFlags.None) { return RailConfiguration.NoRail; } int rail_count = 0; foreach (RailDirection dir in DirectionUtils.AllRailDirections) { if ((rail_direction & ToRailDirectionFlags(dir)) != 0) { rail_count++; } } if (rail_count == 1) { return RailConfiguration.SingleRail; } if (AreTwoDisjointRailTracks(rail_direction)) { return RailConfiguration.TwoDisjointRailTracks; } return RailConfiguration.JoinedTracks; }
public static bool AreTwoDisjointRailTracks(RailDirectionFlags rail_direction) { return ( (rail_direction == (RailDirectionFlags.UpLeft | RailDirectionFlags.DownRight)) || (rail_direction == (RailDirectionFlags.DownLeft | RailDirectionFlags.UpRight)) ); }