public TextureAtlasPosition this[string textureCode] { get { if (contentTextPos == null) { int textureSubId; textureSubId = ObjectCacheUtil.GetOrCreate <int>(capi, "contenttexture-" + contentTexture.ToString() + "-" + contentTexture.Alpha, () => { TextureAtlasPosition texPos; int id = 0; BitmapRef bmp = capi.Assets.TryGet(contentTexture.Base.Clone().WithPathPrefixOnce("textures/").WithPathAppendixOnce(".png"))?.ToBitmap(capi); if (bmp != null) { if (contentTexture.Alpha != 255) { bmp.MulAlpha(contentTexture.Alpha); } capi.BlockTextureAtlas.InsertTexture(bmp, out id, out texPos); bmp.Dispose(); } return(id); }); contentTextPos = capi.BlockTextureAtlas.Positions[textureSubId]; } return(contentTextPos); } }
public TextureAtlasPosition this[string textureCode] { get { if (textureCode == "topper" && corkTextPos != null) { return(corkTextPos); } if (textureCode == "glass" && blockTextPos != null) { return(blockTextPos); } if (textureCode == "bracing" && bracingTextPos != null) { return(bracingTextPos); } if (contentTextPos == null) { int textureSubId; textureSubId = ObjectCacheUtil.GetOrCreate <int>(capi, "contenttexture-" + contentTexture.ToString(), () => { TextureAtlasPosition texPos; int id = 0; BitmapRef bmp = capi.Assets.TryGet(contentTexture.Base.Clone().WithPathPrefixOnce("textures/").WithPathAppendixOnce(".png"))?.ToBitmap(capi); if (bmp != null) { capi.BlockTextureAtlas.InsertTexture(bmp, out id, out texPos); bmp.Dispose(); } return(id); }); contentTextPos = capi.BlockTextureAtlas.Positions[textureSubId]; } return(contentTextPos); } }