static void Postfix(CompColorable __instance) { if (__instance.parent.def.Equals(UmbrellaDefOf.Parasol) || __instance.parent.def.Equals(UmbrellaDefOf.FoldableParasol)) { __instance.Color = RandomColor(); } }
//public Graphic_RandomApparelMulti RandomGraphic //{ // get // { // if (this.isRandomizedGraphic) // { // return GraphicDatabase.Get<Graphic_Single>(this.def.graphicData.texPath, ShaderDatabase.CutoutComplex, this.def.graphicData.drawSize, this.DrawColor, this.DrawColorTwo) as Graphic_RandomApparelMulti; // } // return null; // } //} //public override Graphic Graphic //{ // get // { // if (this.isRandomizedGraphic) // { // return GraphicDatabase.Get<Graphic_Single>(this.randomGraphicPath, ShaderDatabase.CutoutComplex, this.def.graphicData.drawSize, this.DrawColor, this.DrawColorTwo) as Graphic_RandomApparelMulti; // } // return GraphicDatabase.Get<Graphic_Single>(this.def.graphicData.texPath, ShaderDatabase.CutoutComplex, this.def.graphicData.drawSize, this.DrawColor, this.DrawColorTwo); // } //} private void SetFactionColor(ref Color color, CompFactionColor compF) { if (this.Wearer != null) { if (udef != null) { if ((compF != null && compF.CProps.UseCamouflageColor)) { color = CamouflageColorsUtility.CamouflageColors[1]; } else { color = udef.FactionColor2; } } } else { CompColorable comp = this.GetComp <CompColorable>(); if (comp != null && comp.Active) { color = comp.Color; } } }
public static void PostFix(Thing t, Color newColor, bool reportFailure = true) { if (t.def.IsApparel && t.def.defName.StartsWith("CASFlak")) { CompColorable compColorable = ThingCompUtility.TryGetComp <CompColorable>(t); if (compColorable != null) { ThingDef def = t.def; bool flag; if (def == null) { flag = false; } else { GraphicData graphicData = def.graphicData; Color? color = (graphicData != null) ? new Color?(graphicData.color) : null; flag = (color != null); } if (flag) { Color color2 = t.def.graphicData.color; compColorable.Color = color2; } } } }
static void Postfix(PawnGraphicSet __instance) { CompRainbow isRainbow = __instance.pawn.TryGetComp <CompRainbow>(); if (isRainbow == null) { return; } long ticks = __instance.pawn.ageTracker.AgeBiologicalTicks; float speed = 1500f; float hue = (float)(ticks % speed) / speed; Color color = Color.HSVToRGB(hue, 1f, 1f); //Color color = new Color((float)(ticks % 255) / 255, 0.5f, 0.5f); CompColorable comp = __instance.pawn.TryGetComp <CompColorable>(); if (comp != null) { __instance.nakedGraphic = __instance.nakedGraphic.GetColoredVersion(__instance.nakedGraphic.Shader, color, Color.white); } }
// RimWorld.CharacterCardUtility public static void DrawCard(Rect rect, ThingWithComps selectedThing) { GUI.BeginGroup(rect); var compToggleDef = selectedThing.GetComp <CompToggleDef>(); if (compToggleDef != null) { var ts = Text.CalcSize(selectedThing.LabelCap).x; var y = rect.y; var rect2 = new Rect(rect.width / 2 - ts + SpacingOffset, y, rect.width, HeaderSize); y += rect2.height; Text.Font = GameFont.Medium; Widgets.Label(rect2, selectedThing.LabelCap); Text.Font = GameFont.Small; Widgets.ListSeparator(ref y, rect2.width, "Select one of the following:"); // add all the buttons for the toggle defs foreach (var td in compToggleDef.toggleDefs) { var rect3 = new Rect(0f, y, rect.width, 20f); var isactive = false; if (selectedThing.def == td) { isactive = true; } if (Widgets.RadioButtonLabeled(rect3, td.LabelCap, isactive)) { //Log.Message(".. change location to "+td.LabelCap); // CHange def then give it a new id. Hopefully nothing index on the id var map = selectedThing.Map; var loc = selectedThing.Position; var rot = selectedThing.Rotation; selectedThing.DeSpawn(); selectedThing.def = td; selectedThing.thingIDNumber = -1; ThingIDMaker.GiveIDTo(selectedThing); // necessary CompColorable colorable = selectedThing.TryGetComp <CompColorable>(); if (colorable != null) { colorable.Color = selectedThing.def.colorGenerator.NewRandomizedColor(); } // selectedThing.DrawColor = selectedThing.def.colorGenerator.NewRandomizedColor(); Graphic graphic = selectedThing.def.graphicData.GraphicColoredFor(selectedThing); GenSpawn.Spawn(selectedThing, loc, map, rot); FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); Traverse traverse = Traverse.Create(selectedThing); subgraphic.SetValue(selectedThing, graphic); Find.Selector.Select(selectedThing); break; } y += 25f; } } GUI.EndGroup(); }
public override void Initialize(CompProperties props) { base.Initialize(props); CompColorable comp = parent.GetComp <CompColorable>(); if (comp != null && !comp.active) { parent.GetComp <CompColorable>().active = true; } parent.Notify_ColorChanged(); }
public Graphic GetGraphic(Graphic other, bool wornGraphic = false, CompColorable colorable = null) { if (this.graphicData == null) { this.graphicData = new GraphicData(); } if (other.data != null) { CopyFrom(other.data); } if (!this.texPath.NullOrEmpty() && !wornGraphic) { this.graphicData.texPath = this.texPath; } else if (!this.wornGraphicPath.NullOrEmpty() && wornGraphic) { this.graphicData.texPath = this.wornGraphicPath; } this.graphicData.color = (this.color ?? other.color); this.graphicData.colorTwo = (this.colorTwo ?? other.colorTwo); if (colorable != null) { if (colorable is CompColorableTwo twocolor) { if (twocolor.Active) { this.graphicData.color = twocolor.Color; } if (twocolor.ActiveTwo) { this.graphicData.colorTwo = twocolor.ColorTwo; } } if (colorable is CompColorableTwoFaction twoFaction) { if (twoFaction.ActiveFaction && this.allowFactionColours) { if (twoFaction.FactionActive) { this.graphicData.color = twoFaction.Color; } if (twoFaction.FactionActiveTwo) { this.graphicData.colorTwo = twoFaction.ColorTwo; } } } } return(this.graphicData.Graphic); }
public override void DesignateSingleCell(IntVec3 loc) { var things = Find.VisibleMap.thingGrid.ThingsListAtFast(loc); foreach (var thing in things) { CompColorable compColorable = thing.TryGetComp <CompColorable>(); if (compColorable != null) { thing.SetColor(ClothesPaintToolMod.color); } } }
// Token: 0x0600002D RID: 45 RVA: 0x0000384C File Offset: 0x00001A4C public static Toil MakeUnfinishedThingIfNeeded() { Toil toil = new Toil(); toil.initAction = delegate() { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; bool flag = !curJob.RecipeDef.UsesUnfinishedThing; if (!flag) { bool flag2 = curJob.GetTarget(TargetIndex.B).Thing is UnfinishedThing; if (!flag2) { List <Thing> list = Toils_WPRecipe.CalculateIngredients(curJob, actor); string str = "ingredient list in toil_wprecipe"; List <Thing> list2 = list; Log.Message(str + ((list2 != null) ? list2.ToString() : null), false); Thing thing = Toils_WPRecipe.CalculateDominantIngredient(curJob, list); for (int i = 0; i < list.Count; i++) { Thing thing2 = list[i]; string str2 = "ingredient in toil_wprecipe"; Thing thing3 = list[i]; Log.Message(str2 + ((thing3 != null) ? thing3.ToString() : null), false); actor.Map.designationManager.RemoveAllDesignationsOn(thing2, false); bool spawned = thing2.Spawned; if (spawned) { thing2.DeSpawn(DestroyMode.Vanish); } } ThingDef stuff = (!curJob.RecipeDef.unfinishedThingDef.MadeFromStuff) ? null : thing.def; UnfinishedThing unfinishedThing = (UnfinishedThing)ThingMaker.MakeThing(curJob.RecipeDef.unfinishedThingDef, stuff); unfinishedThing.Creator = actor; unfinishedThing.BoundBill = (Bill_ProductionWithUft)curJob.bill; unfinishedThing.ingredients = list; CompColorable compColorable = unfinishedThing.TryGetComp <CompColorable>(); bool flag3 = compColorable != null; if (flag3) { compColorable.Color = thing.DrawColor; } GenSpawn.Spawn(unfinishedThing, curJob.GetTarget(TargetIndex.A).Cell, actor.Map, WipeMode.Vanish); curJob.SetTarget(TargetIndex.B, unfinishedThing); actor.Reserve(unfinishedThing, curJob, 1, -1, null, true); } } }; return(toil); }
public Graphic GetGraphic(GraphicData other, bool wornGraphic = false, CompColorable colorable = null) { if (this.graphicData == null) { this.graphicData = new GraphicData(); } CopyFrom(other); if (!this.texPath.NullOrEmpty()) { this.graphicData.texPath = this.texPath; } this.graphicData.color = (this.color ?? other.color); this.graphicData.colorTwo = (this.colorTwo ?? other.colorTwo); return(this.graphicData.Graphic); }
public static Color GetColor(this Thing thing) { ThingWithComps thingWithComps = thing as ThingWithComps; if (thingWithComps == null) { return(thing.DrawColor); } CompColorable comp = thingWithComps.GetComp <CompColorable>(); if (comp == null) { return(thing.DrawColor); } return(comp.Color); }
// Token: 0x06000062 RID: 98 RVA: 0x00006438 File Offset: 0x00004638 public static void CorrectActiveApparel(Apparel apparel, Pawn pawn = null) { Thing thing = ThingMaker.MakeThing(apparel.def, apparel.Stuff); if (QualityUtility.TryGetQuality(apparel, out QualityCategory qualityCategory)) { CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing); if (compQuality != null) { compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony); } } CompColorable compColorable = ThingCompUtility.TryGetComp <CompColorable>(apparel); if (compColorable != null) { CompColorable compColorable2 = ThingCompUtility.TryGetComp <CompColorable>(thing); if (compColorable2 != null) { compColorable2.Color = compColorable.Color; } } if (pawn != null) { pawn.apparel.Remove(apparel); apparel.Destroy(0); pawn.apparel.Wear(thing as Apparel, true, false); return; } if (apparel.Spawned) { IntVec3 intVec = IntVec3.Zero; Map map = apparel?.Map; if (map != null) { intVec = apparel.Position; } apparel.Destroy(0); if (intVec != IntVec3.Zero) { GenSpawn.Spawn(thing, intVec, map, 0); } } }
public static Toil MakeUnfinishedThingIfNeeded() { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; if (!curJob.RecipeDef.UsesUnfinishedThing) { return; } if (curJob.GetTarget(TargetIndex.B).Thing is UnfinishedThing) { return; } List <Thing> list = Toils_Recipe.CalculateIngredients(curJob, actor); Thing thing = Toils_Recipe.CalculateDominantIngredient(curJob, list); for (int i = 0; i < list.Count; i++) { Thing thing2 = list[i]; actor.Map.designationManager.RemoveAllDesignationsOn(thing2, false); if (thing2.Spawned) { thing2.DeSpawn(DestroyMode.Vanish); } } ThingDef stuff = (!curJob.RecipeDef.unfinishedThingDef.MadeFromStuff) ? null : thing.def; UnfinishedThing unfinishedThing = (UnfinishedThing)ThingMaker.MakeThing(curJob.RecipeDef.unfinishedThingDef, stuff); unfinishedThing.Creator = actor; unfinishedThing.BoundBill = (Bill_ProductionWithUft)curJob.bill; unfinishedThing.ingredients = list; CompColorable compColorable = unfinishedThing.TryGetComp <CompColorable>(); if (compColorable != null) { compColorable.Color = thing.DrawColor; } GenSpawn.Spawn(unfinishedThing, curJob.GetTarget(TargetIndex.A).Cell, actor.Map, WipeMode.Vanish); curJob.SetTarget(TargetIndex.B, unfinishedThing); actor.Reserve(unfinishedThing, curJob, 1, -1, null, true); }; return(toil); }
public void CreateLightCopy(string defname) { Pawn tmpPawn = GetPawn; if (GetPawn.equipment.Primary != null) //if primary equipped { if (GetPawn.equipment.Primary.TryGetComp <CompTakePhoto>() == null) // if primary not camera { if (GetPawn.equipment.Primary.TryGetComp <CompLightCopy>() != null) // if primary light copy { GetPawn.equipment.Primary.Destroy(); // destroy light copy } else { return; // primary is no camera or light copy } } else { MakeBox(); // primary is camera } } // new weapon with specific color ThingWithComps weaponToCreate = new ThingWithComps(); if (ThingDef.Named(defname).MadeFromStuff) { weaponToCreate = (ThingWithComps)ThingMaker.MakeThing(ThingDef.Named(defname), GenStuff.RandomStuffFor(ThingDef.Named(defname))); } else { weaponToCreate = (ThingWithComps)ThingMaker.MakeThing(ThingDef.Named(defname), null); } if (weaponToCreate.TryGetComp <CompQuality>() != null) { weaponToCreate.TryGetComp <CompQuality>().SetQuality(parent.TryGetComp <CompQuality>().Quality, ArtGenerationContext.Colony); } weaponToCreate.HitPoints = 1; if (weaponToCreate.TryGetComp <CompColorable>() == null) { CompColorable compColorable = new CompColorable { parent = weaponToCreate }; CompProperties compProps = new CompProperties { compClass = typeof(CompColorable) }; compColorable.Initialize(compProps); weaponToCreate.AllComps.Add(compColorable); } weaponToCreate.TryGetComp <CompColorable>().Color = Props.LightCopyColor; // remove certain special abilities from light copy weaponToCreate.AllComps.RemoveAll(x => x.GetType().Name.Equals("CompWeaponTransform")); // checking for string because "monster hunter rimworld" mod also has transformable weapons weaponToCreate.AllComps.RemoveAll(x => x.GetType().Equals(typeof(CompTakePhoto))); CompLightCopy rWBYLightCopyDestroyAbility = new CompLightCopy { parent = weaponToCreate }; CompProperties compProps2 = new CompProperties { compClass = typeof(CompLightCopy) }; rWBYLightCopyDestroyAbility.Initialize(compProps2); weaponToCreate.AllComps.Add(rWBYLightCopyDestroyAbility); if (!ConsumeAmmunition()) { return; } ListOfDifferentPhotos.Remove(defname); tmpPawn.equipment.AddEquipment(weaponToCreate); }
public static Toil MakeUnfinishedThingIfNeeded() { Toil toil = new Toil(); toil.initAction = () => { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; //Recipe doesn't use unfinished things if (!curJob.RecipeDef.UsesUnfinishedThing) { return; } //Already working on an unfinished thing if (curJob.GetTarget(JobDriver_DoBill.IngredientInd).Thing is UnfinishedThing) { return; } //Create the unfinished thing var ingredients = CalculateIngredients(curJob, actor); Thing dominantIngredient = CalculateDominantIngredient(curJob, ingredients); //Despawn ingredients. They will be saved inside the UFT //because these ingredients can come back out if the UFT is canceled for (int i = 0; i < ingredients.Count; i++) { var ingredient = ingredients[i]; actor.Map.designationManager.RemoveAllDesignationsOn(ingredient); if (ingredient.Spawned) { ingredient.DeSpawn(); } } //Store the dominant ingredient as the UnfinishedThing's stuff ThingDef stuff = curJob.RecipeDef.unfinishedThingDef.MadeFromStuff ? dominantIngredient.def : null; //Make the UFT and set its data UnfinishedThing uft = (UnfinishedThing)ThingMaker.MakeThing(curJob.RecipeDef.unfinishedThingDef, stuff); uft.Creator = actor; uft.BoundBill = (Bill_ProductionWithUft)curJob.bill; uft.ingredients = ingredients; CompColorable cc = uft.TryGetComp <CompColorable>(); if (cc != null) { cc.Color = dominantIngredient.DrawColor; } //Spawn the UFT GenSpawn.Spawn(uft, curJob.GetTarget(JobDriver_DoBill.BillGiverInd).Cell, actor.Map); //Set the job to use the unfinished thing as its only ingredient curJob.SetTarget(JobDriver_DoBill.IngredientInd, uft); //Reserve the unfinished thing actor.Reserve(uft, curJob); }; return(toil); }