本文整理汇总了C#中IMyReplicable.GetPriority方法的典型用法代码示例。如果您正苦于以下问题:C# IMyReplicable.GetPriority方法的具体用法?C# IMyReplicable.GetPriority怎么用?C# IMyReplicable.GetPriority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyReplicable
的用法示例。
在下文中一共展示了IMyReplicable.GetPriority方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshReplicable
private void RefreshReplicable(IMyReplicable replicable)
{
MyTimeSpan now = m_timeFunc();
foreach (var client in m_clientStates)
{
MyReplicableClientData replicableInfo;
bool hasObj = client.Value.Replicables.TryGetValue(replicable, out replicableInfo);
bool isRelevant = replicable.GetPriority(client.Value.State) > 0;
if(isRelevant)
{
var dependency = replicable.GetDependency();
isRelevant = dependency == null || client.Value.IsReplicableReady(dependency);
}
if (!hasObj && isRelevant)
{
AddForClient(replicable, client.Key, client.Value);
}
else if (hasObj)
{
// Hysteresis
replicableInfo.UpdateSleep(isRelevant, now);
if (replicableInfo.ShouldRemove(now, MaxSleepTime))
RemoveForClient(replicable, client.Key, client.Value, true);
}
}
}
示例2: RefreshReplicable
private void RefreshReplicable(IMyReplicable replicable)
{
ProfilerShort.Begin("m_timeFunc");
MyTimeSpan now = m_timeFunc();
ProfilerShort.End();
foreach (var client in m_clientStates)
{
ProfilerShort.Begin("RefreshReplicablePerClient");
ProfilerShort.Begin("TryGetValue Replicables");
MyReplicableClientData replicableInfo;
bool hasObj = client.Value.Replicables.TryGetValue(replicable, out replicableInfo);
ProfilerShort.End();
ProfilerShort.Begin("GetPriority");
ProfilerShort.Begin(replicable.GetType().Name);
float priority = replicable.GetPriority(new MyClientInfo(client.Value));
if (hasObj)
{
replicableInfo.Priority = priority;
}
bool isRelevant = priority > 0;
ProfilerShort.End();
ProfilerShort.End();
if (isRelevant && !hasObj)
{
ProfilerShort.Begin("CheckReady");
var dependency = replicable.GetDependency();
isRelevant = dependency == null || client.Value.IsReplicableReady(dependency);
ProfilerShort.End();
if (isRelevant)
{
ProfilerShort.Begin("AddForClient");
AddForClient(replicable, client.Key, client.Value, priority, false);
ProfilerShort.End();
}
}
else if (hasObj)
{
ProfilerShort.Begin("UpdateSleepAndRemove");
// Hysteresis
replicableInfo.UpdateSleep(isRelevant, now);
if (replicableInfo.ShouldRemove(now, MaxSleepTime))
RemoveForClient(replicable, client.Key, client.Value, true);
ProfilerShort.End();
}
ProfilerShort.End();
}
}