48 public const string fName =
"InventorySlotWidget";
66 set => m_rectangleWidget.CenterColor = value;
71 set => m_rectangleWidget.BevelColor = value;
76 set => m_blockIconWidget.CustomViewMatrix = value;
104 List<Widget> list =
new();
127 FlipDirection =
true,
128 LitBarColor =
new Color(32, 128, 0),
129 UnlitBarColor =
new Color(24, 24, 24, 64),
130 BarSize =
new Vector2(12f, 12f),
143 FillColor =
new Color(160, 160, 160),
144 OutlineColor = Color.Transparent
151 FillColor =
new Color(160, 160, 160),
152 OutlineColor = Color.Transparent
159 FillColor =
new Color(160, 160, 160),
160 OutlineColor = Color.Transparent
164 list.Add(stackPanelWidget);
176 "OnInventorySlotWidgetDefined",
178 loader.OnInventorySlotWidgetDefined(
this, out List<Widget> childrenWidgetsToAdd);
179 if (childrenWidgetsToAdd !=
null) {
180 list.AddRange(childrenWidgetsToAdd);
207 m_blockIconWidget.DrawBlockEnvironmentData.Owner =
m_entity;
211 else if (input.
Tap.HasValue
229 if (inventory !=
null) {
236 if (input.
Click.HasValue
240 if (viewPlayer !=
null) {
250 else if (splitSourceInventory !=
null) {
252 int totalCount = splitSourceInventory.
GetSlotCount(splitSourceSlotIndex);
256 splitSourceInventory,
257 splitSourceSlotIndex,
276 || viewPlayer ==
null) {
332 num = m_dragMode.Value
switch {
339 m_rectangleWidget.IsVisible =
true;
348 m_countWidget.Text = num.ToString();
351 m_countWidget.IsVisible = num > 1 && !flag;
355 m_foodOverlayWidget.FillColor = flag2 ?
new Color(128, 64, 0) :
new Color(160, 160, 160);
359 m_healthBarWidget.IsVisible =
true;
360 m_healthBarWidget.Value = percent;
363 m_healthBarWidget.IsVisible =
false;
367 m_healthBarWidget.IsVisible =
false;
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;
381 m_splitLabelWidget.IsVisible =
false;
383 m_highlightWidget.OutlineColor =
new Color(0, 0, 0);
384 m_highlightWidget.FillColor =
new Color(0, 0, 0, 80);
387 m_highlightWidget.OutlineColor =
new Color(255, 64, 0);
388 m_splitLabelWidget.IsVisible =
true;
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;
403 base.MeasureOverride(parentAvailableSize);
405 "InventorySlotWidgetMeasureOverride",
407 loader.InventorySlotWidgetMeasureOverride(
this, parentAvailableSize);
449 if (componentFrame !=
null) {
451 environmentData.InWorldMatrix = componentFrame.
Matrix;
452 environmentData.Temperature =
m_subsystemTerrain.Terrain.GetSeasonalTemperature(point.
X, point.
Z);
457 if (componentBlockEntity !=
null) {
460 environmentData.Temperature =
m_subsystemTerrain.Terrain.GetSeasonalTemperature(coordinates.
X, coordinates.
Z);
461 environmentData.Humidity =
m_subsystemTerrain.Terrain.GetSeasonalHumidity(coordinates.
X, coordinates.
Z);
465 if (componentVitalStats !=
null) {
479 if (viewPlayer !=
null) {
495 int splitCount = totalCount;
499 splitCount = totalCount;
505 splitCount = (totalCount + 1) / 2;
510 "OnInventorySlotWidgetCalculateSplitCount",
512 loader.OnInventorySlotWidgetCalculateSplitCount(
533 "HandleMoveInventoryItem",
535 loader.HandleMoveInventoryItem(
548 int slotValue = sourceInventory.
GetSlotValue(sourceSlotIndex);
549 int slotValue2 = targetInventory.
GetSlotValue(targetSlotIndex);
550 int slotCount = sourceInventory.
GetSlotCount(sourceSlotIndex);
551 int slotCount2 = targetInventory.
GetSlotCount(targetSlotIndex);
553 || slotValue == slotValue2) {
557 targetInventory.
AddSlotItems(targetSlotIndex, slotValue, count2);
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);
581 "HandleInventoryDragProcess",
583 loader.HandleInventoryDragProcess(
589 ref targetSlotProcessCapacity
594 if (targetSlotProcessCapacity > 0) {
601 out
int processedValue,
602 out
int processedCount
604 if (processedValue != 0
605 && processedCount != 0) {
609 sourceInventory.
AddSlotItems(sourceSlotIndex, processedValue, count);
614 bool movedByMods =
false;
616 "HandleInventoryDragMove",
618 loader.HandleInventoryDragMove(
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);
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);
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)
static int FindAcquireSlotForItem(IInventory inventory, int value)
ComponentInput ComponentInput
float EnvironmentTemperature
static object Get(Type type, string name)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static bool DragHalfInSplit
static int ExtractContents(int value)
static int ToCell(float x)
static int ReplaceLight(int value, int light)
readonly PrimitivesRenderer2D PrimitivesRenderer2D
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 readonly Matrix Identity
static Vector2 Transform(Vector2 v, Matrix m)