public static void UpdateStates(CircuitStatePacket packet) { foreach (var state in packet.States) { var netObj = NetObject.GetByNetId(state.Key.Key); if (netObj == null || !netObj.enabled) { continue; } var ios = netObj.GetComponentsInChildren <CircuitOutput>(); if (ios.Length <= state.Key.Value) { continue; } var io = ios[state.Key.Value]; CurrentlyUpdating = io; io.On = state.Value; } CurrentlyUpdating = null; HasCalledCircuitUpdate = true; }
public static void DoData(ComponentDataPacket packet) { var netObj = NetObject.GetByNetId(packet.NetID); if (netObj == null) { return; } switch (packet.ComponentType) { case ComponentType.Noisemaker: var noisemaker = netObj.GetComponentInChildren <Noisemaker>(); noisemaker.ToneFrequency = (float)packet.Data[0]; break; case ComponentType.Display: var display = netObj.GetComponentInChildren <Display>(); display.DisplayColor = (DisplayColor)packet.Data[0]; display.ForceVisualRefresh(); break; case ComponentType.Label: var label = netObj.GetComponent <Label>(); label.text.text = (string)packet.Data[0]; label.text.fontSize = (float)packet.Data[1]; break; } }
public static void DoPaint(PaintBoardPacket packet) { var obj = NetObject.GetByNetId(packet.BoardID).gameObject; var board = obj.GetComponent <CircuitBoard>(); board.SetBoardColor(packet.Color); }
public static void DoAction(UserInputPacket packet) { var obj = NetObject.GetByNetId(packet.NetID); CurrentlyActing.Add(packet.NetID); switch (packet.Receiver) { case UserInputPacket.UserInputReceiver.Button: DoButton(obj.GetComponentInChildren <Button>(), packet.State); break; case UserInputPacket.UserInputReceiver.Switch: DoSwitch(obj.GetComponentInChildren <Switch>(), packet.State); break; } CurrentlyActing.Remove(packet.NetID); }