private void UpdateUserInterface(EntityUid uid, CrewMonitoringConsoleComponent?component = null)
        {
            if (!Resolve(uid, ref component))
            {
                return;
            }

            var ui = component.Owner.GetUIOrNull(CrewMonitoringUIKey.Key);

            if (ui == null)
            {
                return;
            }

            // update all sensors info
            var allSensors = component.ConnectedSensors.Values.ToList();
            var uiState    = new CrewMonitoringState(allSensors);

            ui.SetState(uiState);
        }
示例#2
0
        private void UpdateUserInterface(EntityUid uid, CrewMonitoringConsoleComponent?component = null)
        {
            if (!Resolve(uid, ref component))
            {
                return;
            }

            var ui = component.Owner.GetUIOrNull(CrewMonitoringUIKey.Key);

            if (ui == null)
            {
                return;
            }

            // For directional arrows, we need to fetch the monitor's transform data
            var xform = Transform(uid);

            var(worldPos, worldRot) = xform.GetWorldPositionRotation();

            // In general, the directions displayed depend on either the orientation of the grid, or the orientation of
            // the monitor. But in the special case where the monitor IS a player (i.e., admin ghost), we base it off
            // the players eye rotation. We don't know what that is for sure, but we know their last grid angle, which
            // should work well enough?
            if (TryComp(uid, out InputMoverComponent? mover))
            {
                worldRot = mover.LastGridAngle;
            }
            else if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
            {
                worldRot = grid.WorldRotation;
            }

            // update all sensors info
            var allSensors = component.ConnectedSensors.Values.ToList();
            var uiState    = new CrewMonitoringState(allSensors, worldPos, worldRot, component.Snap, component.Precision);

            ui.SetState(uiState);
        }