3 using Microsoft.Xna.Framework;
12 private string[] terminalButtonStyles;
13 private GUIFrame containerHolder;
14 private GUIImage containerIndicator;
15 private GUIComponentStyle indicatorStyleRed, indicatorStyleGreen;
17 partial
void InitProjSpecific(ContentXElement element)
19 terminalButtonStyles =
new string[RequiredSignalCount];
21 foreach (var childElement
in element.GetChildElements(
"TerminalButton"))
23 string style = childElement.GetAttributeString(
"style",
null);
24 if (style ==
null) {
continue; }
25 terminalButtonStyles[i++] = style;
27 indicatorStyleRed = GUIStyle.GetComponentStyle(
"IndicatorLightRed");
28 indicatorStyleGreen = GUIStyle.GetComponentStyle(
"IndicatorLightGreen");
37 RelativeSpacing = 0.08f
41 bool buttonsEnabled = AllowUsingButtons;
42 foreach (var child
in component.Children)
45 if (!(child.UserData is
int)) {
continue; }
46 child.Enabled = buttonsEnabled;
47 child.Children.ForEach(c => c.Enabled = buttonsEnabled);
49 if (Container ==
null) {
return; }
53 var indicatorStyle = buttonsEnabled ? indicatorStyleGreen : indicatorStyleRed;
54 if (containerIndicator.Style != indicatorStyle)
56 containerIndicator.ApplyStyle(indicatorStyle);
62 float x = 1.0f / (1 + RequiredSignalCount);
63 float y = Math.Min((x * paddedFrame.Rect.Width) / paddedFrame.Rect.Height, 0.5f);
64 Vector2 relativeSize =
new Vector2(x, y);
66 var containerSection =
new GUIFrame(
new RectTransform(
new Vector2(x, 1.0f), paddedFrame.RectTransform), style:
null);
67 var containerSlot =
new GUIFrame(
new RectTransform(
new Vector2(1.0f, y), containerSection.RectTransform, anchor:
Anchor.Center), style:
null);
68 containerHolder =
new GUIFrame(
new RectTransform(
new Vector2(1f, 1.2f), containerSlot.RectTransform,
Anchor.BottomCenter), style:
null);
69 containerIndicator =
new GUIImage(
new RectTransform(
new Vector2(0.5f, 0.5f * (1.0f - y)), containerSection.RectTransform, anchor:
Anchor.BottomCenter),
70 style:
"IndicatorLightRed", scaleToFit:
true);
72 for (
int i = 0; i < RequiredSignalCount; i++)
77 OnClicked = (button, userData) =>
79 int signalIndex = (int)userData;
86 item.CreateClientEvent(
this,
new EventData(signalIndex));
91 var image =
new GUIImage(
new RectTransform(Vector2.One, button.RectTransform), terminalButtonStyles[i], scaleToFit:
true);
97 OnItemLoadedProjSpecific();
100 partial
void OnItemLoadedProjSpecific()
102 if (Container ==
null) {
return; }
109 Write(msg, extraData);
static Character? Controlled
Action< GUIComponent > OnAddedToGUIUpdateList
RectTransform RectTransform
static bool IsSingleplayer
RectTransform RectTransform
If set, the inventory is automatically positioned inside the rect
virtual IEnumerable< Item > AllItems
All items contained in the inventory. Stacked items are returned as individual instances....
readonly ItemInventory Inventory
Interface for entities that the clients can send events to the server
int ReadRangedInteger(int min, int max)
Interface for entities that the server can send events to the clients