3 using Microsoft.Xna.Framework;
5 using System.Collections.Generic;
22 foreach (var subElement
in element.
Elements())
24 switch (subElement.Name.ToString().ToLowerInvariant())
26 case "pumpoutemitter":
27 pumpOutEmitters.Add((subElement.GetAttributeVector2(
"position", Vector2.Zero),
new ParticleEmitter(subElement)));
30 pumpInEmitters.Add((subElement.GetAttributeVector2(
"position", Vector2.Zero),
new ParticleEmitter(subElement)));
39 RelativeOffset = new Vector2(0, 0.04f)
43 float powerButtonSize = 1f;
44 var powerArea =
new GUIFrame(
new RectTransform(
new Vector2(0.3f, 1) * powerButtonSize, paddedFrame.RectTransform,
Anchor.CenterLeft), style:
null);
45 var paddedPowerArea =
new GUIFrame(
new RectTransform(
new Vector2(0.9f, 0.8f), powerArea.RectTransform,
Anchor.Center), style:
"PowerButtonFrame");
46 var powerLightArea =
new GUIFrame(
new RectTransform(
new Vector2(0.87f, 0.2f), powerArea.RectTransform,
Anchor.TopRight), style:
null);
47 powerLight =
new GUITickBox(
new RectTransform(Vector2.One, powerLightArea.RectTransform,
Anchor.Center),
48 TextManager.Get(
"PowerLabel"), font: GUIStyle.SubHeadingFont, style:
"IndicatorLightPower")
54 PowerButton =
new GUIButton(
new RectTransform(
new Vector2(0.8f, 0.75f), paddedPowerArea.RectTransform,
Anchor.TopCenter)
56 RelativeOffset = new Vector2(0, 0.1f)
57 }, style:
"PowerButton")
60 OnClicked = (button, data) =>
64 if (GameMain.Client !=
null)
67 item.CreateClientEvent(
this);
74 var rightArea =
new GUIFrame(
new RectTransform(
new Vector2(0.65f, 1), paddedFrame.RectTransform,
Anchor.CenterRight), style:
null);
76 autoControlIndicator =
new GUITickBox(
new RectTransform(
new Vector2(1.0f, 0.25f), rightArea.RectTransform,
Anchor.TopLeft),
77 TextManager.Get(
"PumpAutoControl",
"ReactorAutoControl"), font: GUIStyle.SubHeadingFont, style:
"IndicatorLightYellow")
81 ToolTip = TextManager.Get(
"AutoControlTip")
86 var sliderArea =
new GUIFrame(
new RectTransform(
new Vector2(1, 0.65f), rightArea.RectTransform,
Anchor.BottomLeft), style:
null);
87 var pumpSpeedText =
new GUITextBlock(
new RectTransform(
new Vector2(1, 0.3f), sliderArea.RectTransform,
Anchor.TopLeft),
"",
88 textColor: GUIStyle.TextColorNormal, textAlignment: Alignment.CenterLeft, wrap:
false, font: GUIStyle.SubHeadingFont)
90 AutoScaleHorizontal =
true
92 LocalizedString pumpSpeedStr = TextManager.Get(
"PumpSpeed");
93 pumpSpeedText.TextGetter = () => {
return TextManager.AddPunctuation(
':', pumpSpeedStr, (
int)Math.Round(flowPercentage) +
" %"); };
94 pumpSpeedSlider =
new GUIScrollBar(
new RectTransform(
new Vector2(1, 0.35f), sliderArea.RectTransform,
Anchor.Center), barSize: 0.1f, style:
"DeviceSlider")
97 OnMoved = (GUIScrollBar scrollBar,
float barScroll) =>
99 if (pumpSpeedLockTimer <= 0.0f)
103 float newValue = barScroll * 200.0f - 100.0f;
108 if (GameMain.Client !=
null)
111 item.CreateClientEvent(
this);
117 var textsArea =
new GUIFrame(
new RectTransform(
new Vector2(1, 0.25f), sliderArea.RectTransform,
Anchor.BottomCenter), style:
null);
118 var outLabel =
new GUITextBlock(
new RectTransform(
new Vector2(0.5f, 1.0f), textsArea.RectTransform,
Anchor.CenterLeft), TextManager.Get(
"PumpOut"),
119 textColor: GUIStyle.TextColorNormal, textAlignment: Alignment.CenterLeft, wrap:
false, font: GUIStyle.SubHeadingFont);
120 var inLabel =
new GUITextBlock(
new RectTransform(
new Vector2(0.5f, 1.0f), textsArea.RectTransform,
Anchor.CenterRight), TextManager.Get(
"PumpIn"),
121 textColor: GUIStyle.TextColorNormal, textAlignment: Alignment.CenterRight, wrap:
false, font: GUIStyle.SubHeadingFont);
122 GUITextBlock.AutoScaleAndNormalize(outLabel, inLabel);
128 if (pumpSpeedSlider !=
null)
130 pumpSpeedSlider.
BarScroll = (flowPercentage + 100.0f) / 200.0f;
134 partial
void UpdateProjSpecific(
float deltaTime)
138 foreach (var (position, emitter) in pumpOutEmitters)
148 relativeParticlePos.X = -relativeParticlePos.X;
149 angle += MathHelper.Pi;
153 relativeParticlePos.Y = -relativeParticlePos.Y;
157 velocityMultiplier: MathHelper.Lerp(0.5f, 1.0f, -
FlowPercentage / 100.0f));
162 foreach (var (position, emitter) in pumpInEmitters)
169 relativeParticlePos.X = -relativeParticlePos.X;
170 angle += MathHelper.Pi;
174 relativeParticlePos.Y = -relativeParticlePos.Y;
177 velocityMultiplier: MathHelper.Lerp(0.5f, 1.0f,
FlowPercentage / 100.0f));
182 private float flickerTimer;
183 private readonly
float flickerFrequency = 1;
195 flickerTimer += deltaTime;
196 if (flickerTimer > flickerFrequency)
211 if (Math.Abs(pumpSpeedScroll - pumpSpeedSlider.
BarScroll) > 0.01f)
213 pumpSpeedSlider.
BarScroll = pumpSpeedScroll;
IEnumerable< ContentXElement > Elements()
RectTransform RectTransform
void OverrideTextColor(Color color)
Overrides the color for all the states.
bool AutoScaleHorizontal
When enabled, the text is automatically scaled down to fit the textblock horizontally.
void StartDelayedCorrection(IReadMessage buffer, float sendingTime, bool waitForMidRoundSync=false)
const float CorrectionDelay
void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData=null)
override void UpdateHUDComponentSpecific(Character character, float deltaTime, Camera cam)
override void OnItemLoaded()
Called when all the components of the item have been loaded. Use to initialize connections between co...
void ClientEventRead(IReadMessage msg, float sendingTime)
Highlights an UI element of some kind. Generally used in tutorials.
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
void WriteRangedInteger(int val, int min, int max)
void WriteBoolean(bool val)