本文整理汇总了C++中MemoryBuffer::ReadStringHash方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::ReadStringHash方法的具体用法?C++ MemoryBuffer::ReadStringHash怎么用?C++ MemoryBuffer::ReadStringHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::ReadStringHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_component
//
// read_component
//
void ClientSidePrediction::read_component(MemoryBuffer& message, Node* node)
{
auto network = GetSubsystem<Network>();
auto scene = network->GetServerConnection()->GetScene();
// Read component ID
auto componentID = message.ReadUInt();
// Read component type
auto type = message.ReadStringHash();
// Check if the component by this ID and type already exists in this node
auto component = scene->GetComponent(componentID);
if (!component || component->GetType() != type || component->GetNode() != node)
{
if (component)
component->Remove();
component = node->CreateComponent(type, LOCAL, componentID);
}
// If was unable to create the component, would desync the message and therefore have to abort
if (!component)
{
LOGERROR("CreateNode message parsing aborted due to unknown component");
return;
}
// Read attributes and apply
read_network_attributes(*component, message);
component->ApplyAttributes();
}
示例2: 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);
}