Example #1
0
        public void Populate(CrayonDecalPrototype proto)
        {
            var path = new ResourcePath(proto.SpritePath);

            _decals = new Dictionary <string, Texture>();
            foreach (var state in proto.Decals)
            {
                var rsi = new SpriteSpecifier.Rsi(path, state);
                _decals.Add(state, rsi.Frame0());
            }

            RefreshList();
        }
Example #2
0
    public RSI.State GetState(SpriteSpecifier.Rsi rsiSpecifier)
    {
        if (_resourceCache.TryGetResource <RSIResource>(
                SharedSpriteComponent.TextureRoot / rsiSpecifier.RsiPath,
                out var theRsi) &&
            theRsi.RSI.TryGetState(rsiSpecifier.RsiState, out var state))
        {
            return(state);
        }

        Logger.Error("Failed to load RSI {0}", rsiSpecifier.RsiPath);
        return(SpriteComponent.GetFallbackState(_resourceCache));
    }
Example #3
0
        private void OnSolutionChange(EntityUid owner, TransformableContainerComponent component,
                                      SolutionChangedEvent args)
        {
            if (!_solutionsSystem.TryGetFitsInDispenser(owner, out var solution))
            {
                return;
            }
            //Transform container into initial state when emptied
            if (component.CurrentReagent != null && solution.Contents.Count == 0)
            {
                CancelTransformation(component);
            }

            //the biggest reagent in the solution decides the appearance
            var reagentId = solution.GetPrimaryReagentId();

            //If biggest reagent didn't changed - don't change anything at all
            if (component.CurrentReagent != null && component.CurrentReagent.ID == reagentId)
            {
                return;
            }

            //Only reagents with spritePath property can change appearance of transformable containers!
            if (!string.IsNullOrWhiteSpace(reagentId) &&
                _prototypeManager.TryIndex(reagentId, out ReagentPrototype? proto) &&
                !string.IsNullOrWhiteSpace(proto.SpriteReplacementPath))
            {
                var spriteSpec =
                    new SpriteSpecifier.Rsi(
                        new ResourcePath("Objects/Consumable/Drinks/" + proto.SpriteReplacementPath), "icon");
                if (EntityManager.TryGetComponent(owner, out SpriteComponent? sprite))
                {
                    sprite?.LayerSetSprite(0, spriteSpec);
                }

                string val = proto.Name + " glass";
                EntityManager.GetComponent <MetaDataComponent>(owner).EntityName        = val;
                EntityManager.GetComponent <MetaDataComponent>(owner).EntityDescription = proto.Description;
                component.CurrentReagent = proto;
                component.Transformed    = true;
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
            {
                var gasPrototype = _prototypeManager.Index <GasPrototype>(i.ToString());
                GasPrototypes[i] = gasPrototype;

                if (string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayTexture))
                {
                    _gasOverlays[i] = new SpriteSpecifier.Texture(new ResourcePath(gasPrototype.GasOverlayTexture));
                }

                if (!string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayState))
                {
                    _gasOverlays[i] = new SpriteSpecifier.Rsi(new ResourcePath(gasPrototype.GasOverlaySprite), gasPrototype.GasOverlayState);
                }
            }
        }
Example #5
0
        static Atmospherics()
        {
            var protoMan = IoCManager.Resolve <IPrototypeManager>();

            GasPrototypes = new GasPrototype[TotalNumberOfGases];
            GasOverlays   = new SpriteSpecifier[TotalNumberOfGases];

            for (var i = 0; i < TotalNumberOfGases; i++)
            {
                var gasPrototype = protoMan.Index <GasPrototype>(i.ToString());
                GasPrototypes[i] = gasPrototype;

                if (string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayTexture))
                {
                    GasOverlays[i] = new SpriteSpecifier.Texture(new ResourcePath(gasPrototype.GasOverlayTexture));
                }

                if (!string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayState))
                {
                    GasOverlays[i] = new SpriteSpecifier.Rsi(new ResourcePath(gasPrototype.GasOverlaySprite), gasPrototype.GasOverlayState);
                }
            }
        }
Example #6
0
        void ISolutionChange.SolutionChanged(SolutionChangeEventArgs eventArgs)
        {
            var solution = eventArgs.Owner.GetComponent <SolutionContainerComponent>();

            //Transform container into initial state when emptied
            if (_currentReagent != null && solution.ReagentList.Count == 0)
            {
                CancelTransformation();
            }

            //the biggest reagent in the solution decides the appearance
            var reagentId = solution.Solution.GetPrimaryReagentId();

            //If biggest reagent didn't changed - don't change anything at all
            if (_currentReagent != null && _currentReagent.ID == reagentId)
            {
                return;
            }

            //Only reagents with spritePath property can change appearance of transformable containers!
            if (!string.IsNullOrWhiteSpace(reagentId) &&
                _prototypeManager.TryIndex(reagentId, out ReagentPrototype? proto) &&
                !string.IsNullOrWhiteSpace(proto.SpriteReplacementPath))
            {
                var spriteSpec = new SpriteSpecifier.Rsi(new ResourcePath("Objects/Consumable/Drinks/" + proto.SpriteReplacementPath), "icon");

                if (Owner.TryGetComponent(out SpriteComponent? sprite))
                {
                    sprite?.LayerSetSprite(0, spriteSpec);
                }

                Owner.Name        = proto.Name + " glass";
                Owner.Description = proto.Description;
                _currentReagent   = proto;
                Transformed       = true;
            }
        }
        public LateJoinGui()
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("Late Join");

            var jobList = new VBoxContainer();
            var vBox    = new VBoxContainer
            {
                Children =
                {
                    new ScrollContainer
                    {
                        SizeFlagsVertical = SizeFlags.FillExpand,
                        Children          =
                        {
                            jobList
                        }
                    }
                }
            };

            Contents.AddChild(vBox);

            foreach (var job in _prototypeManager.EnumeratePrototypes <JobPrototype>().OrderBy(j => j.Name))
            {
                var jobButton = new JobButton
                {
                    JobId = job.ID
                };

                var jobSelector = new HBoxContainer
                {
                    SizeFlagsHorizontal = SizeFlags.FillExpand
                };

                var icon = new TextureRect
                {
                    TextureScale = (2, 2),
                    Stretch      = TextureRect.StretchMode.KeepCentered
                };

                if (job.Icon != null)
                {
                    var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), job.Icon);
                    icon.Texture = specifier.Frame0();
                }
                jobSelector.AddChild(icon);

                var jobLabel = new Label
                {
                    Text = job.Name
                };

                jobSelector.AddChild(jobLabel);

                jobButton.AddChild(jobSelector);
                jobList.AddChild(jobButton);
                jobButton.OnPressed += args =>
                {
                    SelectedId?.Invoke(jobButton.JobId);
                };
            }

            SelectedId += jobId =>
            {
                Logger.InfoS("latejoin", $"Late joining as ID: {jobId}");
                _console.ProcessCommand($"joingame {CommandParsing.Escape(jobId)}");
                Close();
            };
        }