private void OnStateChange(TabState newState)
    {
        //Important: if you get NREs out of nowhere, make sure your server code doesn't accidentally run on client as well
        if (!IsServer)
        {
            return;
        }
        switch (newState)
        {
        case TabState.Normal:
            PowerOff();
            StartNormalOperation();
            //Important: set values from server using SetValue and not Value
            this["OffOverlay"].SetValue   = DebugTools.ColorToHex(Color.clear);
            this["Rulers"].SetValue       = rulersColor;
            this["RadarScanRay"].SetValue = rayColor;
            this["Crosshair"].SetValue    = crosshairColor;
            SetSafetyProtocols(@on: true);

            break;

        case TabState.Emagged:
            PowerOff();
            StartNormalOperation();
            //Remove overlay
            this["OffOverlay"].SetValue = DebugTools.ColorToHex(Color.clear);
            //Repaint radar to evil colours
            this["Rulers"].SetValue       = ChangeColorHue(rulersColor, -80);
            this["RadarScanRay"].SetValue = ChangeColorHue(rayColor, -80);
            this["Crosshair"].SetValue    = ChangeColorHue(crosshairColor, -80);
            AddEmagItems();
            SetSafetyProtocols(@on: false);

            break;

        case TabState.Off:
            PowerOff();
            //Black screen overlay
            this["OffOverlay"].SetValue = DebugTools.ColorToHex(Color.black);
            SetSafetyProtocols(@on: true);

            break;

        default:
            return;
        }
    }
Beispiel #2
0
    private void UpdateScreenDisplay()
    {
        if (LocalAPC.State != APC.APCState.Dead)
        {
            OffOverlayColor.SetValue = DebugTools.ColorToHex(Color.clear);
            Logger.LogTrace("Updating APC display", Category.NetUI);
            // Update the electrical values
            float voltage    = LocalAPC.Voltage;
            float current    = LocalAPC.Current;
            float resistance = LocalAPC.Resistance;
            float power      = voltage * current;
            ElectricalValues.SetValue = $"{voltage:G4} V\n{current:G4} A\n{power:G4} W";
            StatusText.SetValue       = LocalAPC.State.ToString();
            ChargePercentage.SetValue = CalculateChargePercentage();

            // State specific updates
            switch (LocalAPC.State)
            {
            case APC.APCState.Full:
                BackgroundColor.SetValue = fullBackground;
                UpdateForegroundColours(fullForeground);
                ChargeBar.SetValue = "100";
                break;

            case APC.APCState.Charging:
                BackgroundColor.SetValue = chargingBackground;
                UpdateForegroundColours(chargingForeground);
                AnimateChargeBar();
                break;

            case APC.APCState.Critical:
                BackgroundColor.SetValue = criticalBackground;
                UpdateForegroundColours(criticalForeground);
                ChargeBar.SetValue = "0";
                break;
            }
        }
        else
        {
            BackgroundColor.SetValue = DebugTools.ColorToHex(Color.clear);             // Also changing the background since it bleeds through on the edges
            OffOverlayColor.SetValue = DebugTools.ColorToHex(Color.black);
        }
    }
Beispiel #3
0
    private void UpdateScreenDisplay()
    {
        if (LocalAPC.State != APC.APCState.Dead)
        {
            OffOverlayColor.SetValue = DebugTools.ColorToHex(Color.clear);
            Logger.LogTrace("Updating APC display", Category.NetUI);
            // Display the electrical values using engineering notation
            string voltage = LocalAPC.Voltage.ToEngineering("V");
            string current = LocalAPC.Current.ToEngineering("A");
            string power   = (LocalAPC.Voltage * LocalAPC.Current).ToEngineering("W");
            ElectricalValues.SetValue = $"{voltage}\n{current}\n{power}";
            StatusText.SetValue       = LocalAPC.State.ToString();
            ChargePercentage.SetValue = CalculateChargePercentage();
            // State specific updates
            switch (LocalAPC.State)
            {
            case APC.APCState.Full:
                BackgroundColor.SetValue = fullBackground;
                UpdateForegroundColours(fullForeground);
                ChargeBar.SetValue = "100";
                break;

            case APC.APCState.Charging:
                BackgroundColor.SetValue = chargingBackground;
                UpdateForegroundColours(chargingForeground);
                AnimateChargeBar();
                break;

            case APC.APCState.Critical:
                BackgroundColor.SetValue = criticalBackground;
                UpdateForegroundColours(criticalForeground);
                ChargeBar.SetValue = "0";
                break;
            }
        }
        else
        {
            BackgroundColor.SetValue = DebugTools.ColorToHex(Color.clear);             // Also changing the background since it bleeds through on the edges
            OffOverlayColor.SetValue = DebugTools.ColorToHex(Color.black);
        }
    }
 private static string ChangeColorHue(string srcHexColour, int amount)
 {
     return(DebugTools.ColorToHex(HSVUtil.ChangeColorHue(DebugTools.HexToColor(srcHexColour), amount)));
 }