Skip to content

Commit

Permalink
repeatDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Jul 22, 2024
1 parent 6164bc3 commit 0b4a771
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"eventType": "SPAWN_PREFAB",
"repeatDelay": {
"NORMAL": 1,
"PASSIVE": 1,
"NIGHTMARE": 1
},
"itemInventoryConditions": [
{
"type": "AnyOfItem",
Expand Down
10 changes: 9 additions & 1 deletion Winch/Serialization/WorldEvent/WorldEventDataConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ namespace Winch.Serialization.WorldEvent;

public class WorldEventDataConverter : DredgeTypeConverter<ModdedWorldEvent>
{
private readonly static Dictionary<GameMode, float> defaultRepeatDelay = new()
{
{ GameMode.NORMAL, 1 },
{ GameMode.PASSIVE, 1 },
{ GameMode.NIGHTMARE, 1 },
};


private readonly Dictionary<string, FieldDefinition> _definitions = new()
{
{ "id", new(null, null) },
Expand All @@ -23,7 +31,7 @@ public class WorldEventDataConverter : DredgeTypeConverter<ModdedWorldEvent>
{ "minSanity", new(0f, o => Mathf.Clamp01(float.Parse(o.ToString()))) },
{ "maxSanity", new(1f, o => Mathf.Clamp01(float.Parse(o.ToString()))) },
{ "weight", new(0f, o => float.Parse(o.ToString())) },
{ "repeatDelay", new(new Dictionary<GameMode, float>(), o => DredgeTypeHelpers.ParseDictionary<GameMode, float>(o, k => DredgeTypeHelpers.GetEnumValue<GameMode>(k), v => float.Parse(v.ToString()))) },
{ "repeatDelay", new(defaultRepeatDelay, o => DredgeTypeHelpers.ParseDictionary<GameMode, float>(o, k => DredgeTypeHelpers.GetEnumValue<GameMode>(k), v => float.Parse(v.ToString()))) },
{ "spawnStartTime", new(0f, o => Mathf.Clamp01(float.Parse(o.ToString()))) },
{ "spawnEndTime", new(1f, o => Mathf.Clamp01(float.Parse(o.ToString()))) },
{ "hasDuration", new(false, o=> bool.Parse(o.ToString())) },
Expand Down

0 comments on commit 0b4a771

Please sign in to comment.