public override void Init(GraphicRequest req) { this.data = req.graphicData; if (req.path.NullOrEmpty()) { throw new ArgumentNullException("folderPath"); } if (req.shader == null) { throw new ArgumentNullException("shader"); } this.path = req.path; this.color = req.color; this.drawSize = req.drawSize; List <Texture2D> list = (from x in ContentFinder <Texture2D> .GetAllInFolder(req.path) where !x.name.EndsWith(Graphic_Single.MaskSuffix) orderby x.name select x).ToList <Texture2D>(); if (list.NullOrEmpty <Texture2D>()) { Log.Error("Collection cannot init: No textures found at path " + req.path); this.subGraphics = new Graphic[] { BaseContent.BadGraphic }; return; } this.subGraphics = new Graphic[list.Count]; for (int i = 0; i < list.Count; i++) { string path = req.path + "/" + list[i].name; this.subGraphics[i] = GraphicDatabase.Get <Graphic_Single>(path, req.shader, this.drawSize, this.color); } }
public override void Init(GraphicRequest req) { base.data = req.graphicData; base.path = req.path; base.color = req.color; base.drawSize = req.drawSize; List <StuffAppearanceDef> allDefsListForReading = DefDatabase <StuffAppearanceDef> .AllDefsListForReading; this.subGraphics = new Graphic[allDefsListForReading.Count]; for (int i = 0; i < this.subGraphics.Length; i++) { StuffAppearanceDef stuffAppearance = allDefsListForReading[i]; string text = req.path; if (!stuffAppearance.pathPrefix.NullOrEmpty()) { text = stuffAppearance.pathPrefix + "/" + text.Split('/').Last(); } Texture2D texture2D = (from x in ContentFinder <Texture2D> .GetAllInFolder(text) where x.name.EndsWith(stuffAppearance.defName) select x).FirstOrDefault(); if ((Object)texture2D != (Object)null) { this.subGraphics[i] = GraphicDatabase.Get <Graphic_Single>(text + "/" + texture2D.name, req.shader, base.drawSize, base.color); } } for (int j = 0; j < this.subGraphics.Length; j++) { if (this.subGraphics[j] == null) { this.subGraphics[j] = this.subGraphics[StuffAppearanceDefOf.Smooth.index]; } } }
public override void Init(GraphicRequest req) { this.data = req.graphicData; this.path = req.path; this.color = req.color; this.colorTwo = req.colorTwo; this.drawSize = req.drawSize; Texture2D[] array = new Texture2D[3]; array[0] = ContentFinder <Texture2D> .Get(req.path + "_back", false); if (array[0] == null) { Log.Error("Failed to find any texture while constructing " + this.ToString()); return; } array[1] = ContentFinder <Texture2D> .Get(req.path + "_side", false); if (array[1] == null) { array[1] = array[0]; } array[2] = ContentFinder <Texture2D> .Get(req.path + "_front", false); if (array[2] == null) { array[2] = array[0]; } Texture2D[] array2 = new Texture2D[3]; if (req.shader.SupportsMaskTex()) { array2[0] = ContentFinder <Texture2D> .Get(req.path + "_backm", false); if (array2[0] != null) { array2[1] = ContentFinder <Texture2D> .Get(req.path + "_sidem", false); if (array2[1] == null) { array2[1] = array2[0]; } array2[2] = ContentFinder <Texture2D> .Get(req.path + "_frontm", false); if (array2[2] == null) { array2[2] = array2[0]; } } } for (int i = 0; i < 3; i++) { MaterialRequest req2 = default(MaterialRequest); req2.mainTex = array[i]; req2.shader = req.shader; req2.color = this.color; req2.colorTwo = this.colorTwo; req2.maskTex = array2[i]; this.mats[i] = MaterialPool.MatFrom(req2); } }
public static Graphic Get(Type graphicClass, string path, Shader shader, Vector2 drawSize, Color color, Color colorTwo, GraphicData data) { GraphicRequest graphicRequest = new GraphicRequest(graphicClass, path, shader, drawSize, color, colorTwo, data, 0); if (graphicRequest.graphicClass == typeof(Graphic_Single)) { return(GraphicDatabase.GetInner <Graphic_Single>(graphicRequest)); } if (graphicRequest.graphicClass == typeof(Graphic_Terrain)) { return(GraphicDatabase.GetInner <Graphic_Terrain>(graphicRequest)); } if (graphicRequest.graphicClass == typeof(Graphic_Multi)) { return(GraphicDatabase.GetInner <Graphic_Multi>(graphicRequest)); } if (graphicRequest.graphicClass == typeof(Graphic_Mote)) { return(GraphicDatabase.GetInner <Graphic_Mote>(graphicRequest)); } if (graphicRequest.graphicClass == typeof(Graphic_Random)) { return(GraphicDatabase.GetInner <Graphic_Random>(graphicRequest)); } if (graphicRequest.graphicClass == typeof(Graphic_Flicker)) { return(GraphicDatabase.GetInner <Graphic_Flicker>(graphicRequest)); } if (graphicRequest.graphicClass == typeof(Graphic_Appearances)) { return(GraphicDatabase.GetInner <Graphic_Appearances>(graphicRequest)); } if (graphicRequest.graphicClass == typeof(Graphic_StackCount)) { return(GraphicDatabase.GetInner <Graphic_StackCount>(graphicRequest)); } try { return((Graphic)GenGeneric.InvokeStaticGenericMethod(typeof(GraphicDatabase), graphicRequest.graphicClass, "GetInner", new object[] { graphicRequest })); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception getting ", graphicClass, " at ", path, ": ", ex.ToString() })); } return(BaseContent.BadGraphic); }
private static T GetInner <T>(GraphicRequest req) where T : Graphic, new() { if (!allGraphics.TryGetValue(req, out Graphic value)) { value = new T(); value.Init(req); allGraphics.Add(req, value); } return((T)value); }
private static T GetInner <T>(GraphicRequest req) where T : Graphic, new() { req.color = (Color32)req.color; req.colorTwo = (Color32)req.colorTwo; if (!allGraphics.TryGetValue(req, out var value)) { value = new T(); value.Init(req); allGraphics.Add(req, value); } return((T)value); }
private static T GetInner <T>(GraphicRequest req) where T : Graphic, new() { Graphic graphic = default(Graphic); if (!GraphicDatabase.allGraphics.TryGetValue(req, out graphic)) { graphic = (Graphic)(object)new T(); graphic.Init(req); GraphicDatabase.allGraphics.Add(req, graphic); } return((T)graphic); }
private static T GetInner <T>(GraphicRequest req) where T : Graphic, new() { Graphic graphic; if (!GraphicDatabase.allGraphics.TryGetValue(req, out graphic)) { graphic = Activator.CreateInstance <T>(); graphic.Init(req); GraphicDatabase.allGraphics.Add(req, graphic); } return((T)((object)graphic)); }
public override void Init(GraphicRequest req) { this.data = req.graphicData; this.path = req.path; this.color = req.color; this.colorTwo = req.colorTwo; this.drawSize = req.drawSize; MaterialRequest req2 = default(MaterialRequest); req2.mainTex = ContentFinder <Texture2D> .Get(req.path, true); req2.shader = req.shader; req2.color = this.color; req2.colorTwo = this.colorTwo; req2.renderQueue = req.renderQueue; if (req.shader.SupportsMaskTex()) { req2.maskTex = ContentFinder <Texture2D> .Get(req.path + Graphic_Single.MaskSuffix, false); } this.mat = MaterialPool.MatFrom(req2); }
public override void Init(GraphicRequest req) { data = req.graphicData; if (req.path.NullOrEmpty()) { throw new ArgumentNullException("folderPath"); } if (req.shader == null) { throw new ArgumentNullException("shader"); } base.path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; List <Texture2D> list = (from x in ContentFinder <Texture2D> .GetAllInFolder(req.path) where !x.name.EndsWith(Graphic_Single.MaskSuffix) orderby x.name select x).ToList(); if (list.NullOrEmpty()) { list = (from x in ContentFinder <Texture2D> .GetAllInFolder("World/Hills") orderby x.name select x).ToList(); //FlodeMoveTo.Instance.InFloder(req.path); //.Error("Collection cannot init: No textures found at path " + req.path); //Log.Message("Use Default Texure"); subGraphics = new Graphic[1] { BaseContent.BadGraphic }; return; } subGraphics = new Graphic[list.Count]; for (int i = 0; i < list.Count; i++) { string path = req.path + "/" + list[i].name; subGraphics[i] = GraphicDatabase.Get(typeof(Graphic_Single), path, req.shader, drawSize, color, colorTwo, null, req.shaderParameters); } }
public override void Init(GraphicRequest req) { data = req.graphicData; path = req.path; color = req.color; drawSize = req.drawSize; List <StuffAppearanceDef> allDefsListForReading = DefDatabase <StuffAppearanceDef> .AllDefsListForReading; subGraphics = new Graphic[allDefsListForReading.Count]; for (int i = 0; i < subGraphics.Length; i++) { StuffAppearanceDef stuffAppearance = allDefsListForReading[i]; string text = req.path; if (!stuffAppearance.pathPrefix.NullOrEmpty()) { text = stuffAppearance.pathPrefix + "/" + text.Split('/').Last(); } Texture2D texture2D = (from x in ContentFinder <Texture2D> .GetAllInFolder(text) where x.name.EndsWith(stuffAppearance.defName) select x).FirstOrDefault(); if (texture2D != null) { subGraphics[i] = GraphicDatabase.Get <Graphic_Single>(text + "/" + texture2D.name, req.shader, drawSize, color); } else { texture2D = Resources.Load <Texture2D>("Textures/World/MouseTile"); // Debug.Log(">>>>>>" + text + ">>>>>>" + stuffAppearance.defName); } } for (int j = 0; j < subGraphics.Length; j++) { if (subGraphics[j] == null) { subGraphics[j] = subGraphics[StuffAppearanceDefOf.Smooth.index]; } } }
public override void Init(GraphicRequest req) { data = req.graphicData; path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; MaterialRequest req2 = default(MaterialRequest); req2.mainTex = ContentFinder <Texture2D> .Get(req.path); req2.shader = req.shader; req2.color = color; req2.colorTwo = colorTwo; req2.renderQueue = req.renderQueue; req2.shaderParameters = req.shaderParameters; if (req.shader.SupportsMaskTex()) { req2.maskTex = ContentFinder <Texture2D> .Get(req.path + MaskSuffix, reportFailure : false); } mat = MaterialPool.MatFrom(req2); }
public static Graphic Get <T>(string path, Shader shader, Vector2 drawSize, Color color, Color colorTwo) where T : Graphic, new() { GraphicRequest req = new GraphicRequest(typeof(T), path, shader, drawSize, color, colorTwo, null, 0, null); return(GetInner <T>(req)); }
public override void Init(GraphicRequest req) { this.data = req.graphicData; this.path = req.path; this.color = req.color; this.colorTwo = req.colorTwo; this.drawSize = req.drawSize; Texture2D[] array = new Texture2D[this.mats.Length]; array[0] = ContentFinder <Texture2D> .Get(req.path + "_north", false); if (array[0] == null) { Log.Error("Failed to find any texture while constructing " + this.ToString() + ". Filenames have changed; if you are converting an old mod, recommend renaming textures from *_back to *_north, *_side to *_east, and *_front to *_south.", false); } else { array[1] = ContentFinder <Texture2D> .Get(req.path + "_east", false); if (array[1] == null) { array[1] = array[0]; } array[2] = ContentFinder <Texture2D> .Get(req.path + "_south", false); if (array[2] == null) { array[2] = array[0]; } array[3] = ContentFinder <Texture2D> .Get(req.path + "_west", false); if (array[3] == null) { array[3] = array[1]; this.westFlipped = base.WestFlipped; } Texture2D[] array2 = new Texture2D[this.mats.Length]; if (req.shader.SupportsMaskTex()) { array2[0] = ContentFinder <Texture2D> .Get(req.path + "_northm", false); if (array2[0] != null) { array2[1] = ContentFinder <Texture2D> .Get(req.path + "_eastm", false); if (array2[1] == null) { array2[1] = array2[0]; } array2[2] = ContentFinder <Texture2D> .Get(req.path + "_southm", false); if (array2[2] == null) { array2[2] = array2[0]; } array2[3] = ContentFinder <Texture2D> .Get(req.path + "_westm", false); if (array2[3] == null) { array2[3] = array2[1]; } } } for (int i = 0; i < this.mats.Length; i++) { MaterialRequest req2 = default(MaterialRequest); req2.mainTex = array[i]; req2.shader = req.shader; req2.color = this.color; req2.colorTwo = this.colorTwo; req2.maskTex = array2[i]; req2.shaderParameters = req.shaderParameters; this.mats[i] = MaterialPool.MatFrom(req2); } } }
public override void Init(GraphicRequest req) { base.Init(req); }
public virtual void Init(GraphicRequest req) { Log.ErrorOnce("Cannot init Graphic of class " + base.GetType().ToString(), 658928); }
public static Graphic Get <T>(string path, Shader shader) where T : Graphic, new() { GraphicRequest req = new GraphicRequest(typeof(T), path, shader, Vector2.one, Color.white, Color.white, null, 0); return(GraphicDatabase.GetInner <T>(req)); }
public static Graphic Get <T>(string path, Shader shader, Vector2 drawSize, Color color, Color colorTwo, GraphicData data) where T : Graphic, new() { GraphicRequest req = new GraphicRequest(typeof(T), path, shader, drawSize, color, colorTwo, data, 0); return(GraphicDatabase.GetInner <T>(req)); }
public static Graphic Get <T>(string path, Shader shader, Vector2 drawSize, Color color, int renderQueue) where T : Graphic, new() { GraphicRequest req = new GraphicRequest(typeof(T), path, shader, drawSize, color, Color.white, null, renderQueue); return(GraphicDatabase.GetInner <T>(req)); }
public override void Init(GraphicRequest req) { data = req.graphicData; path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; Texture2D[] array = new Texture2D[mats.Length]; array[0] = ContentFinder <Texture2D> .Get(req.path + "_north", reportFailure : false); array[1] = ContentFinder <Texture2D> .Get(req.path + "_east", reportFailure : false); array[2] = ContentFinder <Texture2D> .Get(req.path + "_south", reportFailure : false); array[3] = ContentFinder <Texture2D> .Get(req.path + "_west", reportFailure : false); if (array[0] == null) { if (array[2] != null) { array[0] = array[2]; drawRotatedExtraAngleOffset = 180f; } else if (array[1] != null) { array[0] = array[1]; drawRotatedExtraAngleOffset = -90f; } else if (array[3] != null) { array[0] = array[3]; drawRotatedExtraAngleOffset = 90f; } else { array[0] = ContentFinder <Texture2D> .Get(req.path, reportFailure : false); } } if (array[0] == null) { Log.Error("Failed to find any textures at " + req.path + " while constructing " + this.ToStringSafe()); return; } if (array[2] == null) { array[2] = array[0]; } if (array[1] == null) { if (array[3] != null) { array[1] = array[3]; eastFlipped = base.DataAllowsFlip; } else { array[1] = array[0]; } } if (array[3] == null) { if (array[1] != null) { array[3] = array[1]; westFlipped = base.DataAllowsFlip; } else { array[3] = array[0]; } } Texture2D[] array2 = new Texture2D[mats.Length]; if (req.shader.SupportsMaskTex()) { array2[0] = ContentFinder <Texture2D> .Get(req.path + "_northm", reportFailure : false); array2[1] = ContentFinder <Texture2D> .Get(req.path + "_eastm", reportFailure : false); array2[2] = ContentFinder <Texture2D> .Get(req.path + "_southm", reportFailure : false); array2[3] = ContentFinder <Texture2D> .Get(req.path + "_westm", reportFailure : false); if (array2[0] == null) { if (array2[2] != null) { array2[0] = array2[2]; } else if (array2[1] != null) { array2[0] = array2[1]; } else if (array2[3] != null) { array2[0] = array2[3]; } } if (array2[2] == null) { array2[2] = array2[0]; } if (array2[1] == null) { if (array2[3] != null) { array2[1] = array2[3]; } else { array2[1] = array2[0]; } } if (array2[3] == null) { if (array2[1] != null) { array2[3] = array2[1]; } else { array2[3] = array2[0]; } } } for (int i = 0; i < mats.Length; i++) { MaterialRequest req2 = default(MaterialRequest); req2.mainTex = array[i]; req2.shader = req.shader; req2.color = color; req2.colorTwo = colorTwo; req2.maskTex = array2[i]; req2.shaderParameters = req.shaderParameters; mats[i] = MaterialPool.MatFrom(req2); } }
public override void Init(GraphicRequest req) { this.data = req.graphicData; this.path = req.path; this.color = req.color; this.colorTwo = req.colorTwo; this.drawSize = req.drawSize; Texture2D[] array = new Texture2D[4]; array[0] = ContentFinder <Texture2D> .Get(req.path + "_north", false); if (array[0] == null) { Log.Error("Failed to find any texture while constructing " + this); return; } array[1] = ContentFinder <Texture2D> .Get(req.path + "_east", false); if (array[1] == null) { array[1] = array[0]; } array[2] = ContentFinder <Texture2D> .Get(req.path + "_south", false); if (array[2] == null) { array[2] = array[0]; } array[3] = ContentFinder <Texture2D> .Get(req.path + "_west", false); if (array[3] == null) { array[3] = array[1]; } Texture2D[] array2 = new Texture2D[4]; if (req.shader.SupportsMaskTex()) { array2[0] = ContentFinder <Texture2D> .Get(req.path + "_northm", false); if (array2[0] == null) { array2[0] = FaceTextures.RedTexture; } array2[1] = ContentFinder <Texture2D> .Get(req.path + "_eastm", false); if (array2[1] == null) { array2[1] = FaceTextures.RedTexture; } array2[2] = ContentFinder <Texture2D> .Get(req.path + "_southm", false); if (array2[2] == null) { array2[2] = FaceTextures.RedTexture; } array2[3] = ContentFinder <Texture2D> .Get(req.path + "_westm", false); if (array2[3] == null) { array2[3] = FaceTextures.RedTexture; } } for (int i = 0; i < 4; i++) { MaterialRequest req2 = default; req2.mainTex = array[i]; req2.shader = req.shader; req2.color = this.color; req2.colorTwo = this.colorTwo; req2.maskTex = array2[i]; this.mats[i] = MaterialPool.MatFrom(req2); } }