Converted DefaultVitality into extension method
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Eft.Profile;
|
||||
|
||||
namespace SPTarkov.Server.Core.Extensions
|
||||
{
|
||||
public static class VitalityExtensions
|
||||
{
|
||||
public static void SetDefaults(this 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>(),
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Extensions;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Eft.Profile;
|
||||
@@ -6,7 +7,6 @@ using SPTarkov.Server.Core.Models.Spt.Config;
|
||||
using SPTarkov.Server.Core.Servers;
|
||||
using SPTarkov.Server.Core.Utils;
|
||||
using BodyPartHealth = SPTarkov.Server.Core.Models.Eft.Common.Tables.BodyPartHealth;
|
||||
using Vitality = SPTarkov.Server.Core.Models.Eft.Profile.Vitality;
|
||||
|
||||
namespace SPTarkov.Server.Core.Helpers;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class HealthHelper(
|
||||
ConfigServer _configServer
|
||||
)
|
||||
{
|
||||
protected HealthConfig _healthConfig = _configServer.GetConfig<HealthConfig>();
|
||||
protected readonly HealthConfig _healthConfig = _configServer.GetConfig<HealthConfig>();
|
||||
|
||||
/// <summary>
|
||||
/// Resets the profiles vitality/health and vitality/effects properties to their defaults
|
||||
@@ -29,82 +29,11 @@ public class HealthHelper(
|
||||
{
|
||||
var profile = _saveServer.GetProfile(sessionID);
|
||||
|
||||
DefaultVitality(profile.VitalityData);
|
||||
profile.VitalityData.SetDefaults();
|
||||
|
||||
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>(),
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update player profile vitality values with changes from client request object
|
||||
/// </summary>
|
||||
|
||||
@@ -32,22 +32,11 @@
|
||||
<!-- BuildType options - LOCAL, DEBUG, RELEASE, BLEEDING_EDGE, BLEEDING_EDGE_MODS - *must be all caps*-->
|
||||
</PropertyGroup>
|
||||
<Target Name="AfterEverythingDone" AfterTargets="PostBuildEvent">
|
||||
<Exec
|
||||
ConsoleToMsBuild="true"
|
||||
Condition="'$(IsPublish)' == 'true'"
|
||||
Command="dotnet build -c $(Configuration) $(MSBuildProjectDirectory)/../../Patches/Ceciler.Virtualizer/Ceciler.Virtualizer.csproj"
|
||||
/>
|
||||
<Exec
|
||||
ConsoleToMsBuild="true"
|
||||
Command="dotnet "$(MSBuildProjectDirectory)/../../Ceciler/Ceciler.Launcher.dll" "$(OutDir)SPTarkov.Server.Core.dll" "$(MSBuildProjectDirectory)/../../Patches/Ceciler.Virtualizer/bin/$(Configuration)/$(TargetFramework)/Ceciler.Virtualizer.dll""
|
||||
/>
|
||||
<Exec ConsoleToMsBuild="true" Condition="'$(IsPublish)' == 'true'" Command="dotnet build -c $(Configuration) $(MSBuildProjectDirectory)/../../Patches/Ceciler.Virtualizer/Ceciler.Virtualizer.csproj" />
|
||||
<Exec ConsoleToMsBuild="true" Command="dotnet "$(MSBuildProjectDirectory)/../../Ceciler/Ceciler.Launcher.dll" "$(OutDir)SPTarkov.Server.Core.dll" "$(MSBuildProjectDirectory)/../../Patches/Ceciler.Virtualizer/bin/$(Configuration)/$(TargetFramework)/Ceciler.Virtualizer.dll"" />
|
||||
</Target>
|
||||
<!-- Generates the ProgramStatics class with the build information -->
|
||||
<Target Name="GenerateProgramStatics" BeforeTargets="BeforeBuild">
|
||||
<WriteLinesToFile
|
||||
File="Utils/ProgramStatics.Generated.cs"
|
||||
Lines="
using SPTarkov.Server.Core.Models.Enums%3B

namespace SPTarkov.Server.Core.Utils%3B

public static partial class ProgramStatics
{
 private static string? _sptVersion = "$(SptVersion)"%3B
 private static string? _commit = "$(SptCommit)"%3B
 private static double? _buildTime = $(SptBuildTime)%3B
 private static EntryType? BuildType = EntryType.$(SptBuildType)%3B
}
"
|
||||
Overwrite="true"
|
||||
/>
|
||||
<WriteLinesToFile File="Utils/ProgramStatics.Generated.cs" Lines="
using SPTarkov.Server.Core.Models.Enums%3B

namespace SPTarkov.Server.Core.Utils%3B

public static partial class ProgramStatics
{
 private static string? _sptVersion = "$(SptVersion)"%3B
 private static string? _commit = "$(SptCommit)"%3B
 private static double? _buildTime = $(SptBuildTime)%3B
 private static EntryType? BuildType = EntryType.$(SptBuildType)%3B
}
" Overwrite="true" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user