Esempio n. 1
0
        void UpdateRenderer()
        {
            if (renderer == null)
            {
                return;
            }

            ItemStack contentStack = inputStack == null ? outputStack : inputStack;
            ItemStack prevStack    = renderer.ContentStack;

            bool useOldRenderer =
                renderer.ContentStack != null &&
                renderer.contentStackRenderer != null &&
                contentStack?.Collectible is IInFirepitRendererSupplier &&
                renderer.ContentStack.Equals(api.World, contentStack, GlobalConstants.IgnoredStackAttributes)
            ;

            if (useOldRenderer)
            {
                return;                 // Otherwise the cooking sounds restarts all the time
            }
            renderer.contentStackRenderer?.Dispose();
            renderer.contentStackRenderer = null;

            if (contentStack?.Collectible is IInFirepitRendererSupplier)
            {
                IInFirepitRenderer childrenderer = (contentStack.Collectible as IInFirepitRendererSupplier).GetRendererWhenInFirepit(contentStack, this, contentStack == outputStack);
                if (childrenderer != null)
                {
                    renderer.SetChildRenderer(contentStack, childrenderer);
                    return;
                }
            }

            InFirePitProps props = GetRenderProps(contentStack);

            if (contentStack?.Collectible != null && !(contentStack?.Collectible is IInFirepitMeshSupplier) && props != null)
            {
                renderer.SetContents(contentStack, props.Transform);
            }
            else
            {
                renderer.SetContents(null, null);
            }
        }
Esempio n. 2
0
        void UpdateRenderer()
        {
            if (renderer == null)
            {
                return;
            }

            ItemStack contentStack = inputStack == null ? outputStack : inputStack;
            ItemStack prevStack    = renderer.ContentStack;

            if (prevStack != null && prevStack.Equals(api.World, contentStack, GlobalConstants.IgnoredStackAttributes))
            {
                // But still update the stack for the temperature update
                renderer.ContentStack = contentStack;
                return;
            }

            renderer.contentStackRenderer?.Dispose();
            renderer.contentStackRenderer = null;

            if (contentStack?.Collectible is IInFirepitRendererSupplier)
            {
                IInFirepitRenderer childrenderer = (contentStack.Collectible as IInFirepitRendererSupplier).GetRendererWhenInFirepit(contentStack, this, contentStack == outputStack);
                if (childrenderer != null)
                {
                    renderer.SetChildRenderer(contentStack, childrenderer);
                    return;
                }
            }

            InFirePitProps props = GetRenderProps(contentStack);

            if (contentStack?.Collectible != null && !(contentStack?.Collectible is IInFirepitMeshSupplier) && (props == null || contentStack.Class == EnumItemClass.Item))
            {
                renderer.SetContents(contentStack, props?.Transform);
            }
            else
            {
                renderer.SetContents(null, null);
            }
        }