/// <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()); }
/// <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()); }