5 switch (item.GetHealthLevel(damage_zone))
11 Debug.Log(
"repairing from GameConstants.STATE_RUINED");
13 CalculateHealth(player, repair_kit, item, specialty_weight, damage_zone, use_kit_qty);
16 if (CanRepairToPristine(player) || CanBeRepairedToPristine(item))
18 CalculateHealth(player, repair_kit, item, specialty_weight, damage_zone, use_kit_qty);
22 CalculateHealth(player, repair_kit, item, specialty_weight, damage_zone, use_kit_qty);
29 void CalculateHealth(
PlayerBase player,
ItemBase kit,
Object item,
float specialty_weight,
string damage_zone =
"",
bool use_kit_qty =
true)
32 Class.CastTo(entity,item);
36 entity.SetAllowDamage(
true);
39 int health_levels_count = item.GetNumberOfHealthLevels(damage_zone);
40 float kit_repair_cost_adjusted;
43 int target_level =
Math.Clamp(item.GetHealthLevel(damage_zone) - 1, 0, health_levels_count - 1);
45 if (!CanRepairToPristine(player) && !CanBeRepairedToPristine(item))
47 target_level =
Math.Clamp(target_level,
GameConstants.STATE_WORN, health_levels_count - 1);
49 health_coef = item.GetHealthLevelValue(target_level,damage_zone);
52 if (kit && kit.ConfigGetInt(
"repairKitType"))
54 bool kit_has_quantity = kit.HasQuantity();
55 float cur_kit_quantity = kit.GetQuantity();
56 float kit_repair_cost_per_level = GetKitRepairCost(kit, item);
58 if (cur_kit_quantity > kit_repair_cost_per_level)
60 kit_repair_cost_adjusted = kit_repair_cost_per_level;
62 kit_repair_cost_adjusted =
Math.Clamp(kit_repair_cost_adjusted, 0, 100);
65 new_quantity = kit.GetQuantity() - kit_repair_cost_adjusted;
66 kit.SetQuantity(new_quantity);
69 else if (!kit_has_quantity)
81 if (item.GetHealth01(damage_zone,
"Health") < health_coef)
83 item.SetHealth01(damage_zone,
"Health",health_coef);
88 entity.ProcessInvulnerabilityCheck(entity.GetInvulnerabilityTypeString());
94 int state = item.GetHealthLevel(damage_zone);
98 int repair_kit_type = repair_kit.ConfigGetInt(
"repairKitType");
105 item.ConfigGetIntArray(
"repairableWithKits", repairable_with_types);
107 for (
int i = 0; i < repairable_with_types.Count(); i++)
109 int repairable_with_type = repairable_with_types.Get(i);
111 if (IsRepairValid(repair_kit_type, repairable_with_type))
121 private bool IsRepairValid(
int repair_kit_type,
int repairable_with_type)
123 if (repair_kit_type > 0 && repairable_with_type > 0)
125 return repair_kit_type == repairable_with_type;
132 private bool CanRepairToPristine(
PlayerBase player)
138 private bool CanBeRepairedToPristine(
Object item)
140 return item.CanBeRepairedToPristine();
148 item.ConfigGetIntArray(
"repairableWithKits", allowedRepairKitTypes);
149 item.ConfigGetFloatArray(
"repairCosts", repairKitCosts);
151 int repairKitType = repair_kit.ConfigGetInt(
"repairKitType");
153 foreach (
int i,
int allowedKitType : allowedRepairKitTypes)
155 if (allowedKitType == repairKitType)
157 return repairKitCosts.Get(i);
Super root of all classes in Enforce script.
Plugin interface for controlling of agent pool system.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
bool CanRepair(ItemBase item_repair_kit)
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)