Files
SPT-Server-Build/Libraries/Core/Routers/SaveLoad/HealthSaveLoadRouter.cs
T
2025-01-29 12:12:01 +00:00

103 lines
3.0 KiB
C#

using SptCommon.Annotations;
using Core.DI;
using Core.Helpers;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.Profile;
namespace Core.Routers.SaveLoad;
[Injectable(InjectableTypeOverride = typeof(SaveLoadRouter))]
public class HealthSaveLoadRouter() : SaveLoadRouter
{
protected override List<HandledRoute> GetHandledRoutes()
{
return [new("spt-health", false)];
}
public override SptProfile HandleLoad(SptProfile profile)
{
DefaultVitality(profile.VitalityData);
return profile;
}
public void DefaultVitality(Vitality? vitality)
{
vitality ??= new Vitality { Health = null, Energy = 0, Temperature = 0, Hydration = 0 };
vitality.Health = new Dictionary<string, BodyPartHealth>
{
{
"Head", new BodyPartHealth
{
Health = new CurrentMinMax
{
Current = 0,
},
Effects = new Dictionary<string, BodyPartEffectProperties>()
}
},
{
"Chest", new BodyPartHealth
{
Health = new CurrentMinMax
{
Current = 0,
},
Effects = new Dictionary<string, BodyPartEffectProperties>()
}
},
{
"Stomach", new BodyPartHealth
{
Health = new CurrentMinMax
{
Current = 0,
},
Effects = new Dictionary<string, BodyPartEffectProperties>()
}
},
{
"LeftArm", new BodyPartHealth
{
Health = new CurrentMinMax
{
Current = 0,
},
Effects = new Dictionary<string, BodyPartEffectProperties>()
}
},
{
"RightArm", new BodyPartHealth
{
Health = new CurrentMinMax
{
Current = 0,
},
Effects = new Dictionary<string, BodyPartEffectProperties>()
}
},
{
"LeftLeg", new BodyPartHealth
{
Health = new CurrentMinMax
{
Current = 0,
},
Effects = new Dictionary<string, BodyPartEffectProperties>()
}
},
{
"RightLeg", new BodyPartHealth
{
Health = new CurrentMinMax
{
Current = 0,
},
Effects = new Dictionary<string, BodyPartEffectProperties>()
}
}
};
}
}