Added Armor insurance Removal

This commit is contained in:
dvize
2023-05-30 16:28:52 -07:00
parent 0fa82b2dd6
commit e268726b9a
2 changed files with 45 additions and 1 deletions

View File

@@ -99,6 +99,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "C:\SPT\BepInEx\plugins\dvize.ASS.dll"</PostBuildEvent>
<PostBuildEvent>copy "$(TargetPath)" "F:\SPT-AKI\BepInEx\plugins\dvize.ASS.dll"</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -21,6 +21,10 @@ namespace armorMod
{
get; set;
}
private ConfigEntry<Boolean> LoseInsuranceOnRepair
{
get; set;
}
private static ConfigEntry<float> TimeDelayRepairInSec
{
get; set;
@@ -41,6 +45,8 @@ namespace armorMod
private float newMaxDurabilityDrainRate;
private ArmorComponent armor;
private static float timeSinceLastHit = 0f;
private static InsuranceCompanyClass insurance;
private static List<InsuredItemClass> insuranceList;
private readonly Dictionary<EquipmentSlot, List<Item>> equipmentSlotDictionary = new Dictionary<EquipmentSlot, List<Item>>
{
@@ -54,6 +60,7 @@ namespace armorMod
internal void Awake()
{
ArmorServiceMode = Config.Bind("Armor Repair Settings", "Enable/Disable Mod", true, "Enables the Armor Repairing Options Below");
LoseInsuranceOnRepair = Config.Bind("Armor Repair Settings", "Lose Insurance On Repair", true, "If Enabled, you will lose insurance on whenever the armor is repaired in-raid");
TimeDelayRepairInSec = Config.Bind("Armor Repair Settings", "Time Delay Repair in Sec", 60f, "How Long Before you were last hit that it repairs armor");
ArmorRepairRateOverTime = Config.Bind("Armor Repair Settings", "Armor Repair Rate", 0.5f, "How much durability per second is repaired");
MaxDurabilityDegradationRateOverTime = Config.Bind("Armor Repair Settings", "Max Durability Drain Rate", 0.025f, "How much max durability per second of repairs is drained");
@@ -75,6 +82,9 @@ namespace armorMod
player.BeingHitAction += Player_BeingHitAction;
player.OnPlayerDeadOrUnspawn += Player_OnPlayerDeadOrUnspawn;
runOnceAlready = true;
//get insurance singleton
insurance = Singleton<InsuranceCompanyClass>.Instance;
}
RepairArmor();
@@ -115,12 +125,46 @@ namespace armorMod
if (armor.Repairable.Durability + newRepairRate >= armor.Repairable.MaxDurability)
{
armor.Repairable.Durability = armor.Repairable.MaxDurability;
//check if insuredItems class contains the item
if (insurance != null && LoseInsuranceOnRepair.Value)
{
// use accesstools to get private List<InsuredItemClass> list_0;
insuranceList = (List<InsuredItemClass>)AccessTools.Field(typeof(InsuranceCompanyClass), "list_0").GetValue(insurance);
//check the insuranceList for the item by id and remove it if it exists
var x = insuranceList.Where(i => i.itemId == item.Id).FirstOrDefault();
if (x != null)
{
//remove from insuranceList
insuranceList.Remove(x);
}
}
//Logger.LogInfo("ASS: Setting MaxDurability for " + item.LocalizedName());
}
else
{
armor.Repairable.Durability += newRepairRate;
armor.Repairable.MaxDurability -= newMaxDurabilityDrainRate;
//check if insuredItems class contains the item
if (insurance != null && LoseInsuranceOnRepair.Value)
{
// use accesstools to get private List<InsuredItemClass> list_0;
insuranceList = (List<InsuredItemClass>)AccessTools.Field(typeof(InsuranceCompanyClass), "list_0").GetValue(insurance);
//check the insuranceList for the item by id and remove it if it exists
var x = insuranceList.Where(i => i.itemId == item.Id).FirstOrDefault();
if (x != null)
{
//remove from insuranceList
insuranceList.Remove(x);
}
}
//Logger.LogInfo("ASS: Repairing " + item.LocalizedName() + " : " + armor.Repairable.Durability + "/" + armor.Repairable.MaxDurability);
}
}