Esempio n. 1
0
            private void UpdateEntityRendering(TileEntity entity)
            {
                if (!entity)
                {
                    return;
                }

                int  renderedFloor   = tile.Map.RenderedFloor;
                bool renderEntireMap = tile.Map.RenderEntireMap;

                bool underground   = renderedFloor < 0;
                int  absoluteFloor = underground ? -renderedFloor + 1 : renderedFloor;
                int  relativeFloor = entity.Floor - absoluteFloor;
                bool renderFloor   = renderEntireMap || (relativeFloor <= 0 && relativeFloor > -3);

                if (renderFloor)
                {
                    float opacity = renderEntireMap ? 1f : tile.Map.GetRelativeFloorOpacity(relativeFloor);
                    MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
                    propertyBlock.SetColor(ShaderPropertyIds.Color, new Color(opacity, opacity, opacity));
                    Renderer[] renderers = entity.GetComponentsInChildren <Renderer>();
                    foreach (Renderer renderer in renderers)
                    {
                        renderer.SetPropertyBlock(propertyBlock);
                    }
                }
            }