private void UpdateUi(EntityUid uid, ConfigurationComponent component)
 {
     if (_uiSystem.TryGetUi(uid, ConfigurationUiKey.Key, out var ui))
     {
         ui.SetState(new ConfigurationBoundUserInterfaceState(component.Config));
     }
 }
        private List <ConfigurationComponent> ExtractValidComponents(ConfigurationWriteModel model)
        {
            var components       = compRepo.GetAllById(model.Components.Select(cmp => cmp.Id).ToArray());
            var configComponents = new List <ConfigurationComponent>();

            foreach (var item in components)
            {
                var quantity = model.Components.First(cmp => cmp.Id == item.Id).Quantity;
                var cfgCmp   = new ConfigurationComponent(item, quantity);
                configComponents.Add(cfgCmp);
            }

            return(configComponents);
        }
    private void OnInteractUsing(EntityUid uid, ConfigurationComponent component, InteractUsingEvent args)
    {
        if (args.Handled)
        {
            return;
        }

        if (!TryComp(args.Used, out ToolComponent? tool) || !tool.Qualities.Contains(component.QualityNeeded))
        {
            return;
        }

        if (!TryComp(args.User, out ActorComponent? actor))
        {
            return;
        }

        args.Handled = _uiSystem.TryOpen(uid, ConfigurationUiKey.Key, actor.PlayerSession);
    }
    private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args)
    {
        foreach (var key in component.Config.Keys)
        {
            var value = args.Config.GetValueOrDefault(key);

            if (string.IsNullOrWhiteSpace(value) || component.Validation != null && !component.Validation.IsMatch(value))
            {
                continue;
            }

            component.Config[key] = value;
        }

        UpdateUi(uid, component);

        // TODO raise event.
        // TODO support float (spinbox) and enum (drop-down) configurations
        // TODO support verbs.
    }
示例#5
0
 public Worker(ILogger <Worker> logger, ConfigurationComponent configuration)
 {
     this._configuration = configuration;
     _logger             = logger;
 }
示例#6
0
 public NotificationGateway(ConfigurationComponent configurationComponent)
 {
     this.configurationComponent = configurationComponent;
 }
 private void OnStartup(EntityUid uid, ConfigurationComponent component, ComponentStartup args)
 {
     UpdateUi(uid, component);
 }
示例#8
0
 public OwlveyGateway(ConfigurationComponent configurationComponent)
 {
     this.configurationComponent = configurationComponent;
 }