예제 #1
0
        public override void OnBlockRemoved()
        {
            base.OnBlockRemoved();

            renderer?.Dispose();
            renderer = null;
        }
예제 #2
0
        public override void OnBlockRemoved()
        {
            base.OnBlockRemoved();

            if (renderer != null)
            {
                renderer.Unregister();
                renderer = null;
            }
        }
예제 #3
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            if (metalContent != null)
            {
                metalContent.ResolveBlockOrItem(api.World);
            }


            block = api.World.BlockAccessor.GetBlock(pos);
            if (block == null || block.Code == null || block.Attributes == null)
            {
                return;
            }

            fillHeight    = block.Attributes["fillHeight"].AsFloat(1);
            requiredUnits = block.Attributes["requiredUnits"].AsInt(100);

            if (block.Attributes["fillQuadsByLevel"].Exists)
            {
                fillQuadsByLevel = block.Attributes["fillQuadsByLevel"].AsObject <Cuboidf[]>();
            }


            if (fillQuadsByLevel == null)
            {
                fillQuadsByLevel = new Cuboidf[] { new Cuboidf(2, 0, 2, 14, 0, 14), };
            }

            if (api is ICoreClientAPI)
            {
                ICoreClientAPI capi = (ICoreClientAPI)api;



                capi.Event.RegisterRenderer(renderer = new ToolMoldRenderer(pos, capi, fillQuadsByLevel), EnumRenderStage.Opaque);

                UpdateRenderer();
            }

            RegisterGameTickListener(OnGameTick, 50);
        }