public override void SpawnSetup() { base.SpawnSetup(); if (StoredBooks.Count <= 0 && MissingBooksList.Count <= 0) { ReadXML(); MiniGraphic = GraphicDatabase.Get <Graphic_Multi>("Clutter/Furniture/BookShelf/MiniBookShelf"); MiniGraphic.drawSize = def.graphicData.drawSize; } }
public static void Reload(Thing t, string texPath) { Graphic graphic = GraphicDatabase.Get(t.def.graphicData.graphicClass, texPath, ShaderDatabase.LoadShader(t.def.graphicData.shaderType.shaderPath), t.def.graphicData.drawSize, t.DrawColor, t.DrawColorTwo); typeof(Thing).GetField("graphicInt", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(t, graphic); if (t.Map != null) { t.DirtyMapMesh(t.Map); } }
public static void Postfix(Apparel apparel, BodyTypeDef bodyType, ref ApparelGraphicRecord rec) { if (apparel.def.apparel.wornGraphicPath.NullOrEmpty()) { return; } CompAdvancedGraphic comp = apparel.TryGetComp <CompAdvancedGraphic>(); CompQuality quality = apparel.TryGetComp <CompQuality>(); CompArt art = apparel.TryGetComp <CompArt>(); bool adv = comp != null; if (adv) { if (comp._graphic == null || comp._graphic.path.NullOrEmpty()) { bool flag = apparel.DefaultGraphic as Graphic_RandomRotated != null; if (flag) { // Log.Message(apparel.LabelShortCap + " as Graphic_RandomRotated"); Traverse traverse = Traverse.Create(apparel.DefaultGraphic); Graphic_AdvancedSingle subGraphic = AG_Thing_get_DefaultGraphic_CompAdvancedGraphic_Patch.subgraphic.GetValue(apparel.DefaultGraphic) as Graphic_AdvancedSingle; if (subGraphic != null) { // Log.Message(apparel.LabelShortCap + " as Graphic_AdvancedSingle"); comp._graphic = subGraphic.SubGraphicFor(apparel); } } else { comp._graphic = apparel.DefaultGraphic; return; } } string path = apparel.def.apparel.wornGraphicPath; Shader shader = ShaderDatabase.Cutout; if (apparel.def.apparel.useWornGraphicMask) { shader = ShaderDatabase.CutoutComplex; } if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead || apparel.def.apparel.wornGraphicPath == BaseContent.PlaceholderImagePath) { path = comp._graphic.path; } else { path = comp._graphic.path + "_" + bodyType.defName; } Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, shader, apparel.def.graphicData.drawSize, apparel.DrawColor, apparel.DrawColorTwo); rec = new ApparelGraphicRecord(graphic, apparel); } if (apparel.DrawColorTwo != Color.white) { rec.graphic = rec.graphic.GetColoredVersion(rec.graphic.Shader, apparel.DrawColor, apparel.DrawColorTwo); } }
private void UpdateGraphics() { if (axlesComp.HasAxles()) { string text = "Things/Pawn/" + def.defName + "/Wheel"; graphic_Wheel_Single = new Graphic_Single(); graphic_Wheel_Single = GraphicDatabase.Get <Graphic_Single>(text, def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Single; } }
private void GetGraphic() { if (graphicLinked?.MatSingle != null) { return; } var graphicSingle = GraphicDatabase.Get <Graphic_Single>(def.graphicData.texPath); graphicLinked = new Graphic_LinkedAirPipe(graphicSingle); }
internal static void LoadDiscoFloorGraphics(Building b) { var gd = b.DefaultGraphic.data; Graphic MakeUnlit(string path, Vector2 size) { return(GraphicDatabase.Get(gd.graphicClass, path, DiscoDefOf.Transparent.Shader, size, Color.white, Color.white, gd, gd.shaderParameters)); } DiscoFloorGlowGraphic = MakeUnlit("DSC/Effects/FloorGlow", Vector2.one); }
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 Graphic BackpackGraphic(BodyType bodyType, string graphicPath) { if (bodyType == BodyType.Undefined) { Log.Error("Getting naked body graphic with undefined body type."); bodyType = BodyType.Male; } string path = graphicPath + bodyType.ToString(); return(GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.CutoutComplex, Vector2.one, this.DrawColor, this.DrawColorTwo)); }
public PawnGraphicRenderer(float melanin) { Color skinColor = PawnSkinColors.GetSkinColor(this.melanin = melanin); Gender gender = (Rand.Value < 0.5f) ? Gender.Male : Gender.Female; CrownType crownType = (Rand.Value < 0.5f) ? CrownType.Average : CrownType.Narrow; HairDef hairDef = RandomHairDefFor(gender); Color hairColor = PawnHairColors.RandomHairColor(skinColor, 18); headGraphic = GraphicDatabaseHeadRecords.GetHeadRandom(gender, skinColor, crownType, false); hairGraphic = GraphicDatabase.Get <Graphic_Multi>(hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, hairColor); }
/// <summary> /// Import the graphics /// </summary> private void UpdateGraphics() { graphic_Body = new Graphic_Multi(); graphic_Handle = new Graphic_Multi(); graphic_Wheel = new Graphic_Multi(); graphic_Wheel = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Wheel", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo); graphic_Body = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cargo", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo); graphic_Handle = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Handle", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo); }
public virtual Graphic GetPath(Pawn pawn, ref int sharedIndex, int?savedIndex = new int?()) { string returnPath = string.Empty; int variantCounting = this.variantCount; foreach (BodyAddonPrioritization prio in this.Prioritization) { switch (prio) { case BodyAddonPrioritization.Backstory: if (this.backstoryGraphics?.FirstOrDefault(predicate: babgs => pawn.story.AllBackstories.Any(predicate: bs => bs.identifier == babgs.backstory)) is BodyAddonBackstoryGraphic babg) { returnPath = babg.path; variantCounting = babg.variantCount; } break; case BodyAddonPrioritization.Hediff: if (this.hediffGraphics?.FirstOrDefault(predicate: bahgs => pawn.health.hediffSet.hediffs.Any(predicate: h => h.def.defName == bahgs.hediff && (h.Part == null || this.bodyPart.NullOrEmpty() || (h.Part.untranslatedCustomLabel == this.bodyPart || h.Part.def.defName == this.bodyPart)))) is BodyAddonHediffGraphic bahg) { returnPath = bahg.path; variantCounting = bahg.variantCount; } break; default: throw new ArgumentOutOfRangeException(); } if (!returnPath.NullOrEmpty()) { break; } } if (returnPath.NullOrEmpty()) { returnPath = this.path; } ExposableValueTuple <Color, Color> channel = pawn.GetComp <AlienComp>().GetChannel(this.ColorChannel); int tv; return(!returnPath.NullOrEmpty() ? GraphicDatabase.Get <Graphic_Multi>(path: returnPath = (returnPath + ((tv = (savedIndex.HasValue ? (sharedIndex = savedIndex.Value) : (this.linkVariantIndexWithPrevious ? sharedIndex % variantCounting : (sharedIndex = Rand.Range(min: 0, max: variantCounting))))) == 0 ? "" : tv.ToString())), shader: ContentFinder <Texture2D> .Get(itemPath: returnPath + "_northm", reportFailure: false) == null ? this.ShaderType.Shader : ShaderDatabase.CutoutComplex, //ShaderDatabase.Transparent, drawSize: this.drawSize * 1.5f, color: channel.first, channel.second) : null); }
public static Graphic GetBodyOverlay(BodyType bodyType, string patronname) { if (bodyType == BodyType.Undefined) { bodyType = BodyType.Male; } string str = patronname + "_" + bodyType.ToString(); string path = "Things/Chaos/BodyOverlays/" + str; return(GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.CutoutComplex, Vector2.one, Color.white)); }
private void CreateAnim() { Frames = new Graphic_Single[maxCycles]; for (int i = 0; i < maxCycles; i++) { Frames[i] = GraphicDatabase.Get <Graphic_Single>(FramePath + (i + 1), this.def.graphicData.Graphic.Shader); Frames[i].drawSize = this.def.graphicData.drawSize; } DisableTex = GraphicDatabase.Get <Graphic_Single>(FramePath + 0, this.def.graphicData.Graphic.Shader); DisableTex.drawSize = this.def.graphicData.drawSize; }
public override void PostAdd(DamageInfo?dinfo) { base.PostAdd(dinfo); List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs; initialHediffCount = hediffs.Count; storeGraphic = this.pawn.Drawer.renderer.graphics.nakedGraphic; Graphic newGraphic = GraphicDatabase.Get <Graphic_Single>("Things/Pawn/Animal/AA_ArcticLion/AA_ArcticLion_Invisible", ShaderDatabase.Cutout, this.pawn.Drawer.renderer.graphics.nakedGraphic.drawSize, Color.white); this.pawn.Drawer.renderer.graphics.nakedGraphic = newGraphic; }
public override void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation) { if (!(thing is MinifiedThing)) { GraphicDatabase.Get <Graphic_Single>(thingDef.uiIconPath, ShaderTypeDefOf.EdgeDetect.Shader, thingDef.graphicData.drawSize, this.color, this.colorTwo) .DrawWorker(loc, rot, thingDef, thing, extraRotation); } else { base.DrawWorker(loc, rot, thingDef, thing, extraRotation); } }
// Token: 0x06000011 RID: 17 RVA: 0x00002C20 File Offset: 0x00001C20 static PlasmaGeothermalPlant() { checked { for (var i = 0; i < FrameCount; i++) { TexResFrames[i] = GraphicDatabase.Get <Graphic_Single>(FramePath + (i + 1), ThingDef.Named("CTSPlasmaGeothermalPlant").graphicData.Graphic.Shader); TexResFrames[i].drawSize = ThingDef.Named("CTSPlasmaGeothermalPlant").graphicData.drawSize; } } }
public static void ExportHairCut( HairDef hairDef, string name) { string path = MergedHairPath + name; if (!name.NullOrEmpty() && !File.Exists(path + "_Upperhead_south.png")) { LongEventHandler.ExecuteWhenFinished( delegate { Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, Color.white); SetTempTextures(graphic, out Texture2D temptexturefront, out Texture2D temptextureside, out Texture2D temptextureback, out Texture2D temptextureside2); Texture2D _maskTexFrontBack; Texture2D _maskTexSide; string upperPath = path + "_Upperhead"; if (temptexturefront.width == 256) { _maskTexFrontBack = FaceTextures.MaskTexUppherheadFrontBack256; _maskTexSide = FaceTextures.MaskTexUpperheadSide256; } else { _maskTexFrontBack = FaceTextures.MaskTexUppherheadFrontBack; _maskTexSide = FaceTextures.MaskTexUpperheadSide; } CutOutHair(_maskTexFrontBack, _maskTexSide, upperPath, ref temptexturefront, ref temptextureside, ref temptextureback, ref temptextureside2); SetTempTextures(graphic, out temptexturefront, out temptextureside, out temptextureback, out temptextureside2); string fullPath = path + "_Fullhead"; if (temptexturefront.width == 256) { _maskTexFrontBack = FaceTextures.MaskTexFullheadFrontBack256; _maskTexSide = FaceTextures.MaskTexFullheadSide256; } else { _maskTexFrontBack = FaceTextures.MaskTexFullheadFrontBack; _maskTexSide = FaceTextures.MaskTexFullheadSide; } CutOutHair(_maskTexFrontBack, _maskTexSide, fullPath, ref temptexturefront, ref temptextureside, ref temptextureback, ref temptextureside2); });
internal static void LoadFueledHeatingElementGraphics(Building b) { var gd = b.DefaultGraphic.data; Graphic Make(string path, bool unlit = false) { return(GraphicDatabase.Get(gd.graphicClass, path, unlit ? RFDefOf.TransparentPostLight.Shader : gd.shaderType.Shader, gd.drawSize, Color.white, Color.white, gd, gd.shaderParameters)); } HEFueledIdle = Make("RF/Buildings/HeatingElement_FueledIdle"); HEFueledGlow = Make("RF/Buildings/HeatingElement_FueledGlow"); }
//returns a custom hair texture based on the current hair texture public Material GetCustomHairMat(Pawn pawn, Rot4 facing) { var maxCoverageDef = this.getMaxCoverageDef(pawn); //find the def with max coverage //using IsHeadDef as the key to return a HeadCoverage type i.e. covered or not covered var headCoverage = this.headCoverages[maxCoverageDef.GetModExtension <BodyPartGroupDefExtension>().IsHeadDef]; //passing in the pawn & coverage level to get the custom texture path string texPath = headCoverage.GetTexPath(pawn, maxCoverageDef.GetModExtension <BodyPartGroupDefExtension>().CoverageLevel); return(GraphicDatabase.Get <Graphic_Multi>(texPath, ShaderDatabase.Cutout, Vector2.one, pawn.story.hairColor).MatAt(facing)); // Set new graphic }
internal static Graphic GetChildBodyGraphics(PawnGraphicSet graphicSet, Shader shader, Color skinColor) { string str = "Naked_Boy"; if (graphicSet.pawn.gender == Gender.Female) { str = "Naked_Girl"; } string path = "Things/Pawn/Humanlike/Children/Bodies/" + str; return(GraphicDatabase.Get <Graphic_Multi> (path, shader, Vector2.one, skinColor)); }
public static Graphic GetOffGraphic(ThingWithComps parent) { try { return(offGraphics[parent.def]); } catch (Exception) { var g = GraphicDatabase.Get(parent.def.graphicData.graphicClass, parent.def.graphicData.texPath + "_Off", parent.def.graphicData.shaderType.Shader, parent.def.graphicData.drawSize, parent.DrawColor, parent.DrawColorTwo); ajarGraphics.Add(parent.def, g); return(offGraphics[parent.def]); } }
//get lowest pixel as percentage of height, to account for different hair resolutions public static int GetBottomPixelPercentage(Pawn pawn, string texPath, Rot4 rot) { //load the current hair mat var material = GraphicDatabase.Get <Graphic_Multi>(texPath, ShaderDatabase.Cutout, Vector2.one, pawn.story.hairColor).MatAt(rot); //get current hair texture Texture2D hairTexture = getReadableTexture((Texture2D)material.mainTexture); //get the percentage above the bottom double percentage = ((double)getLowestPixel(hairTexture) / (double)hairTexture.height) * 100; return((int)percentage); }
public override void SpawnSetup() { base.SpawnSetup(); power = GetComp <CompPowerTrader>(); heater = GetComp <CompHeatPusher>(); nextTemperatureCheck = -(thingIDNumber % 20); compDef = def as PalComponentDef; drawMatrix.SetTRS(DrawPos + Altitudes.AltIncVect /**(1+thingIDNumber*0.0001f)*/, Gen.ToQuat(90), Vector3.one); animationFrames = LoadAnimation(); nullGraphic = GraphicDatabase.Get <Graphic_Single>(def.graphicData.texPath, def.graphic.Shader, def.graphicData.drawSize, Color.clear); drawPosHeatPie = DrawPos + Altitudes.AltIncVect * (1 + thingIDNumber * 0.0001f); heatPieMat = MaterialPool.MatFrom("UI/HeatPieRed", ShaderDatabase.ShaderFromType(ShaderType.MetaOverlay)); }
public override void Draw() { base.Draw(); if (powerComp.PowerOn && (Rotation == Rot4.South)) { Graphic screenGlow = GraphicDatabase.Get <Graphic_Single>("FX/MedPod_screenGlow_south", ShaderDatabase.MoteGlow, new Vector2(4f, 5f), Color.white); Mesh screenGlowMesh = screenGlow.MeshAt(Rotation); Vector3 screenGlowDrawPos = DrawPos; screenGlowDrawPos.y = AltitudeLayer.Building.AltitudeFor() + 0.03f; Graphics.DrawMesh(screenGlowMesh, screenGlowDrawPos, Quaternion.identity, FadedMaterialPool.FadedVersionOf(screenGlow.MatAt(Rotation, null), 1), 0); } }
private static void LoadGraphics(Building thing) { activeGraphics = new Graphic[FRAME_COUNT]; for (int i = 0; i < FRAME_COUNT; i++) { var gd = thing.DefaultGraphic.data; string num = (i * FRAME_STEP).ToString(); while (num.Length < 4) { num = '0' + num; } activeGraphics[i] = GraphicDatabase.Get(gd.graphicClass, $"AntimatterAnnihilation/Buildings/AlloyFusionMachine/{num}", gd.shaderType.Shader, gd.drawSize, Color.white, Color.white); } }
public Material ImplantMaterial(Pawn pawn, Rot4 bodyFacing) { string path; if (this.implantDrawProps.implantDrawerType == ImplantDrawerType.Head) { path = implantDrawProps.implantGraphicPath; } else { path = implantDrawProps.implantGraphicPath + "_" + pawn.story.bodyType.ToString(); } return(GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.Cutout, pawn.Graphic.drawSize, Color.white).MatAt(bodyFacing)); }
// My own methods internal static Graphic GetChildHeadGraphics(PawnGraphicSet graphicSet, Shader shader, Color skinColor) { Graphic_Multi graphic = null; string str = "Male_Average_Normal"; if (graphicSet.pawn.gender == Gender.Female) { str = "Female_Average_Normal"; } string path = "Things/Pawn/Humanlike/Children/Heads/" + str; graphic = GraphicDatabase.Get <Graphic_Multi> (path, shader, Vector2.one, skinColor) as Graphic_Multi; return(graphic); }
public void GetGraphicArray() { //Creating frame array AnimFrames = new Graphic_Single[FrameCount]; for (int i = 0; i < FrameCount; i++) { AnimFrames[i] = GraphicDatabase.Get <Graphic_Single>("Cupro/Anim/FountainWater" + (i + 1), ShaderDatabase.Transparent, def.graphicData.drawSize, new Color(1f, 1f, 1f, 0.65f)); } if (AnimFrames.Count() > 0) { currFrame = AnimFrames.FirstOrDefault(); } animOff = GraphicDatabase.Get <Graphic_Single>("Cupro/Anim/FountainWater0", ShaderDatabase.Transparent, def.graphicData.drawSize, new Color(1f, 1f, 1f, 0.65f)); }
public Material ImplantMaterial(Pawn pawn, Rot4 bodyFacing) { string path; if (this.Props.markDrawerType != MarkDrawerType.Body) { path = Props.markGraphicPath; } else { path = Props.markGraphicPath + "_" + pawn.story.bodyType.ToString(); } return(GraphicDatabase.Get <Graphic_Multi>(path, Props.shader, Props.drawSize, Props.color, Props.colorTwo).MatAt(bodyFacing)); }
static PipeOverlayMats() { TransmitterShader = ShaderDatabase.MetaOverlay; MatConnectorBase = MaterialPool.MatFrom("Things/Special/Fluid/VPE_OverlayBase", ShaderDatabase.MetaOverlay); MatConnectorLine = MaterialPool.MatFrom("Things/Special/Power/OverlayWire", ShaderDatabase.MetaOverlay); MatConnectorAnticipated = MaterialPool.MatFrom("Things/Special/Power/OverlayWireAnticipated", ShaderDatabase.MetaOverlay); MatConnectorBaseAnticipated = MaterialPool.MatFrom("Things/Special/Power/OverlayBaseAnticipated", ShaderDatabase.MetaOverlay); Graphic graphic = GraphicDatabase.Get <Graphic_Single>("Things/Special/Fluid/VPE_BlankTransmitterAtlas", TransmitterShader); LinkedOverlayGraphic = GraphicUtility.WrapLinked(graphic, LinkDrawerType.TransmitterOverlay); graphic.MatSingle.renderQueue = 3600; MatConnectorBase.renderQueue = 3600; MatConnectorLine.renderQueue = 3600; }