Пример #1
0
 private void OnGetState(EntityUid uid, RadarConsoleComponent component, ref ComponentGetState args)
 {
     args.State = new RadarConsoleComponentState()
     {
         Range = component.MaxRange
     };
 }
Пример #2
0
    protected override void UpdateState(RadarConsoleComponent component)
    {
        var xform  = Transform(component.Owner);
        var onGrid = xform.ParentUid == xform.GridUid;
        EntityCoordinates?coordinates = onGrid ? xform.Coordinates : null;
        Angle?            angle       = onGrid ? xform.LocalRotation : null;

        // Use ourself I guess.
        if (TryComp <IntrinsicUIComponent>(component.Owner, out var intrinsic))
        {
            foreach (var uiKey in intrinsic.UIs)
            {
                if (uiKey.Key?.Equals(RadarConsoleUiKey.Key) == true)
                {
                    coordinates = new EntityCoordinates(component.Owner, Vector2.Zero);
                    angle       = Angle.Zero;
                    break;
                }
            }
        }

        var radarState = new RadarConsoleBoundInterfaceState(
            component.MaxRange,
            coordinates,
            angle,
            new List <DockingInterfaceState>());

        _uiSystem.GetUiOrNull(component.Owner, RadarConsoleUiKey.Key)?.SetState(radarState);
    }
Пример #3
0
 private void OnHandleState(EntityUid uid, RadarConsoleComponent component, ref ComponentHandleState args)
 {
     if (args.Current is not RadarConsoleComponentState state)
     {
         return;
     }
     component.MaxRange = state.Range;
 }
Пример #4
0
 public void SetRange(RadarConsoleComponent component, float value)
 {
     if (component.MaxRange.Equals(value))
     {
         return;
     }
     component.MaxRange = value;
     Dirty(component);
     UpdateState(component);
 }
Пример #5
0
    protected override void UpdateState(RadarConsoleComponent component)
    {
        var xform = Transform(component.Owner);

        var onGrid = xform.ParentUid == xform.GridUid;

        var radarState = new RadarConsoleBoundInterfaceState(
            component.MaxRange,
            onGrid ? xform.Coordinates : null,
            onGrid ? xform.LocalRotation : null,
            new List <DockingInterfaceState>());

        _uiSystem.GetUiOrNull(component.Owner, RadarConsoleUiKey.Key)?.SetState(radarState);
    }
Пример #6
0
 private void OnRadarStartup(EntityUid uid, RadarConsoleComponent component, ComponentStartup args)
 {
     UpdateState(component);
 }
Пример #7
0
 protected virtual void UpdateState(RadarConsoleComponent component)
 {
 }