Added Armor insurance Removal
This commit is contained in:
@@ -99,6 +99,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<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>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
44
Plugin.cs
44
Plugin.cs
@@ -21,6 +21,10 @@ namespace armorMod
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
private ConfigEntry<Boolean> LoseInsuranceOnRepair
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
private static ConfigEntry<float> TimeDelayRepairInSec
|
private static ConfigEntry<float> TimeDelayRepairInSec
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -41,6 +45,8 @@ namespace armorMod
|
|||||||
private float newMaxDurabilityDrainRate;
|
private float newMaxDurabilityDrainRate;
|
||||||
private ArmorComponent armor;
|
private ArmorComponent armor;
|
||||||
private static float timeSinceLastHit = 0f;
|
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>>
|
private readonly Dictionary<EquipmentSlot, List<Item>> equipmentSlotDictionary = new Dictionary<EquipmentSlot, List<Item>>
|
||||||
{
|
{
|
||||||
@@ -54,6 +60,7 @@ namespace armorMod
|
|||||||
internal void Awake()
|
internal void Awake()
|
||||||
{
|
{
|
||||||
ArmorServiceMode = Config.Bind("Armor Repair Settings", "Enable/Disable Mod", true, "Enables the Armor Repairing Options Below");
|
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");
|
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");
|
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");
|
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.BeingHitAction += Player_BeingHitAction;
|
||||||
player.OnPlayerDeadOrUnspawn += Player_OnPlayerDeadOrUnspawn;
|
player.OnPlayerDeadOrUnspawn += Player_OnPlayerDeadOrUnspawn;
|
||||||
runOnceAlready = true;
|
runOnceAlready = true;
|
||||||
|
|
||||||
|
//get insurance singleton
|
||||||
|
insurance = Singleton<InsuranceCompanyClass>.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepairArmor();
|
RepairArmor();
|
||||||
@@ -115,12 +125,46 @@ namespace armorMod
|
|||||||
if (armor.Repairable.Durability + newRepairRate >= armor.Repairable.MaxDurability)
|
if (armor.Repairable.Durability + newRepairRate >= armor.Repairable.MaxDurability)
|
||||||
{
|
{
|
||||||
armor.Repairable.Durability = 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());
|
//Logger.LogInfo("ASS: Setting MaxDurability for " + item.LocalizedName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
armor.Repairable.Durability += newRepairRate;
|
armor.Repairable.Durability += newRepairRate;
|
||||||
armor.Repairable.MaxDurability -= newMaxDurabilityDrainRate;
|
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);
|
//Logger.LogInfo("ASS: Repairing " + item.LocalizedName() + " : " + armor.Repairable.Durability + "/" + armor.Repairable.MaxDurability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user