Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
BowWidget.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3
4namespace Game {
5 public class BowWidget : CanvasWidget {
7
8 public int m_slotIndex;
9
11
13
15 public static string fName = "BowWidget";
16
17 public BowWidget(IInventory inventory, int slotIndex) {
18 m_inventory = inventory;
19 m_slotIndex = slotIndex;
20 XElement node = ContentManager.Get<XElement>("Widgets/BowWidget");
21 LoadContents(this, node);
22 m_inventoryGrid = Children.Find<GridPanelWidget>("InventoryGrid");
23 m_inventorySlotWidget = Children.Find<InventorySlotWidget>("InventorySlot");
24 m_instructionsLabel = Children.Find<LabelWidget>("InstructionsLabel");
25 for (int i = 0; i < m_inventoryGrid.RowsCount; i++) {
26 for (int j = 0; j < m_inventoryGrid.ColumnsCount; j++) {
27 InventorySlotWidget widget = new();
28 m_inventoryGrid.Children.Add(widget);
29 m_inventoryGrid.SetWidgetCell(widget, new Point2(j, i));
30 }
31 }
32 int num = 10;
33 foreach (Widget child in m_inventoryGrid.Children) {
34 (child as InventorySlotWidget)?.AssignInventorySlot(inventory, num++);
35 }
36 m_inventorySlotWidget.AssignInventorySlot(inventory, slotIndex);
37 m_inventorySlotWidget.CustomViewMatrix = Matrix.CreateLookAt(new Vector3(-1f, 0.2f, 0.6f), new Vector3(0f, 0.2f, 0f), Vector3.UnitY);
38 }
39
40 public override void Update() {
41 int slotValue = m_inventory.GetSlotValue(m_slotIndex);
42 int slotCount = m_inventory.GetSlotCount(m_slotIndex);
43 int num = Terrain.ExtractContents(slotValue);
44 m_instructionsLabel.Text = !BowBlock.GetArrowType(Terrain.ExtractData(slotValue)).HasValue
47 if (num != 191
48 || slotCount == 0) {
49 ParentWidget.Children.Remove(this);
50 }
51 }
52 }
53}
Engine.Vector3 Vector3
static ArrowBlock.? ArrowType GetArrowType(int data)
static string fName
InventorySlotWidget m_inventorySlotWidget
IInventory m_inventory
override void Update()
GridPanelWidget m_inventoryGrid
LabelWidget m_instructionsLabel
BowWidget(IInventory inventory, int slotIndex)
readonly WidgetsList Children
static object Get(Type type, string name)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static int ExtractContents(int value)
static int ExtractData(int value)
ContainerWidget ParentWidget
virtual void LoadContents(object eventsTarget, XElement node)
static Matrix CreateLookAt(Vector3 position, Vector3 target, Vector3 up)
static readonly Vector3 UnitY