新增1.0和2.0两种协议车型车型
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StandardScene.Fass2Simulator
|
||||
{
|
||||
public sealed class Fass2SimNodeProfile
|
||||
{
|
||||
public int ActionDelayMs { get; set; }
|
||||
}
|
||||
|
||||
public sealed class Fass2SimNodeProfileStore
|
||||
{
|
||||
private readonly Dictionary<ushort, Fass2SimNodeProfile> _profiles = new Dictionary<ushort, Fass2SimNodeProfile>();
|
||||
|
||||
public void Load(IDictionary<string, Fass2SimNodeProfile> nodes)
|
||||
{
|
||||
_profiles.Clear();
|
||||
if (nodes == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var pair in nodes)
|
||||
{
|
||||
if (!ushort.TryParse(pair.Key, out var nodeId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_profiles[nodeId] = pair.Value ?? new Fass2SimNodeProfile();
|
||||
}
|
||||
}
|
||||
|
||||
public int ResolveActionDelayMs(ushort nodeId, int fallbackMs)
|
||||
{
|
||||
if (_profiles.TryGetValue(nodeId, out var profile) && profile.ActionDelayMs > 0)
|
||||
{
|
||||
return profile.ActionDelayMs;
|
||||
}
|
||||
|
||||
return fallbackMs;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user