/// <summary> /// Kicks the player from the server with a specified message. /// </summary> /// <param name="message">The kick reason.</param> public void Kick(string message) { if (pkick) { return; } pkick = true; if (UsedNow != null && ((Entity)UsedNow).IsSpawned) { UsedNow.StopUse(this); } if (Network.Alive) { SendMessage(TextChannel.IMPORTANT, "Kicking you: " + message); Network.Alive = false; Network.PrimarySocket.Close(5); } // TODO: Broadcast kick message SysConsole.Output(OutputType.INFO, "Kicking " + this.ToString() + ": " + message); if (IsSpawned && !Removed) { ItemStack it = Items.GetItemForSlot(Items.cItem); it.Info.SwitchFrom(this, it); HookItem.RemoveHook(this); RemoveMe(); } string nl = Name.ToLower(); string fn = "server_player_saves/" + nl[0].ToString() + "/" + nl + ".plr"; SaveToYAML(PlayerConfig); TheServer.Files.WriteText(fn, PlayerConfig.SaveToString()); }
public override void Tick() { if (!IsSpawned) { return; } if (TheRegion.Delta <= 0) { return; } base.Tick(); opstt += TheRegion.Delta; while (opstt > 1.0) { opstt -= 1.0; OncePerSecondTick(); } ItemStack cit = Items.GetItemForSlot(Items.cItem); if (GetVelocity().LengthSquared() > 1) // TODO: Move animation to CharacterEntity { // TODO: Replicate animation automation on client? SetAnimation("human/stand/run", 0); SetAnimation("human/stand/" + AnimToHold(cit), 1); SetAnimation("human/stand/run", 2); } else { SetAnimation("human/stand/idle01", 0); SetAnimation("human/stand/" + AnimToHold(cit), 1); SetAnimation("human/stand/idle01", 2); } if (Click) // TODO: Move clicking to CharacterEntity { cit.Info.Click(this, cit); LastClick = TheRegion.GlobalTickTime; WasClicking = true; } else if (WasClicking) { cit.Info.ReleaseClick(this, cit); WasClicking = false; } if (AltClick) { cit.Info.AltClick(this, cit); LastAltClick = TheRegion.GlobalTickTime; WasAltClicking = true; } else if (WasAltClicking) { cit.Info.ReleaseAltClick(this, cit); WasAltClicking = false; } cit.Info.Tick(this, cit); WasItemLefting = ItemLeft; WasItemUpping = ItemUp; WasItemRighting = ItemRight; Location pos = LoadRelPos; Vector3i cpos = TheRegion.ChunkLocFor(pos); if (cpos != pChunkLoc) { for (int x = -2; x <= 2; x++) { for (int y = -2; y <= 2; y++) { for (int z = -2; z <= 2; z++) { TryChunk(cpos + new Vector3i(x, y, z), 1); } } } } ChunkMarchAndSend(); if (cpos != pChunkLoc) { /* * // TODO: Better system -> async? * TrySet(pos, 1, 1, 0, 1, false); * TrySet(pos, ViewRadiusInChunks / 2, ViewRadiusInChunks / 2, 0, 1, false); * TrySet(pos, ViewRadiusInChunks, ViewRadiusInChunks, 0, 1, false); * TrySet(pos, ViewRadiusInChunks + 1, ViewRadiusInChunks, 15, 2, true); * TrySet(pos, ViewRadiusInChunks + ViewRadExtra2, ViewRadiusInChunks + ViewRadExtra2Height, 30, 2, true); * TrySet(pos, ViewRadiusInChunks + ViewRadExtra5, ViewRadiusInChunks + ViewRadExtra5Height, 60, 5, true); */ /* * if (!loadedInitially) * { * loadedInitially = true; * ChunkNetwork.SendPacket(new TeleportPacketOut(GetPosition())); * ChunkNetwork.SendPacket(new OperationStatusPacketOut(StatusOperation.CHUNK_LOAD, 1)); * } * else * { * ChunkNetwork.SendPacket(new OperationStatusPacketOut(StatusOperation.CHUNK_LOAD, 2)); * } */ foreach (ChunkAwarenessInfo ch in ChunksAwareOf.Values) { if (!ShouldLoadChunk(ch.ChunkPos)) { removes.Add(ch.ChunkPos); } else if (!ShouldSeeChunk(ch.ChunkPos) && ch.LOD <= BestLOD) { ch.LOD = Chunk.CHUNK_SIZE; } } foreach (Vector3i loc in removes) { Chunk ch = TheRegion.GetChunk(loc); if (ch != null) { ForgetChunk(ch, loc); } else { ChunksAwareOf.Remove(loc); } } removes.Clear(); pChunkLoc = cpos; } if (Breadcrumbs.Count > 0) { double dist = (GetPosition() - Breadcrumbs[Breadcrumbs.Count - 1]).LengthSquared(); if (dist > BreadcrumbRadius * BreadcrumbRadius) { Location one = Breadcrumbs[Breadcrumbs.Count - 1]; Location two = GetPosition().GetBlockLocation() + new Location(0.5f, 0.5f, 0.5f); Breadcrumbs.Add((two - one).Normalize() * BreadcrumbRadius + one); // TODO: Effect? } } // TODO: Move use to CharacterEntity if (Use) { Location forw = ForwardVector(); CollisionResult cr = TheRegion.Collision.RayTrace(GetEyePosition(), GetEyePosition() + forw * 5, IgnoreThis); if (cr.Hit && cr.HitEnt != null && cr.HitEnt.Tag is EntityUseable) { if (UsedNow != (EntityUseable)cr.HitEnt.Tag) { if (UsedNow != null && ((Entity)UsedNow).IsSpawned) { UsedNow.StopUse(this); } UsedNow = (EntityUseable)cr.HitEnt.Tag; UsedNow.StartUse(this); } } else if (UsedNow != null) { if (((Entity)UsedNow).IsSpawned) { UsedNow.StopUse(this); } UsedNow = null; } } else if (UsedNow != null) { if (((Entity)UsedNow).IsSpawned) { UsedNow.StopUse(this); } UsedNow = null; } if (!CanReach(GetPosition())) { Teleport(posClamp(GetPosition())); } }