✨ Complete resource manager
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using static System.Int32;
|
||||
|
||||
namespace AceFieldNewHorizon.Scripts.System;
|
||||
|
||||
@@ -101,12 +102,22 @@ public partial class BuildingRegistry : Node
|
||||
{
|
||||
int val;
|
||||
var obj = costDict[mat];
|
||||
if (obj.VariantType == Variant.Type.PackedInt64Array)
|
||||
val = (int)obj.AsInt64();
|
||||
else if (obj.VariantType == Variant.Type.PackedInt32Array)
|
||||
val = obj.AsInt32();
|
||||
else
|
||||
int.TryParse(obj.ToString(), out val);
|
||||
switch (obj.VariantType)
|
||||
{
|
||||
case Variant.Type.PackedInt64Array:
|
||||
val = (int)obj.AsInt64();
|
||||
break;
|
||||
case Variant.Type.PackedInt32Array:
|
||||
val = obj.AsInt32();
|
||||
break;
|
||||
case Variant.Type.Float:
|
||||
val = (int)obj.AsDouble();
|
||||
break;
|
||||
default:
|
||||
if (!TryParse(obj.ToString(), out val))
|
||||
GD.PrintErr($"[BuildingRegistry] Failed to parse cost for '{key}': {obj.ToString()}");
|
||||
break;
|
||||
}
|
||||
cost[mat] = val;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +131,7 @@ public partial class BuildingRegistry : Node
|
||||
else if (dObj.VariantType == Variant.Type.PackedInt32Array)
|
||||
durability = dObj.AsInt32();
|
||||
else
|
||||
int.TryParse(dObj.ToString(), out durability);
|
||||
TryParse(dObj.ToString(), out durability);
|
||||
}
|
||||
|
||||
// Parse buildTime
|
||||
|
Reference in New Issue
Block a user