| 30 | } |
| 31 | |
| 32 | void CanvasComponentAllocator::register_class(World& world) { |
| 33 | world.delayedUpdateObjectManager.register_class<CanvasComponentAllocator>(world.netObjMan, NetworkingObjects::DelayUpdateSerializedClassManager::CustomConstructors<CanvasComponentAllocator>{ |
| 34 | .writeConstructor = [](const CanvasComponentAllocator& o, cereal::PortableBinaryOutputArchive& a) { |
| 35 | a(o.comp->get_type()); |
| 36 | a(*o.comp); |
| 37 | }, |
| 38 | .readConstructor = [](CanvasComponentAllocator& o, cereal::PortableBinaryInputArchive& a, const std::shared_ptr<NetServer::ClientData>& c) { |
| 39 | CanvasComponentType typeToAllocate; |
| 40 | a(typeToAllocate); |
| 41 | o.comp = std::unique_ptr<CanvasComponent>(CanvasComponent::allocate_comp(typeToAllocate)); |
| 42 | a(*o.comp); |
| 43 | }, |
| 44 | .writeUpdate = [](const CanvasComponentAllocator& o, cereal::PortableBinaryOutputArchive& a) { |
| 45 | a(*o.comp); |
| 46 | }, |
| 47 | .readUpdate = [](CanvasComponentAllocator& o, cereal::PortableBinaryInputArchive& a, const std::shared_ptr<NetServer::ClientData>& c) { |
| 48 | a(*o.comp); |
| 49 | }, |
| 50 | .allocateCopy = [](const CanvasComponentAllocator& o) { |
| 51 | auto theCopy = std::make_shared<CanvasComponentAllocator>(); |
| 52 | theCopy->comp = std::unique_ptr<CanvasComponent>(CanvasComponent::allocate_comp(o.comp->get_type())); |
| 53 | // Maybe do an assignment here |
| 54 | return theCopy; |
| 55 | }, |
| 56 | .assignmentFunc = [](CanvasComponentAllocator& o, const CanvasComponentAllocator& o2) { |
| 57 | o.comp->set_data_from(*o2.comp); |
| 58 | }, |
| 59 | .postUpdateFunc = [&drawP = world.drawProg](CanvasComponentAllocator& o) { |
| 60 | o.comp->compContainer->commit_update(drawP); |
| 61 | } |
| 62 | }); |
| 63 | } |
| 64 | |
| 65 | void CanvasComponentAllocator::save_file(cereal::PortableBinaryOutputArchive& a) const { |
| 66 | a(comp->get_type()); |
nothing calls this directly
no test coverage detected