本文整理汇总了C++中MemoryBuffer::ReadVariant方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::ReadVariant方法的具体用法?C++ MemoryBuffer::ReadVariant怎么用?C++ MemoryBuffer::ReadVariant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::ReadVariant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_node
//
// read_node
//
void ClientSidePrediction::read_node(MemoryBuffer& message)
{
auto network = GetSubsystem<Network>();
auto scene = network->GetServerConnection()->GetScene();
auto node_id = message.ReadUInt();
auto node = scene->GetNode(node_id);
bool new_node = false;
// Create the node if it doesn't exist
if (!node)
{
new_node = true;
// Add initially to the root level. May be moved as we receive the parent attribute
node = scene->CreateChild(node_id, LOCAL);
// Create smoothed transform component
node->CreateComponent<SmoothedTransform>(LOCAL);
}
else
{
// Remove the node from the unused nodes list
unused_nodes.erase(node);
}
// Read attributes
read_network_attributes(*node, message);
// ApplyAttributes() is deliberately skipped, as Node has no attributes that require late applying.
// Furthermore it would propagate to components and child nodes, which is not desired in this case
if (new_node)
{
// Snap the motion smoothing immediately to the end
auto transform = node->GetComponent<SmoothedTransform>();
if (transform)
transform->Update(1.0f, 0.0f);
}
// Read user variables
unsigned num_vars = message.ReadVLE();
for (; num_vars > 0; --num_vars)
{
auto key = message.ReadStringHash();
node->SetVar(key, message.ReadVariant());
}
// Read components
unsigned num_components = message.ReadVLE();
for (; num_components > 0; --num_components)
read_component(message, node);
}