3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
6 using System.Collections.Generic;
18 const float RewireSoundDuration = 5.0f;
23 private float rewireSoundTimer;
25 private Point originalMaxSize;
26 private Vector2 originalRelativeSize;
32 partial
void InitProjSpecific()
44 CheckForLabelOverlap();
53 { AbsoluteOffset = GUIStyle.ItemFrameOffset }, style:
null);
58 rewireSoundTimer = RewireSoundDuration;
61 partial
void UpdateProjSpecific(
float deltaTime)
65 if (Rand.Range(0.0f, 500.0f) < 1.0f)
68 Vector2 baseVel =
new Vector2(0.0f, -100.0f);
69 for (
int i = 0; i < 5; i++)
73 if (particle !=
null) { particle.Size *= Rand.Range(0.5f, 1.0f); }
78 rewireSoundTimer -= deltaTime;
81 if (rewireSoundChannel ==
null || !rewireSoundChannel.
IsPlaying)
89 rewireSoundChannel =
null;
90 rewireSoundTimer = 0.0f;
94 public override void Move(Vector2 amount,
bool ignoreContacts =
false)
122 Connection.DrawConnections(spriteBatch,
this, dragArea.
Rect, user, out (Vector2 tooltipPos,
LocalizedString text) tooltip);
127 if (!tooltip.text.IsNullOrEmpty())
133 private void CheckForLabelOverlap()
137 if (Connection.CheckConnectionLabelOverlap(
this, out Point newRectSize))
139 int xCenter = (int)(GameMain.GraphicsWidth / 2.0f);
140 int maxNewWidth = 2 * Math.Min(xCenter - HUDLayoutSettings.CrewArea.Right, xCenter - HUDLayoutSettings.ChatBoxArea.Right);
141 int yCenter = (int)(GameMain.GraphicsHeight / 2.0f);
142 int maxNewHeight = 2 * Math.Min(yCenter - HUDLayoutSettings.MessageAreaTop.Bottom, HUDLayoutSettings.InventoryTopY - yCenter);
144 newRectSize =
new Point(Math.Min(newRectSize.X, maxNewWidth), Math.Min(newRectSize.Y, maxNewHeight));
160 byte connectionCount = msg.
ReadByte();
161 for (
int i = 0; i < connectionCount; i++)
164 for (
int j = 0; j < wireCount; j++)
169 ushort disconnectedWireCount = msg.
ReadUInt16();
170 for (
int i = 0; i < disconnectedWireCount; i++)
174 int msgLength = (int)(msg.
BitPosition - msgStartPos);
182 ApplyRemoteState(msg);
188 List<Wire> prevWires =
Connections.SelectMany(c => c.Wires).ToList();
199 base.IsActive =
true;
204 connection.ClearConnections();
207 byte connectionCount = msg.
ReadByte();
208 for (
int i = 0; i < connectionCount; i++)
210 HashSet<Wire> newWires =
new HashSet<Wire>();
212 for (
int j = 0; j < wireCount; j++)
215 if (Entity.FindEntityByID(wireId) is not
Item wireItem) {
continue; }
216 Wire wireComponent = wireItem.GetComponent<Wire>();
217 if (wireComponent ==
null) {
continue; }
219 newWires.Add(wireComponent);
226 Wire[] oldWires = connection.Wires.Where(w => !newWires.Contains(w)).ToArray();
227 foreach (var wire
in oldWires)
229 connection.DisconnectWire(wire);
232 foreach (var wire
in newWires.Where(w => !connection.Wires.Contains(w)).ToArray())
234 connection.ConnectWire(wire);
235 wire.TryConnect(connection,
false);
241 ushort disconnectedWireCount = msg.
ReadUInt16();
242 for (
int i = 0; i < disconnectedWireCount; i++)
245 if (!(Entity.FindEntityByID(wireId) is
Item wireItem)) {
continue; }
246 Wire wireComponent = wireItem.GetComponent<Wire>();
247 if (wireComponent ==
null) {
continue; }
249 base.IsActive =
true;
252 foreach (Wire wire
in prevWires)
254 bool connected = wire.Connections[0] !=
null || wire.Connections[1] !=
null;
260 if (connectionPanel !=
null && connectionPanel.DisconnectedWires.Contains(wire))
267 if (wire.Item.ParentInventory ==
null && !connected)
269 wire.Item.Drop(
null);
273 foreach (Wire disconnectedWire
in previousDisconnectedWires)
275 if (disconnectedWire.Connections[0] ==
null &&
276 disconnectedWire.Connections[1] ==
null &&
279 disconnectedWire.Item.Drop(dropper:
null);
Item????????? SelectedItem
The primary selected item. It can be any device that character interacts with. This excludes items li...
static Character? Controlled
Item SelectedSecondaryItem
The secondary selected item. It's an item other than a device (see SelectedItem), e....
static Entity FindEntityByID(ushort ID)
Find an entity based on the ID
void DrawToolTip(SpriteBatch spriteBatch)
Creates and draws a tooltip.
RectTransform RectTransform
GUIComponent that can be used to render custom content on the UI
static SubEditorScreen SubEditorScreen
static ParticleManager ParticleManager
static readonly List< Item > ItemList
static Wire HighlightedWire
readonly List< Connection > Connections
readonly HashSet< Wire > DisconnectedWires
Wires that have been disconnected from the panel, but not removed completely (visible at the bottom o...
void MoveConnectedWires(Vector2 amount)
static bool ShouldDebugDrawWiring
override void Move(Vector2 amount, bool ignoreContacts=false)
override void CreateGUI()
Overload this method and implement. The method is automatically called when the resolution changes.
void ClientEventRead(IReadMessage msg, float sendingTime)
static double DebugWiringEnabledUntil
void TriggerRewiringSound()
override void UpdateHUDComponentSpecific(Character character, float deltaTime, Camera cam)
static bool DebugWiringMode
ConnectionPanel(Item item, ContentXElement element)
override bool ShouldDrawHUD(Character character)
override bool RecreateGUIOnResolutionChange
void StartDelayedCorrection(IReadMessage buffer, float sendingTime, bool waitForMidRoundSync=false)
void Draw(SpriteBatch spriteBatch, RectangleF rect, Color color, SpriteEffects spriteEffects=SpriteEffects.None, Vector2? uvOffset=null)
Interface for entities that the clients can send events to the server
UInt32 ReadVariableUInt32()
Interface for entities that the server can send events to the clients