Exemple #1
0
        /// <summary>
        /// Handles <see cref="MeshDestroyMessage"/>
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="reader"></param>
        /// <returns></returns>
        /// Emits <see cref="OnMeshRemoved"/>.
        protected Error DestroyMesh(PacketBuffer packet, BinaryReader reader)
        {
            MeshDestroyMessage msg = new MeshDestroyMessage();

            if (!msg.Read(reader))
            {
                return(new Error(ErrorCode.MalformedMessage, MeshDestroyMessage.MessageID));
            }

            if (!_meshes.ContainsKey(msg.MeshID))
            {
                return(new Error(ErrorCode.InvalidObjectID, msg.MeshID));
            }

            MeshDetails meshDetails = _meshes[msg.MeshID];

            NotifyMeshRemoved(meshDetails);

            _meshes.Remove(msg.MeshID);
            if (meshDetails.FinalMeshes != null)
            {
                foreach (Mesh mesh in meshDetails.FinalMeshes)
                {
                    Mesh.Destroy(mesh);
                }
            }

            return(new Error());
        }
Exemple #2
0
        /// <summary>
        /// Handles <see cref="MeshDestroyMessage"/>
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="reader"></param>
        /// <returns></returns>
        /// Emits <see cref="OnMeshRemoved"/>.
        protected Error DestroyMesh(PacketBuffer packet, BinaryReader reader)
        {
            MeshDestroyMessage msg = new MeshDestroyMessage();

            if (!msg.Read(reader))
            {
                return(new Error(ErrorCode.MalformedMessage, MeshDestroyMessage.MessageID));
            }

            if (!_meshes.ContainsKey(msg.MeshID))
            {
                return(new Error(ErrorCode.InvalidObjectID, msg.MeshID));
            }

            MeshDetails meshEntry = _meshes[msg.MeshID];

            NotifyMeshRemoved(meshEntry);

            _meshes.Remove(msg.MeshID);
            if (meshEntry.Mesh != null)
            {
                meshEntry.Mesh.ReleaseBuffers();
            }

            return(new Error());
        }
Exemple #3
0
        /// <summary>
        /// Send mesh destruction message.
        /// </summary>
        /// <param name="packet">Packet to populate with the destruction message.</param>
        /// <returns>Zero on success.</returns>
        public int Destroy(PacketBuffer packet)
        {
            MeshDestroyMessage msg = new MeshDestroyMessage();

            msg.MeshID = ID;
            packet.Reset((ushort)RoutingID.Mesh, MeshDestroyMessage.MessageID);
            msg.Write(packet);
            return(0);
        }