Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentInventory.cs
浏览该文件的文档.
1using Engine;
4
5namespace Game {
7 public int m_activeSlotIndex;
8
9 public int m_visibleSlotsCount = 10;
10
11 public const int ShortInventorySlotsCount = 10;
12
13 public override int ActiveSlotIndex {
14 get => m_activeSlotIndex;
15 set => m_activeSlotIndex = Math.Clamp(value, 0, VisibleSlotsCount - 1);
16 }
17
18 public override int VisibleSlotsCount {
20 set {
21 value = Math.Clamp(value, 0, 10);
22 if (value == m_visibleSlotsCount) {
23 return;
24 }
25 m_visibleSlotsCount = value;
27 ComponentFrame componentFrame = Entity.FindComponent<ComponentFrame>();
28 if (componentFrame != null) {
29 Vector3 position = componentFrame.Position + new Vector3(0f, 0.5f, 0f);
30 Vector3 velocity = 1f * componentFrame.Rotation.GetForwardVector();
31 for (int i = m_visibleSlotsCount; i < 10; i++) {
32 DropSlotItems(this, i, position, velocity);
33 }
34 }
35 }
36 }
37
38 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
39 base.Load(valuesDictionary, idToEntityMap);
40 ActiveSlotIndex = valuesDictionary.GetValue<int>("ActiveSlotIndex");
41 }
42
43 public override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap) {
44 base.Save(valuesDictionary, entityToIdMap);
45 valuesDictionary.SetValue("ActiveSlotIndex", ActiveSlotIndex);
46 }
47
48 public override int GetSlotCapacity(int slotIndex, int value) {
49 if (slotIndex >= VisibleSlotsCount
50 && slotIndex < 10) {
51 return 0;
52 }
54 }
55 }
56}
Engine.Vector3 Vector3
virtual int GetMaxStacking(int value)
static void DropSlotItems(IInventory inventory, int slotIndex, Vector3 position, Vector3 velocity)
override int GetSlotCapacity(int slotIndex, int value)
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap)
static int ExtractContents(int value)
ValuesDictionary ValuesDictionary