Ejemplo n.º 1
0
        public void OnUpdate()
        {
            if (!_powered)
            {
                //TODO:If someone cuts power currently, microwave magically keeps going. FIX IT!
                SetAppearance(MicrowaveVisualState.Idle);
            }

            if (_busy && !_powered)
            {
                //we lost power while we were cooking/busy!
                _lostPower = true;
                VaporizeReagents();
                EjectSolids();
                _busy    = false;
                _uiDirty = true;
            }

            if (_uiDirty)
            {
                _userInterface.SetState(new MicrowaveUpdateUserInterfaceState
                                        (
                                            _solution.Solution.Contents.ToArray(),
                                            _storage.ContainedEntities.Select(item => item.Uid).ToArray(),
                                            _busy,
                                            _currentCookTimeButtonIndex,
                                            _currentCookTimerTime
                                        ));
                _uiDirty = false;
            }
        }
        public void OnUpdate()
        {
            var newState = CalcChargeState();

            if (newState != LastChargeState)
            {
                LastChargeState = newState;
                Appearance.SetData(ApcVisuals.ChargeState, newState);
            }

            var newCharge = Storage.Charge;

            if (newCharge != _lastCharge)
            {
                _lastCharge = newCharge;
                _uiDirty    = true;
            }

            var extPowerState = CalcExtPowerState();

            if (extPowerState != _lastExternalPowerState)
            {
                _lastExternalPowerState = extPowerState;
                _uiDirty = true;
            }

            if (_uiDirty)
            {
                _userInterface.SetState(new ApcBoundInterfaceState(_provider.MainBreaker, extPowerState,
                                                                   newCharge / Storage.Capacity));
                _uiDirty = false;
            }
        }
Ejemplo n.º 3
0
        private void UpdateUserInterface()
        {
            var isPrivilegedIdPresent = _privilegedIdContainer.ContainedEntity != null;
            var targetIdEntity        = _targetIdContainer.ContainedEntity;
            IdCardConsoleBoundUserInterfaceState newState;

            // this could be prettier
            if (targetIdEntity == null)
            {
                newState = new IdCardConsoleBoundUserInterfaceState(
                    isPrivilegedIdPresent,
                    PrivilegedIdIsAuthorized(),
                    false,
                    null,
                    null,
                    null);
            }
            else
            {
                var targetIdComponent     = targetIdEntity.GetComponent <IdCardComponent>();
                var targetAccessComponent = targetIdEntity.GetComponent <AccessComponent>();
                newState = new IdCardConsoleBoundUserInterfaceState(
                    isPrivilegedIdPresent,
                    PrivilegedIdIsAuthorized(),
                    true,
                    targetIdComponent.FullName,
                    targetIdComponent.JobTitle,
                    targetAccessComponent.Tags);
            }
            _userInterface.SetState(newState);
        }
Ejemplo n.º 4
0
        public void Update()
        {
            var newState = CalcChargeState();

            if (newState != _lastChargeState && _lastChargeStateChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime)
            {
                _lastChargeState       = newState;
                _lastChargeStateChange = _gameTiming.CurTime;
                _appearance.SetData(ApcVisuals.ChargeState, newState);
            }
            var newCharge = Battery.CurrentCharge;

            if (newCharge != _lastCharge && _lastChargeChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime)
            {
                _lastCharge       = newCharge;
                _lastChargeChange = _gameTiming.CurTime;
                _uiDirty          = true;
            }
            var extPowerState = CalcExtPowerState();

            if (extPowerState != _lastExternalPowerState && _lastExternalPowerStateChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime)
            {
                _lastExternalPowerState       = extPowerState;
                _lastExternalPowerStateChange = _gameTiming.CurTime;
                _uiDirty = true;
            }
            if (_uiDirty)
            {
                _userInterface.SetState(new ApcBoundInterfaceState(MainBreakerEnabled, extPowerState, newCharge / Battery.MaxCharge));
                _uiDirty = false;
            }
        }
        private void UpdateUserInterface()
        {
            if (!Powered)
            {
                return;
            }
            var newState = GetUserInterfaceState();

            _userInterface.SetState(newState);
        }
Ejemplo n.º 6
0
 private void UpdateUserInterface(bool initialUpdate = false)
 {
     _userInterface?.SetState(
         new GasTankBoundUserInterfaceState
     {
         TankPressure        = Air?.Pressure ?? 0,
         OutputPressure      = initialUpdate ? OutputPressure : (float?)null,
         InternalsConnected  = IsConnected,
         CanConnectInternals = IsFunctional && GetInternalsComponent() != null
     });
 }
Ejemplo n.º 7
0
        private void UpdateUserInterface()
        {
            var solidsVisualList = new List <EntityUid>();

            foreach (var item in _storage.ContainedEntities)
            {
                solidsVisualList.Add(item.Uid);
            }

            _userInterface.SetState(new MicrowaveUpdateUserInterfaceState(_solution.Solution.Contents, solidsVisualList, _busy));
        }
