Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
InventorySlotWidget.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
5
6namespace Game {
9
11
13
15
17
19
21
23
25
27
29
31
32 public int m_slotIndex;
33
35
36 public bool m_focus;
37
38 public int m_lastCount = -1;
39
41
43
45
47
48 public const string fName = "InventorySlotWidget";
49
50 public virtual bool HideBlockIcon { get; set; }
51
52 public virtual bool HideEditOverlay { get; set; }
53
54 public virtual bool HideInteractiveOverlay { get; set; }
55
56 public virtual bool HideFoodOverlay { get; set; }
57
58 public virtual bool HideHighlightRectangle { get; set; }
59
60 public virtual bool HideHealthBar { get; set; }
61
62 public virtual bool ProcessingOnly { get; set; }
63
64 public virtual Color CenterColor {
65 get => m_rectangleWidget.CenterColor;
66 set => m_rectangleWidget.CenterColor = value;
67 }
68
69 public virtual Color BevelColor {
70 get => m_rectangleWidget.BevelColor;
71 set => m_rectangleWidget.BevelColor = value;
72 }
73
74 public virtual Matrix? CustomViewMatrix {
75 get => m_blockIconWidget.CustomViewMatrix;
76 set => m_blockIconWidget.CustomViewMatrix = value;
77 }
78
79 public virtual GameWidget GameWidget {
80 get {
81 if (m_gameWidget == null) {
82 for (ContainerWidget parentWidget = ParentWidget; parentWidget != null; parentWidget = parentWidget.ParentWidget) {
83 if (parentWidget is GameWidget gameWidget) {
84 m_gameWidget = gameWidget;
85 break;
86 }
87 }
88 }
89 return m_gameWidget;
90 }
91 }
92
94 get {
95 if (m_dragHostWidget == null) {
96 m_dragHostWidget = GameWidget?.Children.Find<DragHostWidget>(false);
97 }
98 return m_dragHostWidget;
99 }
100 }
101
103 Size = new Vector2(72f, 72f);
104 List<Widget> list = new();
105 //格子边框
106 m_rectangleWidget = new BevelledRectangleWidget { BevelSize = -2f, DirectionalLight = 0.15f, CenterColor = Color.Transparent };
107 list.Add(m_rectangleWidget);
108 //格子背景色
109 m_highlightWidget = new RectangleWidget { FillColor = Color.Transparent, OutlineColor = Color.Transparent };
110 list.Add(m_highlightWidget);
111 //方块图标
114 };
115 list.Add(m_blockIconWidget);
116 //方块数量标志
118 FontScale = 1f, HorizontalAlignment = WidgetAlignment.Far, VerticalAlignment = WidgetAlignment.Far, Margin = new Vector2(6f, 2f)
119 };
120 list.Add(m_countWidget);
121 //耐久条
126 BarsCount = 3,
127 FlipDirection = true,
128 LitBarColor = new Color(32, 128, 0),
129 UnlitBarColor = new Color(24, 24, 24, 64),
130 BarSize = new Vector2(12f, 12f),
131 BarSubtexture = ContentManager.Get<Subtexture>("Textures/Atlas/ProgressBar"),
132 Margin = new Vector2(4f, 4f)
133 };
134 list.Add(m_healthBarWidget);
135 //右上角显示物品的编辑、交互、腐烂信息的面板
136 StackPanelWidget stackPanelWidget = new() {
137 Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Far, Margin = new Vector2(3f, 3f)
138 };
139 //标记可交互方块的手标记
141 Subtexture = ContentManager.Get<Subtexture>("Textures/Atlas/InteractiveItemOverlay"),
142 Size = new Vector2(13f, 14f),
143 FillColor = new Color(160, 160, 160),
144 OutlineColor = Color.Transparent
145 };
146 stackPanelWidget.Children.Add(m_interactiveOverlayWidget);
147 //标记可编辑方块的编辑标记
149 Subtexture = ContentManager.Get<Subtexture>("Textures/Atlas/EditItemOverlay"),
150 Size = new Vector2(12f, 14f),
151 FillColor = new Color(160, 160, 160),
152 OutlineColor = Color.Transparent
153 };
154 stackPanelWidget.Children.Add(m_editOverlayWidget);
155 //标记可腐烂方块的食物标记
157 Subtexture = ContentManager.Get<Subtexture>("Textures/Atlas/FoodItemOverlay"),
158 Size = new Vector2(11f, 14f),
159 FillColor = new Color(160, 160, 160),
160 OutlineColor = Color.Transparent
161 };
162 stackPanelWidget.Children.Add(m_foodOverlayWidget);
163 //完成stackPanelWidget的操作
164 list.Add(stackPanelWidget);
165 //红框Split标记
167 Text = LanguageControl.Get(fName, "1"),
168 Color = new Color(255, 64, 0),
171 Margin = new Vector2(2f, 0f)
172 };
173 list.Add(m_splitLabelWidget);
174 //为mod提供的标记
176 "OnInventorySlotWidgetDefined",
177 loader => {
178 loader.OnInventorySlotWidgetDefined(this, out List<Widget> childrenWidgetsToAdd);
179 if (childrenWidgetsToAdd != null) {
180 list.AddRange(childrenWidgetsToAdd);
181 }
182 return false;
183 }
184 );
185 //最后将Array放到Childred中
186 Children.Add(list.ToArray());
187 }
188
189 public virtual void AssignInventorySlot(IInventory inventory, int slotIndex) {
190 m_inventory = inventory;
191 m_slotIndex = slotIndex;
193 UpdateEnvironmentData(m_blockIconWidget.DrawBlockEnvironmentData);
194 }
195
196 public override void Update() {
197 if (m_inventory == null
198 || DragHostWidget == null) {
199 return;
200 }
201 WidgetInput input = Input;
202 ComponentPlayer viewPlayer = GetViewPlayer();
203 int slotValue = m_inventory.GetSlotValue(m_slotIndex);
204 int num = Terrain.ExtractContents(slotValue);
205 Block block = BlocksManager.Blocks[num];
206 UpdateEnvironmentData(m_blockIconWidget.DrawBlockEnvironmentData);
207 m_blockIconWidget.DrawBlockEnvironmentData.Owner = m_entity;
208 if (m_focus && !input.Press.HasValue) {
209 m_focus = false;
210 }
211 else if (input.Tap.HasValue
212 && HitTestGlobal(input.Tap.Value) == this) {
213 m_focus = true;
214 }
215 if (input.SpecialClick.HasValue
216 && HitTestGlobal(input.SpecialClick.Value.Start) == this
217 && HitTestGlobal(input.SpecialClick.Value.End) == this) {
218 IInventory inventory = null;
220 if (item.m_inventory != null
221 && item.m_inventory != m_inventory
222 && item.Input == Input
223 && item.IsEnabledGlobal
224 && item.IsVisibleGlobal) {
225 inventory = item.m_inventory;
226 break;
227 }
228 }
229 if (inventory != null) {
230 int num2 = ComponentInventoryBase.FindAcquireSlotForItem(inventory, slotValue);
231 if (num2 >= 0) {
232 HandleMoveItem(m_inventory, m_slotIndex, inventory, num2, m_inventory.GetSlotCount(m_slotIndex));
233 }
234 }
235 }
236 if (input.Click.HasValue
237 && HitTestGlobal(input.Click.Value.Start) == this
238 && HitTestGlobal(input.Click.Value.End) == this) {
239 bool flag = false;
240 if (viewPlayer != null) {
241
242 IInventory splitSourceInventory = viewPlayer.ComponentInput.SplitSourceInventory;
243 int splitSourceSlotIndex = viewPlayer.ComponentInput.SplitSourceSlotIndex;
244
245 if (splitSourceInventory == m_inventory
246 && splitSourceSlotIndex == m_slotIndex) {
248 flag = true;
249 }
250 else if (splitSourceInventory != null) {
251
252 int totalCount = splitSourceInventory.GetSlotCount(splitSourceSlotIndex);
253 int splitCount = CalculateSplitCount(totalCount, DragMode.SingleItem);
254
255 flag = HandleMoveItem(
256 splitSourceInventory,
257 splitSourceSlotIndex,
260 splitCount
261 );
262 AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
263 }
264 }
265 if (!flag
266 && m_inventory.ActiveSlotIndex != m_slotIndex
267 && m_slotIndex < 10) {
268 m_inventory.ActiveSlotIndex = m_slotIndex;
269 if (m_inventory.ActiveSlotIndex == m_slotIndex) {
270 AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
271 }
272 }
273 }
274 if (!m_focus
276 || viewPlayer == null) {
277 return;
278 }
279 Vector2? hold = input.Hold;
280 if (hold.HasValue
281 && HitTestGlobal(hold.Value) == this
282 && !DragHostWidget.IsDragInProgress
283 && m_inventory.GetSlotCount(m_slotIndex) > 0
285 input.Clear();
287 AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
288 }
289 Vector2? drag = input.Drag;
290 if (!drag.HasValue
291 || HitTestGlobal(drag.Value) != this
292 || DragHostWidget.IsDragInProgress) {
293 return;
294 }
295 int slotCount = m_inventory.GetSlotCount(m_slotIndex);
296 if (slotCount > 0) {
297 DragMode dragMode = input.DragMode;
301 }
302
303 // 计算物品分割的数量
304 int num3 = CalculateSplitCount(slotCount, dragMode);
305
306 ContainerWidget containerWidget = (ContainerWidget)LoadWidget(
307 null,
308 ContentManager.Get<XElement>("Widgets/InventoryDragWidget"),
309 null
310 );
311 containerWidget.Children.Find<BlockIconWidget>("InventoryDragWidget.Icon").Value = Terrain.ReplaceLight(slotValue, 15);
312 containerWidget.Children.Find<LabelWidget>("InventoryDragWidget.Name").Text = block.GetDisplayName(m_subsystemTerrain, slotValue);
313 containerWidget.Children.Find<LabelWidget>("InventoryDragWidget.Count").Text = num3.ToString();
314 containerWidget.Children.Find<LabelWidget>("InventoryDragWidget.Count").IsVisible = !(m_inventory is ComponentCreativeInventory)
316 UpdateEnvironmentData(containerWidget.Children.Find<BlockIconWidget>("InventoryDragWidget.Icon").DrawBlockEnvironmentData);
317 DragHostWidget.BeginDrag(
318 containerWidget,
319 new InventoryDragData { Inventory = m_inventory, SlotIndex = m_slotIndex, DragMode = dragMode },
320 delegate { m_dragMode = null; }
321 );
322 m_dragMode = dragMode;
323 }
324 }
325
326 public override void MeasureOverride(Vector2 parentAvailableSize) {
327 if (m_inventory != null) {
329 int num = m_inventory.GetSlotCount(m_slotIndex);
330 if (!flag
331 && m_dragMode.HasValue) {
332 num = m_dragMode.Value switch {
334 DragMode.SingleItem => num - 1,
335 DragMode.HalfItems => num - (num + 1) / 2,
336 _ => 0
337 };
338 }
339 m_rectangleWidget.IsVisible = true;
340 if (num > 0) {
341 int slotValue = m_inventory.GetSlotValue(m_slotIndex);
342 int num2 = Terrain.ExtractContents(slotValue);
343 Block block = BlocksManager.Blocks[num2];
344 bool flag2 = block.GetRotPeriod(slotValue) > 0 && block.GetDamage(slotValue) > 0;
345 m_blockIconWidget.Value = Terrain.ReplaceLight(slotValue, 15);
346 m_blockIconWidget.IsVisible = !HideBlockIcon;
347 if (num != m_lastCount) {
348 m_countWidget.Text = num.ToString();
349 m_lastCount = num;
350 }
351 m_countWidget.IsVisible = num > 1 && !flag;
352 m_editOverlayWidget.IsVisible = !HideEditOverlay && block.IsEditable_(slotValue);
353 m_interactiveOverlayWidget.IsVisible = !HideInteractiveOverlay && block.IsInteractive(m_subsystemTerrain, slotValue);
354 m_foodOverlayWidget.IsVisible = !HideFoodOverlay && block.GetRotPeriod(slotValue) > 0;
355 m_foodOverlayWidget.FillColor = flag2 ? new Color(128, 64, 0) : new Color(160, 160, 160);
356 if (!flag) {
357 float percent = block.GetBlockHealth(slotValue);
358 if (percent >= 0) {
359 m_healthBarWidget.IsVisible = true;
360 m_healthBarWidget.Value = percent;
361 }
362 else {
363 m_healthBarWidget.IsVisible = false;
364 }
365 }
366 else {
367 m_healthBarWidget.IsVisible = false;
368 }
369 }
370 else {
371 m_blockIconWidget.IsVisible = false;
372 m_countWidget.IsVisible = false;
373 m_healthBarWidget.IsVisible = false;
374 m_editOverlayWidget.IsVisible = false;
375 m_interactiveOverlayWidget.IsVisible = false;
376 m_foodOverlayWidget.IsVisible = false;
377 }
378 m_highlightWidget.IsVisible = !HideHighlightRectangle;
379 m_highlightWidget.OutlineColor = Color.Transparent;
380 m_highlightWidget.FillColor = Color.Transparent;
381 m_splitLabelWidget.IsVisible = false;
382 if (m_slotIndex == m_inventory.ActiveSlotIndex) {
383 m_highlightWidget.OutlineColor = new Color(0, 0, 0);
384 m_highlightWidget.FillColor = new Color(0, 0, 0, 80);
385 }
386 if (IsSplitMode()) {
387 m_highlightWidget.OutlineColor = new Color(255, 64, 0);
388 m_splitLabelWidget.IsVisible = true;
389 }
390 }
391 else {
392 m_rectangleWidget.IsVisible = false;
393 m_highlightWidget.IsVisible = false;
394 m_blockIconWidget.IsVisible = false;
395 m_countWidget.IsVisible = false;
396 m_healthBarWidget.IsVisible = false;
397 m_editOverlayWidget.IsVisible = false;
398 m_interactiveOverlayWidget.IsVisible = false;
399 m_foodOverlayWidget.IsVisible = false;
400 m_splitLabelWidget.IsVisible = false;
401 }
403 base.MeasureOverride(parentAvailableSize);
405 "InventorySlotWidgetMeasureOverride",
406 loader => {
407 loader.InventorySlotWidgetMeasureOverride(this, parentAvailableSize);
408 return false;
409 }
410 );
411 }
412
413 public override void Draw(DrawContext dc) {
414 if (m_inventory != null
415 && m_inventoryDragData != null) {
416 int slotValue = m_inventoryDragData.Inventory.GetSlotValue(m_inventoryDragData.SlotIndex);
417 if (m_inventory.GetSlotProcessCapacity(m_slotIndex, slotValue) >= 0
418 || m_inventory.GetSlotCapacity(m_slotIndex, slotValue) > 0) {
419 float num = 80f * GlobalTransform.Right.Length();
421 FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(100);
422 flatBatch2D.QueueEllipse(center, new Vector2(num), 0f, new Color(0, 0, 0, 96) * GlobalColorTransform, 64);
423 flatBatch2D.QueueEllipse(center, new Vector2(num - 0.5f), 0f, new Color(0, 0, 0, 64) * GlobalColorTransform, 64);
424 flatBatch2D.QueueEllipse(center, new Vector2(num + 0.5f), 0f, new Color(0, 0, 0, 48) * GlobalColorTransform, 64);
425 flatBatch2D.QueueDisc(center, new Vector2(num), 0f, new Color(0, 0, 0, 48) * GlobalColorTransform, 64);
426 }
427 }
428 m_inventoryDragData = null;
429 }
430
431 public void DragOver(Widget dragWidget, object data) {
433 }
434
435 public virtual void DragDrop(Widget dragWidget, object data) {
436 if (m_inventory != null
437 && data is InventoryDragData inventoryDragData) {
438 HandleDragDrop(inventoryDragData.Inventory, inventoryDragData.SlotIndex, inventoryDragData.DragMode, m_inventory, m_slotIndex);
439 }
440 }
441
443 environmentData.SubsystemTerrain = m_subsystemTerrain;
444 if (!(m_inventory is Component)) {
445 return;
446 }
447 Component component = (Component)m_inventory;
448 ComponentFrame componentFrame = component.Entity.FindComponent<ComponentFrame>();
449 if (componentFrame != null) {
450 Point3 point = Terrain.ToCell(componentFrame.Position);
451 environmentData.InWorldMatrix = componentFrame.Matrix;
452 environmentData.Temperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(point.X, point.Z);
453 environmentData.Humidity = m_subsystemTerrain.Terrain.GetSeasonalHumidity(point.X, point.Z);
454 }
455 else {
456 ComponentBlockEntity componentBlockEntity = component.Entity.FindComponent<ComponentBlockEntity>();
457 if (componentBlockEntity != null) {
458 Point3 coordinates = componentBlockEntity.Coordinates;
459 environmentData.InWorldMatrix = Matrix.Identity;
460 environmentData.Temperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(coordinates.X, coordinates.Z);
461 environmentData.Humidity = m_subsystemTerrain.Terrain.GetSeasonalHumidity(coordinates.X, coordinates.Z);
462 }
463 }
464 ComponentVitalStats componentVitalStats = component.Entity.FindComponent<ComponentVitalStats>();
465 if (componentVitalStats != null) {
466 environmentData.EnvironmentTemperature = componentVitalStats.EnvironmentTemperature;
467 }
468 }
469
471 if (GameWidget == null) {
472 return null;
473 }
474 return GameWidget.PlayerData.ComponentPlayer;
475 }
476
477 public virtual bool IsSplitMode() {
478 ComponentPlayer viewPlayer = GetViewPlayer();
479 if (viewPlayer != null) {
480 if (m_inventory != null
483 }
484 }
485 return false;
486 }
487
494 private int CalculateSplitCount(int totalCount, DragMode dragMode) {
495 int splitCount = totalCount; // 默认是全部数量
496
497 switch (dragMode) {
498 case DragMode.AllItems://全部
499 splitCount = totalCount;
500 break;
501 case DragMode.SingleItem://单个
502 splitCount = MathUtils.Min(totalCount, 1);
503 break;
504 case DragMode.HalfItems://均分
505 splitCount = (totalCount + 1) / 2;
506 break;
507 }
508
510 "OnInventorySlotWidgetCalculateSplitCount",
511 loader => {
512 loader.OnInventorySlotWidgetCalculateSplitCount(
513 this,
514 totalCount,
515 dragMode,
516 ref splitCount
517 );
518 return false;
519 }
520 );
521
522 // 确保数量在1到totalCount之间
523 return MathUtils.Clamp(splitCount, 1, totalCount);
524 }
525
526 public virtual bool HandleMoveItem(IInventory sourceInventory,
527 int sourceSlotIndex,
528 IInventory targetInventory,
529 int targetSlotIndex,
530 int count) {
531 bool moved_ = false;
533 "HandleMoveInventoryItem",
534 loader => {
535 loader.HandleMoveInventoryItem(
536 this,
537 sourceInventory,
538 sourceSlotIndex,
539 targetInventory,
540 targetSlotIndex,
541 ref count,
542 out bool moved
543 );
544 moved_ |= moved;
545 return false;
546 }
547 );
548 int slotValue = sourceInventory.GetSlotValue(sourceSlotIndex);
549 int slotValue2 = targetInventory.GetSlotValue(targetSlotIndex);
550 int slotCount = sourceInventory.GetSlotCount(sourceSlotIndex);
551 int slotCount2 = targetInventory.GetSlotCount(targetSlotIndex);
552 if (slotCount2 == 0
553 || slotValue == slotValue2) {
554 int num = MathUtils.Min(targetInventory.GetSlotCapacity(targetSlotIndex, slotValue) - slotCount2, slotCount, count);
555 if (num > 0) {
556 int count2 = sourceInventory.RemoveSlotItems(sourceSlotIndex, num);
557 targetInventory.AddSlotItems(targetSlotIndex, slotValue, count2);
558 return true;
559 }
560 }
561 return moved_;
562 }
563
564 public virtual bool HandleDragDrop(IInventory sourceInventory,
565 int sourceSlotIndex,
566 DragMode dragMode,
567 IInventory targetInventory,
568 int targetSlotIndex) {
569 int sourceSlotValue = sourceInventory.GetSlotValue(sourceSlotIndex);
570 int targetSlotValue = targetInventory.GetSlotValue(targetSlotIndex);
571 int dragCount = sourceInventory.GetSlotCount(sourceSlotIndex);
572 int targetSlotCount = targetInventory.GetSlotCount(targetSlotIndex);
573 int targetSlotCapacity = targetInventory.GetSlotCapacity(targetSlotIndex, sourceSlotValue);
574 int targetSlotProcessCapacity = targetInventory.GetSlotProcessCapacity(targetSlotIndex, sourceSlotValue);
575
576 dragCount = CalculateSplitCount(dragCount, dragMode);
577
578 bool flag = false;
579 //先进行Process操作
581 "HandleInventoryDragProcess",
582 loader => {
583 loader.HandleInventoryDragProcess(
584 this,
585 sourceInventory,
586 sourceSlotIndex,
587 targetInventory,
588 targetSlotIndex,
589 ref targetSlotProcessCapacity
590 );
591 return false;
592 }
593 );
594 if (targetSlotProcessCapacity > 0) {
595 int processCount = sourceInventory.RemoveSlotItems(sourceSlotIndex, MathUtils.Min(dragCount, targetSlotProcessCapacity));
596 targetInventory.ProcessSlotItems(
597 targetSlotIndex,
598 sourceSlotValue,
599 dragCount,
600 processCount,
601 out int processedValue,
602 out int processedCount
603 );
604 if (processedValue != 0
605 && processedCount != 0) {
606 //TODO:ProcessItem允许突破格子物品上限限制
607 int count = MathUtils.Min(sourceInventory.GetSlotCapacity(sourceSlotIndex, processedValue), processedCount);
608 sourceInventory.RemoveSlotItems(sourceSlotIndex, count);
609 sourceInventory.AddSlotItems(sourceSlotIndex, processedValue, count);
610 }
611 flag = true;
612 }
613 else if (!ProcessingOnly) {
614 bool movedByMods = false;
616 "HandleInventoryDragMove",
617 loader => {
618 loader.HandleInventoryDragMove(
619 this,
620 sourceInventory,
621 sourceSlotIndex,
622 targetInventory,
623 targetSlotIndex,
624 movedByMods,
625 out bool skip
626 );
627 movedByMods |= skip;
628 return false;
629 }
630 );
631 if (!movedByMods) {
632 //移动物品
633 if ((targetSlotCount == 0 || sourceSlotValue == targetSlotValue)
634 && targetSlotCount < targetSlotCapacity) {
635 int num2 = MathUtils.Min(targetSlotCapacity - targetSlotCount, dragCount);
636 bool handleMove = HandleMoveItem(sourceInventory, sourceSlotIndex, targetInventory, targetSlotIndex, num2);
637 if (handleMove) {
638 flag = true;
639 }
640 }
641 //交换两个物品栏之间的物品
642 else if (targetInventory.GetSlotCapacity(targetSlotIndex, sourceSlotValue) >= dragCount
643 && sourceInventory.GetSlotCapacity(sourceSlotIndex, targetSlotValue) >= targetSlotCount
644 && sourceInventory.GetSlotCount(sourceSlotIndex) == dragCount) {
645 int count3 = targetInventory.RemoveSlotItems(targetSlotIndex, targetSlotCount);
646 int count4 = sourceInventory.RemoveSlotItems(sourceSlotIndex, dragCount);
647 targetInventory.AddSlotItems(targetSlotIndex, sourceSlotValue, count4);
648 sourceInventory.AddSlotItems(sourceSlotIndex, targetSlotValue, count3);
649 flag = true;
650 }
651 }
652 }
653 if (flag) {
654 AudioManager.PlaySound("Audio/UI/ItemMoved", 1f, 0f, 0f);
655 }
656 return flag;
657 }
658 }
659}
Engine.Color Color
void QueueEllipse(Vector2 center, Vector2 radius, float depth, Color color, int sides=32, float startAngle=0f, float endAngle=(float) Math.PI *2f)
void QueueDisc(Vector2 center, Vector2 radius, float depth, Color color, int sides=32, float startAngle=0f, float endAngle=(float) Math.PI *2f)
FlatBatch2D FlatBatch(int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null)
static int Clamp(int x, int min, int max)
static int Min(int x1, int x2)
static void PlaySound(string name, float volume, float pitch, float pan)
virtual bool IsInteractive(SubsystemTerrain subsystemTerrain, int value)
virtual bool IsEditable_(int value)
virtual int GetDamage(int value)
virtual int GetRotPeriod(int value)
virtual float GetBlockHealth(int value)
virtual string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
DrawBlockEnvironmentData DrawBlockEnvironmentData
virtual void SetSplitSourceInventoryAndSlot(IInventory inventory, int slotIndex)
static int FindAcquireSlotForItem(IInventory inventory, int value)
IEnumerable< Widget > AllChildren
readonly WidgetsList Children
static object Get(Type type, string name)
virtual DragHostWidget DragHostWidget
virtual void AssignInventorySlot(IInventory inventory, int slotIndex)
void DragOver(Widget dragWidget, object data)
virtual ComponentPlayer GetViewPlayer()
BevelledRectangleWidget m_rectangleWidget
override void MeasureOverride(Vector2 parentAvailableSize)
virtual void DragDrop(Widget dragWidget, object data)
virtual bool HandleMoveItem(IInventory sourceInventory, int sourceSlotIndex, IInventory targetInventory, int targetSlotIndex, int count)
override void Draw(DrawContext dc)
int CalculateSplitCount(int totalCount, DragMode dragMode)
计算分割的数量
virtual bool HandleDragDrop(IInventory sourceInventory, int sourceSlotIndex, DragMode dragMode, IInventory targetInventory, int targetSlotIndex)
void UpdateEnvironmentData(DrawBlockEnvironmentData environmentData)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static int ExtractContents(int value)
static int ToCell(float x)
static int ReplaceLight(int value, int light)
readonly PrimitivesRenderer2D PrimitivesRenderer2D
Widget RootWidget
bool IsVisibleGlobal
static Widget LoadWidget(object eventsTarget, XElement node, ContainerWidget parentWidget)
virtual Widget HitTestGlobal(Vector2 point, Func< Widget, bool > predicate=null)
virtual bool IsVisible
WidgetInput Input
Color GlobalColorTransform
ContainerWidget ParentWidget
virtual WidgetAlignment VerticalAlignment
virtual Vector2 Margin
virtual WidgetAlignment HorizontalAlignment
bool IsDrawRequired
bool IsEnabledGlobal
Vector2 ActualSize
Matrix GlobalTransform
Widget Find(string name, Type type, bool throwIfNotFound=true)
void Add(Widget widget)
Component FindComponent(Type type, string name, bool throwOnError)
virtual Subsystem FindSubsystem(Type type, string name, bool throwOnError)
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
int RemoveSlotItems(int slotIndex, int count)
实际移除的数量
int GetSlotCount(int slotIndex)
int GetSlotCapacity(int slotIndex, int value)
void AddSlotItems(int slotIndex, int value, int count)
int GetSlotProcessCapacity(int slotIndex, int value)
void ProcessSlotItems(int slotIndex, int value, int count, int processCount, out int processedValue, out int processedCount)
int GetSlotValue(int slotIndex)
static Color Transparent
定义 Color.cs:5
static readonly Matrix Identity
static Vector2 Transform(Vector2 v, Matrix m)