Files

45 lines
1.1 KiB
C#

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;
}
}
}