Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ClothingSlot.cs
浏览该文件的文档.
1namespace Game {
2 public class ClothingSlot {
6 public static Dictionary<string, ClothingSlot> ClothingSlots = new();
7
8 public static Dictionary<int, ClothingSlot> ClothingSlotsByInt = new();
9 public static ClothingSlot Head => ClothingSlotsByInt[0];
13
14 public static void AddClothingSlot(string name) {
15 ClothingSlots[name] = new ClothingSlot { Name = name, StableId = ClothingSlots.Count };
16 ClothingSlotsByInt[ClothingSlots[name].StableId] = ClothingSlots[name];
17 }
18
19 public static void Initialize() {
20 ClothingSlots.Clear();
21 AddClothingSlot("Head");
22 AddClothingSlot("Torso");
23 AddClothingSlot("Legs");
24 AddClothingSlot("Feet");
25 ClothingSlots["Head"].MessageWhenLeastInsulated = LanguageControl.Get(ComponentVitalStats.fName, 41);
26 ClothingSlots["Torso"].MessageWhenLeastInsulated = LanguageControl.Get(ComponentVitalStats.fName, 42);
27 ClothingSlots["Legs"].MessageWhenLeastInsulated = LanguageControl.Get(ComponentVitalStats.fName, 43);
28 ClothingSlots["Feet"].MessageWhenLeastInsulated = LanguageControl.Get(ComponentVitalStats.fName, 44);
29 ClothingSlots["Head"].BasicInsulation = 2f;
30 ClothingSlots["Torso"].BasicInsulation = 0.2f;
31 ClothingSlots["Legs"].BasicInsulation = 0.4f;
32 ClothingSlots["Feet"].BasicInsulation = 2f;
34 "InitializeClothingSlots",
35 loader => {
36 loader.InitializeClothingSlots();
37 return false;
38 }
39 );
40 }
41
42 public int StableId;
43
44 public float BasicInsulation = 1e8f;
45
46 public string Name;
47 public virtual string MessageWhenLeastInsulated { get; set; } = string.Empty;
48
49 // 显式转换操作符
50 public static explicit operator int(ClothingSlot slot) => slot.StableId;
51 public static implicit operator ClothingSlot(int id) => ClothingSlotsByInt.TryGetValue(id, out ClothingSlot slot) ? slot : null;
52 }
53}
static ClothingSlot Feet
static void Initialize()
virtual string MessageWhenLeastInsulated
static Dictionary< string, ClothingSlot > ClothingSlots
调用自定义部位(比如手臂)的ClothingSlot,可以用ClothingSlot.ClothingSlots["Arms"]
static ClothingSlot Head
static Dictionary< int, ClothingSlot > ClothingSlotsByInt
static ClothingSlot Torso
static ClothingSlot Legs
static void AddClothingSlot(string name)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook