public static new string ToString() { var sb = new StringBuilder(); sb.AppendLine("#中国疫情#"); sb.AppendLine(InChina.ToString()); sb.AppendLine("#全球疫情#"); sb.AppendLine(InWorld.ToString()); sb.AppendLine("数据更新时间: " + UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")); sb.Append("数据来源: ").Append(ApiHost); return(sb.ToString()); }
public override string ToString() { return(InWorld.ToString() + "; " + InChunks.ToString()); }
public override void Tick() { if (tdisco) { return; } if (!IsValid) { return; } int pc = PacketsToApply.Count; for (int i = 0; i < pc; i++) { PacketsToApply[i].Apply(); } PacketsToApply.RemoveRange(0, pc); TickMovement(InWorld.Delta); // Manage Selection Location forward = Utilities.ForwardVector_Deg(Direction.X, Direction.Y); Location eye = Position + new Location(0, 0, Maxes.Z); Location seltarg = eye + forward * 10; SelectedBlock = Collision.BoxRayTrace(InWorld, new Location(-0.001), new Location(0.001), eye, seltarg, -1); if (SelectedBlock == seltarg) { SelectedBlock = Location.NaN; } // Break if (Attack && !SelectedBlock.IsNaN()) { if (ServerMain.GlobalTickTime - 0.5 >= LastBreak) { LastBreak = ServerMain.GlobalTickTime; Location sel_block = SelectedBlock.GetBlockLocation(); Chunk ch = InWorld.LoadChunk(World.GetChunkLocation(sel_block)); if (ch.Blocks[(int)(sel_block.X - ch.X * 30), (int)(sel_block.Y - ch.Y * 30), (int)(sel_block.Z - ch.Z * 30)].Type != 0) { ch.SetBlock((int)(sel_block.X - ch.X * 30), (int)(sel_block.Y - ch.Y * 30), (int)(sel_block.Z - ch.Z * 30), (ushort)Material.AIR); InWorld.BroadcastBlock(sel_block); } } } if (!Attack) { LastBreak = 0; } // Place Item HeldItem = GetItemForSlot(QuickBarPos); if (Secondary && HeldItem.Material != Material.AIR) { if (ServerMain.GlobalTickTime - 0.3 >= LastPlace) { Location back_a_block = Collision.BoxRayTrace(InWorld, new Location(-0.001), new Location(0.001), eye, seltarg, 1); LastPlace = ServerMain.GlobalTickTime; Location sel_block = back_a_block.GetBlockLocation(); Chunk ch = InWorld.LoadChunk(World.GetChunkLocation(sel_block)); if (ch.Blocks[(int)(sel_block.X - ch.X * 30), (int)(sel_block.Y - ch.Y * 30), (int)(sel_block.Z - ch.Z * 30)].Type != (ushort)HeldItem.Material) { ch.SetBlock((int)(sel_block.X - ch.X * 30), (int)(sel_block.Y - ch.Y * 30), (int)(sel_block.Z - ch.Z * 30), (ushort)HeldItem.Material); InWorld.BroadcastBlock(sel_block); } } } if (!Secondary) { LastPlace = 0; } // TODO: Better tracking of what chunks to send List <Location> locs = GetChunksNear(World.GetChunkLocation(Position)); foreach (Location loc in locs) { if (!ChunksAware.Contains(loc)) { ToSend.Add(loc); ChunksAware.Add(loc); } } for (int i = 0; i < ChunksAware.Count; i++) { if (!locs.Contains(ChunksAware[i])) { ToSend.Remove(ChunksAware[i]); ChunksAware.RemoveAt(i--); } } sendtimer += InWorld.Delta; if (sendtimer >= 0.05f) { sendtimer = 0.05f; if (ToSend.Count > 0) { Chunk ch = InWorld.LoadChunk(ToSend[0]); SendToSecondary(new ChunkPacketOut(ch)); for (int i = 0; i < ch.Entities.Count; i++) { if (ch.Entities[i] != this) { Send(new NewEntityPacketOut(ch.Entities[i])); } } ToSend.RemoveAt(0); } } // Handle networking lock (Packets) { for (int i = 0; i < Packets.Count; i++) { try { Packets[i].Apply(); } catch (Exception ex) { SysConsole.Output(OutputType.ERROR, "Networking / player / receive " + (Packets[i].IsChunkConnection ? "C-" : "") + "packet: " + ex.ToString()); Kick("Invalid packet " + Packets[i].GetType().Name); // TODO: Less internal-ish packet ID handling? } } Packets.Clear(); } }