示例#1
0
        private void CancelTransformation(TransformableContainerComponent component)
        {
            component.CurrentReagent = null;
            component.Transformed    = false;

            if (EntityManager.TryGetComponent(component.Owner, out SpriteComponent? sprite) &&
                component.InitialSprite != null)
            {
                sprite.LayerSetSprite(0, component.InitialSprite);
            }

            EntityManager.GetComponent <MetaDataComponent>(component.Owner).EntityName        = component.InitialName;
            EntityManager.GetComponent <MetaDataComponent>(component.Owner).EntityDescription = component.InitialDescription;
        }
示例#2
0
        private void CancelTransformation(TransformableContainerComponent component)
        {
            component.CurrentReagent = null;
            component.Transformed    = false;

            if (component.Owner.TryGetComponent(out SpriteComponent? sprite) &&
                component.InitialSprite != null)
            {
                sprite.LayerSetSprite(0, component.InitialSprite);
            }

            component.Owner.Name        = component.InitialName;
            component.Owner.Description = component.InitialDescription;
        }
示例#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;
            }
        }