-
Notifications
You must be signed in to change notification settings - Fork 3
/
Helper.cs
47 lines (43 loc) · 2.21 KB
/
Helper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;
namespace Bannerlord.DynamicTroop;
public static class Helper {
public static EquipmentIndex? ItemEnumTypeToEquipmentIndex(ItemObject.ItemTypeEnum itemType) {
return itemType switch {
ItemObject.ItemTypeEnum.HeadArmor => EquipmentIndex.Head,
ItemObject.ItemTypeEnum.HandArmor => EquipmentIndex.Gloves,
ItemObject.ItemTypeEnum.BodyArmor => EquipmentIndex.Body,
ItemObject.ItemTypeEnum.LegArmor => EquipmentIndex.Leg,
ItemObject.ItemTypeEnum.Cape => EquipmentIndex.Cape,
ItemObject.ItemTypeEnum.Horse => EquipmentIndex.Horse,
ItemObject.ItemTypeEnum.HorseHarness => EquipmentIndex.HorseHarness,
_ => null
};
}
public static ItemObject.ItemTypeEnum? EquipmentIndexToItemEnumType(EquipmentIndex index) {
return index switch {
EquipmentIndex.Head => ItemObject.ItemTypeEnum.HeadArmor,
EquipmentIndex.Gloves => ItemObject.ItemTypeEnum.HandArmor,
EquipmentIndex.Body => ItemObject.ItemTypeEnum.BodyArmor,
EquipmentIndex.Leg => ItemObject.ItemTypeEnum.LegArmor,
EquipmentIndex.Cape => ItemObject.ItemTypeEnum.Cape,
EquipmentIndex.Horse => ItemObject.ItemTypeEnum.Horse,
EquipmentIndex.HorseHarness => ItemObject.ItemTypeEnum.HorseHarness,
_ => null
};
}
public static int GetArmorValueForBodyPart(ArmorComponent armorComponent, BoneBodyPartType bodyPart) {
return bodyPart switch {
BoneBodyPartType.Head => armorComponent.HeadArmor,
BoneBodyPartType.Neck => armorComponent.HeadArmor,
BoneBodyPartType.Chest => armorComponent.BodyArmor,
BoneBodyPartType.Abdomen => armorComponent.BodyArmor,
BoneBodyPartType.ShoulderLeft => armorComponent.BodyArmor,
BoneBodyPartType.ShoulderRight => armorComponent.BodyArmor,
BoneBodyPartType.ArmLeft => armorComponent.ArmArmor,
BoneBodyPartType.ArmRight => armorComponent.ArmArmor,
BoneBodyPartType.Legs => armorComponent.LegArmor,
_ => 0
};
}
}