Ejemplo n.º 8
0
 void IActivate.Activate(ActivateEventArgs eventArgs)
 {
     if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
     {
         return;
     }
     if (actor.playerSession.AttachedEntity.TryGetComponent(out BodyManagerComponent attempt))
     {
         _userInterface.SetState(PrepareBodyScannerInterfaceState(attempt.Template, attempt.PartDictionary));
     }
     _userInterface.Open(actor.playerSession);
 }
Ejemplo n.º 9
0
        private void UpdatePDAUserInterface()
        {
            var ownerInfo = new PDAIdInfoText
            {
                ActualOwnerName = OwnerMob?.Name,
                IdOwner         = ContainedID?.FullName,
                JobTitle        = ContainedID?.JobTitle
            };

            //Do we have an account? If so provide the info.
            if (_syndicateUplinkAccount != null)
            {
                var accData  = new UplinkAccountData(_syndicateUplinkAccount.AccountHolder, _syndicateUplinkAccount.Balance);
                var listings = _uplinkManager.FetchListings.ToArray();
                _interface.SetState(new PDAUpdateState(_lightOn, ownerInfo, accData, listings));
            }
            else
            {
                _interface.SetState(new PDAUpdateState(_lightOn, ownerInfo));
            }

            UpdatePDAAppearance();
        }
Ejemplo n.º 10
0
        private void HandleUIMessage(ServerBoundUserInterfaceMessage message)
        {
            switch (message.Message)
            {
            case GeneratorStatusRequestMessage _:
                _userInterface.SetState(new GeneratorState(Status == GravityGeneratorStatus.On));
                break;

            case SwitchGeneratorMessage msg:
                _switchedOn = msg.On;
                UpdateState();
                break;

            default:
                break;
            }
        }
        private void UpdateUserInterface()
        {
            var state = GetUserInterfaceState();

            _userInterface.SetState(state);
        }
 public void UpdateUserInterface()
 {
     _userInterface?.SetState(GetNewUiState());
 }
 private void UpdateBoundInterface()
 {
     _userInterface.SetState(new CommunicationsConsoleInterfaceState(RoundEndSystem.ExpectedCountdownEnd));
 }
Ejemplo n.º 14
0
 private void UpdateUserInterface()
 {
     _userInterface.SetState(new PaperBoundUserInterfaceState(_content, _mode));
 }
 /// <summary>
 ///    Sync bank account information
 /// </summary>
 public void SetState(int id, string name, int balance)
 {
     _userInterface.SetState(new CargoConsoleInterfaceState(_requestOnly, id, name, balance));
 }
 public void UpdateUIState()
 {
     _userInterface.SetState(new SolarControlConsoleBoundInterfaceState(_powerSolarSystem.TargetPanelRotation, _powerSolarSystem.TargetPanelVelocity, _powerSolarSystem.TotalPanelPower, _powerSolarSystem.TowardsSun));
 }
Ejemplo n.º 17
0
        private void UpdateUserInterface()
        {
            string?error = null;

            // Check if the player is still holding the gas analyzer => if not, don't update
            foreach (var session in _userInterface.SubscribedSessions)
            {
                if (session.AttachedEntity == null)
                {
                    return;
                }

                if (!session.AttachedEntity.TryGetComponent(out IHandsComponent handsComponent))
                {
                    return;
                }

                var activeHandEntity = handsComponent?.GetActiveHand?.Owner;
                if (activeHandEntity == null || !activeHandEntity.TryGetComponent(out GasAnalyzerComponent gasAnalyzer))
                {
                    return;
                }
            }

            var pos = Owner.Transform.GridPosition;

            if (!_checkPlayer && _position.HasValue)
            {
                // Check if position is out of range => don't update
                if (!_position.Value.InRange(_mapManager, pos, SharedInteractionSystem.InteractionRange))
                {
                    return;
                }

                pos = _position.Value;
            }

            var gam  = EntitySystem.Get <AtmosphereSystem>().GetGridAtmosphere(pos.GridID);
            var tile = gam?.GetTile(pos).Air;

            if (tile == null)
            {
                error = "No Atmosphere!";
                _userInterface.SetState(
                    new GasAnalyzerBoundUserInterfaceState(
                        0,
                        0,
                        null,
                        error));
                return;
            }

            var gases = new List <GasEntry>();

            for (int i = 0; i < Atmospherics.TotalNumberOfGases; i++)
            {
                var gas = Atmospherics.GetGas(i);

                if (tile.Gases[i] <= Atmospherics.GasMinMoles)
                {
                    continue;
                }

                gases.Add(new GasEntry(gas.Name, tile.Gases[i], gas.Color));
            }

            _userInterface.SetState(
                new GasAnalyzerBoundUserInterfaceState(
                    tile.Pressure,
                    tile.Temperature,
                    gases.ToArray(),
                    error));
        }