Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
CraftingRecipeSlotWidget.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3
4namespace Game {
7
9
10 public string m_ingredient;
11
12 public int m_resultValue;
13
14 public int m_resultCount;
15
17 XElement node = ContentManager.Get<XElement>("Widgets/CraftingRecipeSlot");
18 LoadContents(this, node);
19 m_blockIconWidget = Children.Find<BlockIconWidget>("CraftingRecipeSlotWidget.Icon");
20 m_labelWidget = Children.Find<LabelWidget>("CraftingRecipeSlotWidget.Count");
21 }
22
23 public void SetIngredient(string ingredient) {
24 m_ingredient = ingredient;
25 m_resultValue = 0;
26 m_resultCount = 0;
27 }
28
29 public void SetResult(int value, int count) {
30 m_resultValue = value;
31 m_resultCount = count;
32 m_ingredient = null;
33 }
34
35 public override void MeasureOverride(Vector2 parentAvailableSize) {
36 m_blockIconWidget.IsVisible = false;
37 m_labelWidget.IsVisible = false;
38 if (!string.IsNullOrEmpty(m_ingredient)) {
39 CraftingRecipesManager.DecodeIngredient(m_ingredient, out string craftingId, out int? data);
40 Block[] array = BlocksManager.FindBlocksByCraftingId(craftingId);
41 if (array.Length != 0) {
42 Block block = array[(int)(1.0 * Time.RealTime) % array.Length];
43 if (block != null) {
44 m_blockIconWidget.Value = Terrain.MakeBlockValue(block.BlockIndex, 0, data ?? 0);
45 m_blockIconWidget.Light = 15;
46 m_blockIconWidget.IsVisible = true;
47 }
48 }
49 }
50 else if (m_resultValue != 0) {
51 m_blockIconWidget.Value = m_resultValue;
52 m_blockIconWidget.Light = 15;
53 m_labelWidget.Text = m_resultCount.ToString();
54 m_blockIconWidget.IsVisible = true;
55 m_labelWidget.IsVisible = true;
56 }
57 base.MeasureOverride(parentAvailableSize);
58 }
59 }
60}
static double RealTime
定义 Time.cs:38
int BlockIndex
定义 Block.cs:6
static Block[] FindBlocksByCraftingId(string craftingId)
readonly WidgetsList Children
static object Get(Type type, string name)
override void MeasureOverride(Vector2 parentAvailableSize)
static void DecodeIngredient(string ingredient, out string craftingId, out int? data)
static int MakeBlockValue(int contents)
virtual void LoadContents(object eventsTarget, XElement node)