internal PhysicsHandler(Level l, bool enabled) { Level = l; IsEnabled = enabled; new Thread(TickTimer).Start(); }
public BlockPos(ushort x, ushort y, ushort z, Level l) { X = x; Y = y; Z = z; Level = l; Index = l.PosToInt(X, Y, Z); InBounds = !l.NotInBounds(X, Y, Z); BlockType = !InBounds ? (byte)255 : l.GetTile(Index); BlockMCType = (MCBlocks)BlockType; }
public BlockPos(int x, int y, int z, Level l) { X = (ushort)x; Y = (ushort)y; Z = (ushort)z; Level = l; Index = l.PosToInt(X, Y, Z); InBounds = !l.NotInBounds(X, Y, Z); BlockType = !InBounds ? (byte)255 : l.GetTile(Index); BlockMCType = (MCBlocks)BlockType; }
public LevelHandler() { Lobby = new Level("Lobby", true); LevelSaveCheckTimer.Elapsed += delegate { LevelSaveCheckTimer.Interval = 15000; LevelSaveUpdateCheck(); }; LevelSaveCheckTimer.Start(); }
public BlockPos(int x, int y, int z, Level l) { Stopwatch sw = Stopwatch.StartNew(); X = (ushort)x; Y = (ushort)y; Z = (ushort)z; Level = l; Index = l.PosToInt(X, Y, Z); InBounds = !l.NotInBounds(X, Y, Z); BlockType = !InBounds ? (byte)255 : l.GetTile(Index); BlockMCType = (MCBlocks)BlockType; Level.BlockPosCreationAverager.Add(sw.ElapsedTicks); }
public BlockPos(ushort x, ushort y, ushort z, int pos, Level l) { Stopwatch sw = Stopwatch.StartNew(); X = x; Y = y; Z = z; Level = l; Index = pos; InBounds = !l.NotInBounds(X, Y, Z); BlockType = !InBounds ? (byte)255 : l.GetTile(Index); BlockMCType = (MCBlocks)BlockType; Level.BlockPosCreationAverager.Add(sw.ElapsedTicks); }
public override void Generate(Level lvl) { var half = (ushort)(lvl.SizeY / 2); for (ushort x = 0; x < lvl.SizeX; ++x) { for (ushort z = 0; z < lvl.SizeZ; ++z) { for (ushort y = 0; y < lvl.SizeY; ++y) { if (y != half) { lvl.SetTile(x, y, z, (byte)((y >= half) ? MCBlocks.Air : MCBlocks.Dirt)); } else { lvl.SetTile(x, y, z, (byte)MCBlocks.Grass); } } } } }
/// <summary> /// This method adds a byte to the Otherdata dictionary for physics /// This method will clear out any existing otherdata for the block position /// </summary> /// <param name="level">The level your working with</param> /// <param name="pos">The Block position index in the level block data array</param> /// <param name="value">The "OtherData" value to set for this block.</param> public void AddOtherData(Level level, int pos, byte value) { RemoveOtherData(level, pos); level.Physics.OtherData.Add(pos, value); }
public override void PlayerUse(Player p, string[] parameters, string fullCommand) { if (parameters.Length == 0) { PlayerHelp(p); return; } if (parameters[0].Equals("create", StringComparison.OrdinalIgnoreCase) || parameters[0].Equals("new", StringComparison.OrdinalIgnoreCase)) { if (parameters.Length == 2) { Level lfind = Level.Find(parameters[1]); if (lfind != null) { //Called when a player types /level create <name> or /level new <name> and the name is already used for another level p.SendMessage("Level Already Exists!"); } else { //Called when a player types /level create <name> or /level new <name> and the name isn't already a level Level level = new Level(parameters[1], 256, 256, 256); } } else if (parameters.Length == 3) { //Called when a player types /level create <name> <type> or /level new <name> <type> if (parameters[2].Equals("flatgrass", StringComparison.OrdinalIgnoreCase)) { Level level = new Level(parameters[1], 256, 256, 256, parameters[2]); } else if (parameters[2].Equals("pixel", StringComparison.OrdinalIgnoreCase)) { Level level = new Level(parameters[1], 256, 256, 256, parameters[2]); } else { //Called when a player types /level create <name> <type> or /level new <name> <type> and the type is invalid. p.SendMessage("Invalid world type! Valid types are flatgrass and pixel."); } } else { //This is called when the player types /level create or /level new Level level = new Level("temporary", 256, 256, 256); } } if (parameters[0].Equals("load", StringComparison.OrdinalIgnoreCase)) { //This is called when the player types /level load if (parameters.Length < 2) { PlayerHelp(p); return; } Level level = Level.Find(parameters[1]); if (level != null) p.SendMessage("Level Already Loaded! found!"); else { new Level(parameters[1], false); } } if (parameters[0].Equals("unload", StringComparison.OrdinalIgnoreCase)) { //This is called when the player types /level unload if (parameters.Length < 2) { PlayerHelp(p); return; } Level level = Level.Find(parameters[1]); if (level == null) p.SendMessage("Level not found!"); else { level.Unload(); } } }
public virtual void OnPlace(Player p, Level level, int pos) { }
public virtual void Physics(Level level, int pos) { }
/// <summary> /// This will remove any "OtherData" for the specified block index /// </summary> /// <param name="level">The level your working with</param> /// <param name="pos">The index to remove from the list</param> public void RemoveOtherData(Level level, int pos) { level.Physics.OtherData.Remove(pos); }
public void SwitchMap(Level l) { Stopwatch sw = Stopwatch.StartNew(); OldLevel = Level; Level = l; SendMap(); sw.Stop(); Console.WriteLine("Level sent to player in: " + sw.ElapsedMilliseconds + " ms!"); }
internal void AddMapData(Level l) { for (int index = 0; index < l.BlockData.Length; index++) { byte t = l.BlockData[index]; Bytes.Add(t); } }
internal void SwitchMap(Level l) { OldLevel = Level; Level = l; SendMap(); }
public virtual void OnBreak(Player p, Level level, int pos) { }
public abstract void Generate(Level lvl);
public FlatGrassGenerator(Level lvl) { Generate(lvl); }