Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemMemoryBankBlockBehavior.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public override int[] HandledBlocks => [186];
6 public static string fName = "MemoryBankBlockBehavior";
7
8 public SubsystemMemoryBankBlockBehavior() : base(186) { }
9
10 public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer) {
11 if (componentPlayer.DragHostWidget.IsDragInProgress) {
12 return false;
13 }
14 int value = inventory.GetSlotValue(slotIndex);
15 int count = inventory.GetSlotCount(slotIndex);
16 int id = Terrain.ExtractData(value);
17 MemoryBankData memoryBankData = GetItemData(id);
18 memoryBankData = memoryBankData != null ? (MemoryBankData)memoryBankData.Copy() : new MemoryBankData();
21 componentPlayer.GuiWidget,
23 memoryBankData,
24 () => {
25 int data = StoreItemDataAtUniqueId(memoryBankData);
26 int value2 = Terrain.ReplaceData(value, data);
27 inventory.RemoveSlotItems(slotIndex, count);
28 inventory.AddSlotItems(slotIndex, value2, count);
29 }
30 )
31 );
32 }
33 else {
35 componentPlayer.GuiWidget,
37 memoryBankData,
38 delegate {
39 int data = StoreItemDataAtUniqueId(memoryBankData);
40 int value2 = Terrain.ReplaceData(value, data);
41 inventory.RemoveSlotItems(slotIndex, count);
42 inventory.AddSlotItems(slotIndex, value2, count);
43 }
44 )
45 );
46 }
47 return true;
48 }
49
50 public override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer) {
51 MemoryBankData memoryBankData = GetBlockData(new Point3(x, y, z)) ?? new MemoryBankData();
54 componentPlayer.GuiWidget,
56 memoryBankData,
57 () => {
58 SetBlockData(new Point3(x, y, z), memoryBankData);
59 int face = ((MemoryBankBlock)BlocksManager.Blocks[186]).GetFace(value);
61 ElectricElement electricElement = subsystemElectricity.GetElectricElement(x, y, z, face);
62 if (electricElement != null) {
63 subsystemElectricity.QueueElectricElementForSimulation(electricElement, subsystemElectricity.CircuitStep + 1);
64 }
65 }
66 )
67 );
68 }
69 else {
71 componentPlayer.GuiWidget,
73 memoryBankData,
74 delegate {
75 SetBlockData(new Point3(x, y, z), memoryBankData);
76 int face = ((MemoryBankBlock)BlocksManager.Blocks[186]).GetFace(value);
78 ElectricElement electricElement = subsystemElectricity.GetElectricElement(x, y, z, face);
79 if (electricElement != null) {
80 subsystemElectricity.QueueElectricElementForSimulation(electricElement, subsystemElectricity.CircuitStep + 1);
81 }
82 }
83 )
84 );
85 }
86 return true;
87 }
88 }
89}
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
IEditableItemData Copy()
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)
ElectricElement GetElectricElement(int x, int y, int z, int mountingFace)
override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer)
static int ReplaceData(int value, int data)
static int ExtractData(int value)
virtual Subsystem FindSubsystem(Type type, string name, bool throwOnError)
int RemoveSlotItems(int slotIndex, int count)
实际移除的数量
int GetSlotCount(int slotIndex)
void AddSlotItems(int slotIndex, int value, int count)
int GetSlotValue(int slotIndex)