本文整理汇总了C++中TSerialize::ValueWithDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ TSerialize::ValueWithDefault方法的具体用法?C++ TSerialize::ValueWithDefault怎么用?C++ TSerialize::ValueWithDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSerialize
的用法示例。
在下文中一共展示了TSerialize::ValueWithDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Serialize
void CColorGradientManager::Serialize(TSerialize serializer)
{
if(serializer.IsReading())
Reset();
serializer.BeginGroup("ColorGradientManager");
{
int numToLoad = (int)m_colorGradientsToLoad.size();
int numLoaded = (int)m_currentGradients.size();
int numGradients = numToLoad + numLoaded;
serializer.Value("ColorGradientCount", numGradients);
if(serializer.IsWriting())
{
for(int i=0; i<numToLoad; ++i)
{
LoadingColorGradient& gradient = m_colorGradientsToLoad[i];
serializer.BeginGroup("ColorGradient");
serializer.Value("FilePath", gradient.m_filePath);
serializer.Value("FadeInTime", gradient.m_fadeInTimeInSeconds);
serializer.EndGroup();
}
for(int i=0; i<numLoaded; ++i)
{
LoadedColorGradient& gradient = m_currentGradients[i];
serializer.BeginGroup("ColorGradient");
serializer.Value("FilePath", gradient.m_filePath);
serializer.Value("BlendAmount", gradient.m_layer.m_blendAmount);
serializer.Value("FadeInTime", gradient.m_fadeInTimeInSeconds);
serializer.Value("ElapsedTime", gradient.m_elapsedTime);
serializer.Value("MaximumBlendAmount", gradient.m_maximumBlendAmount);
serializer.EndGroup();
}
}
else
{
m_currentGradients.reserve(numGradients);
for(int i=0; i<numGradients; ++i)
{
serializer.BeginGroup("ColorGradient");
string filePath;
float blendAmount = 1.0f;
float fadeInTimeInSeconds = 0.0f;
serializer.Value("FilePath", filePath);
serializer.Value("BlendAmount", blendAmount);
serializer.Value("FadeInTime", fadeInTimeInSeconds);
const int textureID = GetColorGradingController().LoadColorChart(filePath);
LoadedColorGradient gradient(filePath, SColorChartLayer(textureID, blendAmount), fadeInTimeInSeconds);
// Optional
serializer.ValueWithDefault("ElapsedTime", gradient.m_elapsedTime, 0.0f);
serializer.ValueWithDefault("MaximumBlendAmount", gradient.m_maximumBlendAmount, 1.0f);
m_currentGradients.push_back(gradient);
serializer.EndGroup();
}
}
serializer.EndGroup();
}
}
示例2: Serialize
//------------------------------------------------------------------------
void CVehicleDamageBehaviorEffect::Serialize(TSerialize ser, EEntityAspects aspects)
{
bool isEffectActive = m_slot > -1;
ser.Value("isActive", isEffectActive);
int slot = m_slot;
ser.ValueWithDefault("slot", slot, -1);
if(ser.IsReading())
{
if(!isEffectActive && m_slot > -1)
{
Reset();
}
m_slot = slot;
}
}