public override void OnCollectTextures(ICoreAPI api, ITextureLocationDictionary textureDict) { base.OnCollectTextures(api, textureDict); climateColorMapInt = Attributes["climateColorMapForMap"].AsString(); seasonColorMapInt = Attributes["seasonColorMapForMap"].AsString(); }
/// <summary> /// Called by the texture atlas manager when building up the block atlas. Has to add all of the blocks textures /// </summary> public virtual void BakeAndCollect(IAssetManager manager, ITextureLocationDictionary mainTextureDict, AssetLocation sourceCode, string sourceMessage) { if (alreadyBaked) { return; } foreach (var ct in Values) { ct.Bake(manager); if (ct.Baked.BakedVariants != null) { BakedCompositeTexture[] bct = ct.Baked.BakedVariants; for (int i = 0; i < bct.Length; i++) { if (!mainTextureDict.ContainsKey(bct[i].BakedName)) { mainTextureDict.AddTextureLocation_Checked(new AssetLocationAndSource(bct[i].BakedName, sourceMessage, sourceCode, i + 1)); } } continue; } if (!mainTextureDict.ContainsKey(ct.Baked.BakedName)) { mainTextureDict.AddTextureLocation_Checked(new AssetLocationAndSource(ct.Baked.BakedName, sourceMessage, sourceCode)); } } alreadyBaked = true; }
public override void OnCollectTextures(ICoreAPI api, ITextureLocationDictionary textureDict) { base.OnCollectTextures(api, textureDict); climateColorMapInt = ClimateColorMap; seasonColorMapInt = SeasonColorMap; if (api.Side == EnumAppSide.Client && SeasonColorMap == null) { climateColorMapInt = (api as ICoreClientAPI).TesselatorManager.GetCachedShape(Shape.Base)?.Elements[2].ClimateColorMap; seasonColorMapInt = (api as ICoreClientAPI).TesselatorManager.GetCachedShape(Shape.Base)?.Elements[2].SeasonColorMap; } }
public override void OnCollectTextures(ICoreAPI api, ITextureLocationDictionary textureDict) { base.OnCollectTextures(api, textureDict); climateColorMapInt = ClimateColorMap; seasonColorMapInt = SeasonColorMap; // Branchy leaves if (api.Side == EnumAppSide.Client && SeasonColorMap == null) { climateColorMapInt = (api as ICoreClientAPI).TesselatorManager.GetCachedShape(Shape.Base)?.Elements[0].ClimateColorMap; seasonColorMapInt = (api as ICoreClientAPI).TesselatorManager.GetCachedShape(Shape.Base)?.Elements[0].SeasonColorMap; } moveIndex7Up = TileSideEnum.MoveIndex[TileSideEnum.Up] * 7; }
// We need the tool item textures also in the block atlas public override void OnCollectTextures(ICoreAPI api, ITextureLocationDictionary textureDict) { base.OnCollectTextures(api, textureDict); for (int i = 0; i < api.World.Items.Count; i++) { Item item = api.World.Items[i]; if (item.Tool == null && item.Attributes?["rackable"].AsBool() != true) { continue; } ToolTextures tt = new ToolTextures(); if (item.Shape != null) { IAsset asset = api.Assets.TryGet(item.Shape.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json")); if (asset != null) { Shape shape = asset.ToObject <Shape>(); foreach (var val in shape.Textures) { CompositeTexture ctex = new CompositeTexture(val.Value.Clone()); ctex.Bake(api.Assets); textureDict.AddTextureLocation(new AssetLocationAndSource(ctex.Baked.BakedName, "Shape code " + item.Shape.Base)); tt.TextureSubIdsByCode[val.Key] = textureDict[new AssetLocationAndSource(ctex.Baked.BakedName)]; } } } foreach (var val in item.Textures) { val.Value.Bake(api.Assets); textureDict.AddTextureLocation(new AssetLocationAndSource(val.Value.Baked.BakedName, "Item code " + item.Code)); tt.TextureSubIdsByCode[val.Key] = textureDict[new AssetLocationAndSource(val.Value.Baked.BakedName)]; } ToolTextureSubIds(api)[item] = tt; } }