public static GraphicExtraData Extract(GraphicRequest req, out GraphicRequest outReq, bool removeExtraFromReq = false) { outReq = CopyGraphicRequest(req); if (req.graphicData.texPath[0] == '[') { GraphicExtraData extraData = null; try { var helperDoc = new System.Xml.XmlDocument(); helperDoc.LoadXml(req.graphicData.texPath.Replace('[', '<').Replace(']', '>')); extraData = DirectXmlToObject.ObjectFromXml <GraphicExtraData>( helperDoc.DocumentElement, false); } catch (Exception e) { Log.Error("GraphicExtraData was unable to extract XML from \"" + req.graphicData.texPath + "\"; Exception: " + e); return(null); } extraData.inputString = req.graphicData.texPath; if (removeExtraFromReq) { outReq.graphicData.texPath = extraData.texPath; outReq.path = extraData.texPath; } Debug.Message(Debug.Flag.ConveyorGraphics, "Graphic Extra Data extracted: " + extraData); return(extraData); } #if DEBUG else { Debug.Message(Debug.Flag.ConveyorGraphics, "Graphic Extra Data empty: " + req.graphicData.texPath); } #endif return(null); }
public override void Init(GraphicRequest req) { if (req == minimal) { return; } data = req.graphicData; path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; hash = Gen.HashCombine(hash, path); hash = Gen.HashCombineStruct(hash, color); hash = Gen.HashCombineStruct(hash, colorTwo); for (var i = 0; i < 4; i++) { var iterator = InitIterativ(req, i, ZombieStains.maxStainPoints); while (iterator.MoveNext()) { ; } } }
static Building_Stargate() { UI_ADD_RESOURCES = ContentFinder <Texture2D> .Get("UI/ADD_RESOURCES", true); UI_ADD_COLONIST = ContentFinder <Texture2D> .Get("UI/ADD_COLONIST", true); UI_GATE_IN = ContentFinder <Texture2D> .Get("UI/StargateGUI-In", true); UI_GATE_OUT = ContentFinder <Texture2D> .Get("UI/StargateGUI-Out", true); UI_POWER_UP = ContentFinder <Texture2D> .Get("UI/PowerUp", true); UI_POWER_DOWN = ContentFinder <Texture2D> .Get("UI/PowerDown", true); GraphicRequest requestActive = new GraphicRequest(Type.GetType("Graphic_Single"), "Things/Buildings/Stargate-Active", ShaderDatabase.DefaultShader, new Vector2(3, 3), Color.white, Color.white, new GraphicData(), 0, null); graphicActive = new Graphic_Single(); graphicActive.Init(requestActive); GraphicRequest requestInactive = new GraphicRequest(Type.GetType("Graphic_Single"), "Things/Buildings/Stargate", ShaderDatabase.DefaultShader, new Vector2(3, 3), Color.white, Color.white, new GraphicData(), 0, null); graphicInactive = new Graphic_Single(); graphicInactive.Init(requestInactive); }
public override void Init(GraphicRequest req) { GraphicRequest newReq; var extraData = GraphicExtraData.Extract(req, out newReq); ExtraInit(newReq, extraData); }
public override void Init(GraphicRequest req) { // I'm sure "req ... out req" is perfectly safe? var extraData = GraphicExtraData.Extract(req, out req); ExtraInit(req, extraData); }
public override void ExtraInit(GraphicRequest req, GraphicExtraData extraData) { base.ExtraInit(req, extraData); if (extraData == null) { Log.Error("PRF's Wall Conveyor graphic requires GraphicExtraData"); } else { transitionWest = new GraphicData { graphicClass = typeof(Graphic_Single), texPath = extraData.texPath2 + "_West", drawSize = Vector2.one }; transitionSouth = new GraphicData { graphicClass = typeof(Graphic_Single), texPath = extraData.texPath2 + "_South", drawSize = Vector2.one }; transitionEast = new GraphicData { graphicClass = typeof(Graphic_Single), texPath = extraData.texPath2 + "_East", drawSize = Vector2.one }; sameLinkDefs = extraData.specialLinkDefs; } }
public override void Init(GraphicRequest req) { // Move all Init to ExtraInit var extraData = GraphicExtraData.Extract(req, out GraphicRequest newReq); ExtraInit(newReq, extraData); }
// TODO: add some way to keep track of used textures after game loads (it gets reset to MatSingle or first stuff from list) public override void Init(GraphicRequest req) { path = req.path; drawSize = req.drawSize; color = req.color; colorTwo = req.colorTwo; foreach (var directory in ContentFinder<DirectoryInfo>.GetAllInFolder(req.path)) { path = directory.FullName; var textures = ContentFinder<Texture2D>.GetAllInFolder(directory.FullName).ToList(); if (!textures.NullOrEmpty()) { var textureNameParts = textures[0].name.Split('_'); var graphic = DetermineGraphicType(textureNameParts[textureNameParts.Length - 1]); if (graphic is Graphic_Single) { req.path += "/" + textures[0].name; } graphic.Init(req); categorizedGraphics.Add(directory.Name, graphic); } } }
public override void Init(GraphicRequest req) { path = req.path; subGraphic = GraphicDatabase.Get <Graphic_Single>(req.path, ShaderDatabase.Transparent); compTexPath = req.path + "_Comp"; cornerMat = LoadCompMaterial(compTexPath); }
public override void ExtraInit(GraphicRequest req, GraphicExtraData extraData) { Debug.Warning(Debug.Flag.ConveyorGraphics, "Graphics ExtraInit for Graphic_LinkedConveyorWall: (" + req.graphicData.texPath + ")"); base.ExtraInit(req, extraData); if (extraData == null) { Log.Error("PRF's Wall Conveyor graphic requires GraphicExtraData"); } else if (extraData.graphicData1 == null) { Log.Error("PRF's Wall Conveyor grahpic requires GraphicExtraData's graphicData1"); } else { transitionGData = new GraphicData(); transitionGData.CopyFrom(extraData.graphicData1); // If this throws errors, that's okay - it's a config error that needs to be fixed: // NOTE: this can be changed later if the graphics needs to allow multilpe defs, // not all of which may be actually listed... sameLinkDefs = new List <ThingDef>(extraData.specialLinkDefs.Select( s => DefDatabase <ThingDef> .GetNamed(s))); Debug.Message(Debug.Flag.ConveyorGraphics, " added sameLinkDefs: " + (sameLinkDefs == null ? "null" : String.Join(", ", sameLinkDefs))); } }
public IEnumerator InitIterativ(GraphicRequest req, int n, int points) { var data = GraphicsDatabase.GetColorData(req.path + directions[n], bodyColor, true); yield return(null); while (points > 0) { var stain = ZombieStains.GetRandom(points, req.path.Contains("Naked")); var it = data.ApplyStainsIterativ(stain.Key, Rand.Bool, Rand.Bool); while (it.MoveNext()) { yield return(null); } points -= stain.Value; hash = Gen.HashCombine(hash, stain); yield return(null); } var request = new MaterialRequest { mainTex = null, // will be calculated lazy from 'data' shader = req.shader, color = color, colorTwo = colorTwo, maskTex = null }; mats[n] = new VariableMaterial(request, data); }
public static Material[] GetMatsFrom(GraphicRequest req, Texture2D[] inputTextureArray, Texture2D[] inputMaskArray) { Material[] matArray = new Material[inputTextureArray.Length]; for (int i = 0; i < inputTextureArray.Length; i++) { if (inputTextureArray[i] != null) { Texture2D mask; if (inputMaskArray[i] != null) { mask = inputMaskArray[i]; } else { mask = HairMasker.GetDefaultMask(inputTextureArray[i].width, inputTextureArray[i].height); } MaterialRequest tempMatReq = default(MaterialRequest); tempMatReq.mainTex = inputTextureArray[i]; tempMatReq.shader = req.shader; tempMatReq.color = req.color; tempMatReq.colorTwo = req.colorTwo; tempMatReq.maskTex = mask; tempMatReq.shaderParameters = req.shaderParameters; matArray[i] = MaterialPool.MatFrom(tempMatReq); } } return(matArray); }
public override void ExtraInit(GraphicRequest req, GraphicExtraData extraData) { base.ExtraInit(req, extraData); if (extraData == null) { Log.Error("PRF: invalid XML for conveyor Splitter's graphic:\n" + " it must have <texPath>[extraData]...[texPath2]path/to/building[/texPath2]</texPath>\n" + " but has string: " + req.path); return; } string doorBasePath = extraData.texPath2; splitterBuildingDoorOpen = new GraphicData { graphicClass = typeof(Graphic_Single), texPath = doorBasePath + "_Open", drawSize = Vector2.one }; splitterBuildingDoorClosed = new GraphicData { graphicClass = typeof(Graphic_Single), texPath = doorBasePath + "_Closed", drawSize = Vector2.one }; splitterBuildingBlueprint = new GraphicData { graphicClass = typeof(Graphic_Single), texPath = doorBasePath + "_Blueprint", drawSize = Vector2.one }; }
// ReSharper disable once MissingXmlDoc public static Graphic Get <T>(string path, Shader shader, Vector2 drawSize, Color color, HeadCoverage coverage) where T : Graphic, new() { // Added second 'color' to get a separate graphic GraphicRequest req = new GraphicRequest(typeof(T), path, shader, drawSize, color, color, null, 0); return(GetInner <T>(req, coverage)); }
public override void Init(GraphicRequest req) { // I'm sure "req ... out req" is perfectly safe? // Move all initialization to ExtraInit var extraData = GraphicExtraData.Extract(req, out req); ExtraInit(req, extraData); }
public static Graphic Get(Type graphicClass, string path, Shader shader, Vector2 drawSize, Color color, Color colorTwo, GraphicData data, List <ShaderParameter> shaderParameters) { GraphicRequest graphicRequest = new GraphicRequest(graphicClass, path, shader, drawSize, color, colorTwo, colorThree, data, 0, shaderParameters); 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() }), false); } return(BaseContent.BadGraphic); }
public GraphicRotatable(GraphicRequest req, AutoRotate autoRotate = AutoRotate.None) { base.Init(req); if (autoRotate != AutoRotate.None) { this.autoRotate = autoRotate; //ProcessAutoRotate(); } }
public override void Init(GraphicRequest req) { base.Init(req); baseData = data as GraphicData_SidedBase; if (baseData != null) { baseMatFront = MaterialPool.MatFrom(new MaterialRequest(baseData.BaseFrontTex, baseData.shaderType.Shader, baseData.color)); baseMatSide = MaterialPool.MatFrom(new MaterialRequest(baseData.BaseSideTex, baseData.shaderType.Shader, baseData.color)); } }
public static void UpdateBlightGraphics() { Log.Message("Updating Blight Graphics"); if (Mod_EnhancedOptions.Settings.BlightImageIndex != 0) { String _BlightPath = string.Empty; switch (Mod_EnhancedOptions.Settings.BlightImageIndex) { case 0: _BlightPath = "Things/Plant/Blight"; break; case 1: _BlightPath = "Things/Plant/Blights/Blight_Red"; break; case 2: _BlightPath = "Things/Plant/Blights/Blight_Blue"; break; case 3: _BlightPath = "Things/Plant/Blights/Blight_Orange"; break; case 4: _BlightPath = "Things/Plant/Blights/Blight_Purple"; break; default: _BlightPath = "Things/Plant/Blight"; break; } GraphicRequest requestActive = new GraphicRequest(Type.GetType("Graphic_Single"), _BlightPath, ShaderDatabase.DefaultShader, new Vector2(1, 1), Color.white, Color.white, new GraphicData(), 1); ThingDefOf.Blight.graphic.Init(requestActive); } if (Mod_EnhancedOptions.Settings.BlightScale != 1) { ThingDefOf.Blight.graphic.drawSize = new Vector2(Mod_EnhancedOptions.Settings.BlightScale, Mod_EnhancedOptions.Settings.BlightScale); } Log.Message("Finished Updating Blight Graphics"); }
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; this.subGraphic.Init(req); this.CreateSubMats(); }
public override void Init(GraphicRequest req) { path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; var array = new Texture2D[3]; array[0] = DXTLoader.LoadTextureDXT(ResourceBank.modName, req.path + "_back", TextureFormat.DXT5); if (array[0] == null) { Log.Error("Failed to find any texture while constructing " + ToString()); return; } array[1] = DXTLoader.LoadTextureDXT(ResourceBank.modName, req.path + "_side", TextureFormat.DXT5); if (array[1] == null) { array[1] = array[0]; } array[2] = DXTLoader.LoadTextureDXT(ResourceBank.modName, req.path + "_front", TextureFormat.DXT5); if (array[2] == null) { array[2] = array[0]; } /* * var array2 = new Texture2D[3]; * if (req.shader.SupportsMaskTex()) * { * array2[0] = DXTLoader.LoadTextureDXT(req.path + "_backm"); * if (array2[0] != null) * { * array2[1] = DXTLoader.LoadTextureDXT(req.path + "_sidem"); * if (array2[1] == null) * { * array2[1] = array2[0]; * } * array2[2] = DXTLoader.LoadTextureDXT(req.path + "_frontm"); * if (array2[2] == null) * { * array2[2] = array2[0]; * } * } * }*/ for (var i = 0; i < 3; i++) { var req2 = default(MaterialRequest); req2.mainTex = array[i]; req2.shader = req.shader; req2.color = color; req2.colorTwo = colorTwo; mats[i] = MaterialPool.MatFrom(req2); } }
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.colorTwo = req.colorTwo; this.drawSize = req.drawSize; int idx = this.path.LastIndexOf('/'); if (idx != -1) { // string s1 = this.path.Substring(0, idx); // Log.Message(s1); string s2 = this.path.Substring(idx + 1); // Log.Message(s2); this.path = req.path + "/" + s2; // Log.Message(path); } // Regex.Match(test, @"^[^0-9]*").Value List <Texture2D> list = (from x in ContentFinder <Texture2D> .GetAllInFolder(path) where Regex.Match(x.name, @"^[^0-9]*").Success&& !x.name.EndsWith(Graphic_AdvancedSingle.MaskSuffix) && !x.name.EndsWith(Graphic_AdvancedSingle.GlowSuffix) && !x.name.EndsWith(Graphic_AdvancedSingle.GlowMaskSuffix) && !x.name.Contains(Graphic_AdvancedMulti.NSuffix) && !x.name.Contains(Graphic_AdvancedMulti.SSuffix) && !x.name.Contains(Graphic_AdvancedMulti.ESuffix) && !x.name.Contains(Graphic_AdvancedMulti.WSuffix) orderby x.name select x).ToList <Texture2D>(); if (list.NullOrEmpty <Texture2D>()) { Log.Error("Collection cannot init: No textures found at path " + path, false); this.subGraphics = new Graphic[] { BaseContent.BadGraphic }; return; } // Log.Message("found " + list.Count()+" Variants"); this.subGraphics = new Graphic[list.Count]; for (int i = 0; i < list.Count; i++) { string path = req.path + "/" + list[i].name; // Log.Message("loaded "+ path); this.subGraphics[i] = GraphicDatabase.Get(typeof(Graphic_Single), path, req.shader, this.drawSize, this.color, this.colorTwo, this.data, req.shaderParameters); } this.mat = this.subGraphics[0].MatSingle; }
public virtual void ExtraInit(GraphicRequest req, GraphicExtraData extraData) { // All basically pointless: this.data = req.graphicData; this.color = req.color; this.colorTwo = req.colorTwo; this.drawSize = req.drawSize; this.path = extraData?.texPath ?? req.path; // What we want is two duplicate graphics with slightly different paths EW = MakeSubgraphic(req, extraData, "_East"); NS = MakeSubgraphic(req, extraData, "_North"); }
public override void Init( GraphicRequest req ) { path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; var array = new Texture2D[3]; array[0] = DXTLoader.LoadTextureDXT( ResourceBank.modName, req.path + "_back", TextureFormat.DXT5 ); if (array[0] == null) { Log.Error( "Failed to find any texture while constructing " + ToString() ); return; } array[1] = DXTLoader.LoadTextureDXT( ResourceBank.modName, req.path + "_side", TextureFormat.DXT5 ); if (array[1] == null) { array[1] = array[0]; } array[2] = DXTLoader.LoadTextureDXT( ResourceBank.modName, req.path + "_front", TextureFormat.DXT5 ); if (array[2] == null) { array[2] = array[0]; } /* var array2 = new Texture2D[3]; if (req.shader.SupportsMaskTex()) { array2[0] = DXTLoader.LoadTextureDXT(req.path + "_backm"); if (array2[0] != null) { array2[1] = DXTLoader.LoadTextureDXT(req.path + "_sidem"); if (array2[1] == null) { array2[1] = array2[0]; } array2[2] = DXTLoader.LoadTextureDXT(req.path + "_frontm"); if (array2[2] == null) { array2[2] = array2[0]; } } }*/ for (var i = 0; i < 3; i++) { var req2 = default(MaterialRequest); req2.mainTex = array[i]; req2.shader = req.shader; req2.color = color; req2.colorTwo = colorTwo; mats[i] = MaterialPool.MatFrom( req2 ); } }
public static Graphic GetGraphicRandomRotated(Thing thing, Graphic graphic, Type graphicClass, string path, Shader shader, Vector2 drawSize, Color color, Color colorTwo, GraphicData data, List <ShaderParameter> shaderParameters) { GraphicRequest graphicRequest = new GraphicRequest(graphicClass, path, shader, drawSize, color, colorTwo, data, 0, shaderParameters); graphicRequest.color = (Color32)graphicRequest.color; graphicRequest.colorTwo = (Color32)graphicRequest.colorTwo; if (!GraphicDatabase.allGraphics.TryGetValue(graphicRequest, out Graphic value)) { value = new Graphic_RandomRotated((graphic as Graphic_RandomRotated).subGraphic, thing.def.graphicData.onGroundRandomRotateAngle); value.Init(graphicRequest); GraphicDatabase.allGraphics.Add(graphicRequest, value); } return(value); }
protected Graphic MakeSubgraphic(GraphicRequest req, GraphicExtraData extraData, string texSuffix) { var childReq = GraphicExtraData.CopyGraphicRequest(req); childReq.graphicClass = typeof(T); var tmpG = new T(); if (tmpG is IHaveGraphicExtraData ihged && extraData != null) { var tmpPath = extraData.texPath; extraData.texPath += texSuffix; ihged.ExtraInit(childReq, extraData); extraData.texPath = tmpPath; }
public GraphicRequestRGB(GraphicRequest req) { graphicClass = req.graphicClass; path = req.path; shader = req.shader; drawSize = req.drawSize; color = req.color; colorTwo = req.colorTwo; colorThree = Color.blue; tiles = 1; displacement = Vector2.zero; graphicData = req.graphicData as GraphicDataRGB; renderQueue = req.renderQueue; shaderParameters = req.shaderParameters; }
private static T GetGraphic <T>(String path, Color color) where T : Graphic, new() { GraphicRequest req = new GraphicRequest(); req.color = (Color32)color; req.colorTwo = (Color32)Color.white; req.renderQueue = 0; req.drawSize = Vector2.one; req.path = path; req.shader = ShaderDatabase.Cutout; var value = new T(); value.Init(req); return((T)value); }
//no idea if this is necessary, but *it works* // - "it works" is a general theme here public static GraphicRequest CopyGraphicRequest(GraphicRequest req, string newTexPath = null) { GraphicData gData = new GraphicData(); gData.CopyFrom(req.graphicData); var gr = new GraphicRequest(gData.graphicClass, gData.texPath, req.shader, req.drawSize, req.color, req.colorTwo, gData, req.renderQueue, req.shaderParameters); if (newTexPath != null) { gr.path = newTexPath; gr.graphicData.texPath = newTexPath; } return(gr); }
public static void AssignNewCustomGraphics(Zombie zombie) { var renderPrecedence = 0; var bodyPath = "Zombie/Naked_" + zombie.story.bodyType.ToString(); var bodyRequest = new GraphicRequest(typeof(VariableGraphic), bodyPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence); zombie.customBodyGraphic = Activator.CreateInstance <VariableGraphic>(); zombie.customBodyGraphic.Init(bodyRequest); var headPath = "Zombie/" + zombie.gender + "_" + zombie.story.crownType + "_" + headShapes[Rand.Range(0, 3)]; var headRequest = new GraphicRequest(typeof(VariableGraphic), headPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence); zombie.customHeadGraphic = Activator.CreateInstance <VariableGraphic>(); zombie.customHeadGraphic.Init(headRequest); }
public virtual void ExtraInit(GraphicRequest req, GraphicExtraData extraData) { arrow = arrow00; this.data = req.graphicData; this.color = req.color; this.colorTwo = req.colorTwo; this.drawSize = req.drawSize; this.subGraphic = new Graphic_Single(); if (extraData == null) { this.subGraphic.Init(req); this.path = req.path; return; } var req2 = GraphicExtraData.CopyGraphicRequest(req, extraData.texPath); this.path = extraData.texPath; this.subGraphic.Init(req2); if (extraData.arrowDrawOffset != null) { var v = extraData.arrowDrawOffset.Value; for (int i = 0; i < 4; i++) { arrowOffsetsByRot4[i] = new Vector3(v.x, v.y, v.z); } } if (extraData.arrowEastDrawOffset != null) { arrowOffsetsByRot4[1] = extraData.arrowEastDrawOffset.Value; } if (extraData.arrowWestDrawOffset != null) { arrowOffsetsByRot4[3] = extraData.arrowWestDrawOffset.Value; } if (extraData.arrowNorthDrawOffset != null) { arrowOffsetsByRot4[0] = extraData.arrowNorthDrawOffset.Value; } if (extraData.arrowSouthDrawOffset != null) { arrowOffsetsByRot4[2] = extraData.arrowSouthDrawOffset.Value; } if (extraData.arrowTexPath1 != null) { this.arrow = MaterialPool.MatFrom(extraData.arrowTexPath1); } }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); GraphicRequest req = new GraphicRequest(this.def.graphicData.graphicClass, this.def.graphicData.texPath + "_Ground", this.def.graphicData.shaderType.Shader, this.def.graphicData.drawSize, this.def.graphicData.color, this.def.graphicData.colorTwo, this.def.graphicData, 0, null); MaterialRequest req2 = default(MaterialRequest); req2.mainTex = ContentFinder <Texture2D> .Get(req.path); req2.shader = req.shader; req2.color = req.color; req2.colorTwo = req.colorTwo; req2.renderQueue = req.renderQueue; req2.shaderParameters = req.shaderParameters; groundMat = MaterialPool.MatFrom(req2); }
public override void Init( GraphicRequest req ) { path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; var req2 = default(MaterialRequest); req2.mainTex = DXTLoader.LoadTextureDXT( ResourceBank.modName, req.path, TextureFormat.DXT5 ); req2.shader = req.shader; req2.color = color; req2.colorTwo = colorTwo; /* if (req.shader.SupportsMaskTex()) { req2.maskTex = DXTLoader.LoadTextureDXT(req.path + "_m", TextureFormat.DXT5); }*/ mat = MaterialPool.MatFrom( req2 ); }
// Unfortunately the method used to populate a Graphic_Collection does not actually put the graphics in order // based on their filename. It's pretty difficult to make an interesting animation where the order of the frames // doesn't matter, so we have to fix this ourselves. public override void Init(GraphicRequest req) { List<string> files = Directory.GetFiles(Path.Combine(ModUtilities.GetTexturePath(), req.path)).ToList(); files.Sort((a, b) => a.CompareTo(b)); subGraphics = new Graphic_Single[files.Count]; path = req.path; //Shader = req.shader; color = req.color; drawSize = req.drawSize; int i = 0; foreach (string file in files) { string fileRelative = req.path + "/" + Path.GetFileNameWithoutExtension(file); subGraphics[i++] = GraphicDatabase.Get<Graphic_Single>(fileRelative, req.shader, drawSize, color); } }
public override void SpawnSetup() { base.SpawnSetup(); this.power = base.GetComp<CompPowerTrader>(); UI_ADD_RESOURCES = ContentFinder<Texture2D>.Get("UI/ADD_RESOURCES", true); UI_ADD_COLONIST = ContentFinder<Texture2D>.Get("UI/ADD_COLONIST", true); UI_DROPPOD = ContentFinder<Texture2D>.Get("UI/DEEP_STRIKE", true); UI_GATE_IN = ContentFinder<Texture2D>.Get("UI/StargateGUI-In", true); UI_GATE_OUT = ContentFinder<Texture2D>.Get("UI/StargateGUI-Out", true); UI_POWER_UP = ContentFinder<Texture2D>.Get("UI/PowerUp", true); UI_POWER_DOWN = ContentFinder<Texture2D>.Get("UI/PowerDown", true); GraphicRequest requestActive = new GraphicRequest(Type.GetType("Graphic_Single"), "Things/Buildings/Stargate-Active", def.graphic.Shader, new Vector2(3, 3), Color.white, Color.white); graphicActive = new Graphic_Single(); graphicActive.Init(requestActive); GraphicRequest requestInactive = new GraphicRequest(Type.GetType("Graphic_Single"), "Things/Buildings/Stargate", def.graphic.Shader, new Vector2(3, 3), Color.white, Color.white); graphicInactive = new Graphic_Single(); graphicInactive.Init(requestInactive); if (def is StargateThingDef) { //Read in variables from the custom MyThingDef FileLocationPrimary = ((Enhanced_Development.Stargate.StargateThingDef)def).FileLocationPrimary; FileLocationSecondary = ((Enhanced_Development.Stargate.StargateThingDef)def).FileLocationSecondary; //Log.Message("Setting FileLocationPrimary:" + FileLocationPrimary + " and FileLocationSecondary:" + FileLocationSecondary); } else { Log.Error("Stargate definition not of type \"StargateThingDef\""); } }