public virtual void Update() { try { RealTime.Update(); bool flag; LongEventHandler.LongEventsUpdate(out flag); if (flag) { this.destroyed = true; } else if (!LongEventHandler.ShouldWaitForEvent) { Rand.EnsureStateStackEmpty(); SteamManager.Update(); PortraitsCache.PortraitsCacheUpdate(); this.uiRoot.UIRootUpdate(); if (Time.frameCount > 3 && !Root.prefsApplied) { Root.prefsApplied = true; Prefs.Apply(); } this.soundRoot.Update(); MemoryTracker.Update(); } } catch (Exception e) { Log.Notify_Exception(e); throw; } }
public virtual void Update() { try { ResolutionUtility.Update(); RealTime.Update(); LongEventHandler.LongEventsUpdate(out var sceneChanged); if (sceneChanged) { destroyed = true; } else if (!LongEventHandler.ShouldWaitForEvent) { Rand.EnsureStateStackEmpty(); Widgets.EnsureMousePositionStackEmpty(); SteamManager.Update(); PortraitsCache.PortraitsCacheUpdate(); AttackTargetsCache.AttackTargetsCacheStaticUpdate(); Pawn_MeleeVerbs.PawnMeleeVerbsStaticUpdate(); Storyteller.StorytellerStaticUpdate(); CaravanInventoryUtility.CaravanInventoryUtilityStaticUpdate(); uiRoot.UIRootUpdate(); if (Time.frameCount > 3 && !prefsApplied) { prefsApplied = true; Prefs.Apply(); } soundRoot.Update(); } } catch (Exception arg) { Log.Error("Root level exception in Update(): " + arg); } }
public static void Androidify(Pawn pawn) { ThingDef_AlienRace alien = ThingDefOf.ChjAndroid as ThingDef_AlienRace; pawn.story.hairColor = alien.alienRace.generalSettings.alienPartGenerator.colorChannels.FirstOrDefault(channel => channel.name == "hair").first.NewRandomizedColor(); AlienComp alienComp = pawn.TryGetComp <AlienComp>(); if (alienComp != null) { alienComp.ColorChannels["skin"].first = alien.alienRace.generalSettings.alienPartGenerator.colorChannels.FirstOrDefault(channel => channel.name == "skin").first.NewRandomizedColor(); } PortraitsCache.SetDirty(pawn); PortraitsCache.PortraitsCacheUpdate(); //Add Android Hediff. pawn.health.AddHediff(HediffDefOf.ChjAndroidLike); //Remove old wounds and bad birthday related ones. List <Hediff> hediffs = pawn.health.hediffSet.hediffs.ToList(); foreach (Hediff hediff in hediffs) { if (hediff is Hediff_Injury injury && injury.IsPermanent()) { pawn.health.hediffSet.hediffs.Remove(injury); injury.PostRemoved(); pawn.health.Notify_HediffChanged(null); }
private void UpdatePortrate() { this.Pawn.Drawer.renderer.graphics.ResolveAllGraphics(); PortraitsCache.Clear(); PortraitsCache.PortraitsCacheUpdate(); this.PortraitNeedUpdate = false; }
public static void UpdateApparelGraphicsFor(Pawn pawn) { if (pawn != null) { pawn.Drawer.renderer.graphics.ResolveApparelGraphics(); PortraitsCache.SetDirty(pawn); PortraitsCache.Clear(); PortraitsCache.PortraitsCacheUpdate(); } }
public virtual void Update() { try { ResolutionUtility.Update(); RealTime.Update(); bool flag; LongEventHandler.LongEventsUpdate(out flag); if (flag) { this.destroyed = true; } else if (!LongEventHandler.ShouldWaitForEvent) { Rand.EnsureStateStackEmpty(); Widgets.EnsureMousePositionStackEmpty(); SteamManager.Update(); PortraitsCache.PortraitsCacheUpdate(); AttackTargetsCache.AttackTargetsCacheStaticUpdate(); Pawn_MeleeVerbs.PawnMeleeVerbsStaticUpdate(); Storyteller.StorytellerStaticUpdate(); CaravanInventoryUtility.CaravanInventoryUtilityStaticUpdate(); this.uiRoot.UIRootUpdate(); if (Time.frameCount > 3 && !Root.prefsApplied) { Root.prefsApplied = true; Prefs.Apply(); } this.soundRoot.Update(); try { MemoryTracker.Update(); } catch (Exception arg) { Log.Error("Error in MemoryTracker: " + arg, false); } try { MapLeakTracker.Update(); } catch (Exception arg2) { Log.Error("Error in MapLeakTracker: " + arg2, false); } } } catch (Exception arg3) { Log.Error("Root level exception in Update(): " + arg3, false); } }
public override void Apply(Pawn customTarget = null) { base.Apply(customTarget); Pawn targetPawn = null; if (customTarget != null) { targetPawn = customTarget; } else { targetPawn = customizationWindow.newAndroid; } AlienComp alienComp = targetPawn.TryGetComp <AlienComp>(); if (alienComp != null) { originalSkinColor = alienComp.ColorChannels["skin"].first; originalSkinColorTwo = alienComp.ColorChannels["skin"].second; alienComp.ColorChannels["skin"].first = def.newSkinColor; alienComp.ColorChannels["skin"].second = def.newSkinColor; if (customizationWindow != null) { customizationWindow.refreshAndroidPortrait = true; } else { PortraitsCache.SetDirty(targetPawn); PortraitsCache.PortraitsCacheUpdate(); } } else { Log.Error("alienComp is null! Impossible to alter skin color without it."); } }
private static void ChangeBodyType() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (BodyTypeDef bodyType in DefDatabase <BodyTypeDef> .AllDefs) { list.Add(new DebugMenuOption(bodyType.defName, DebugMenuOptionMode.Tool, delegate() { foreach (Pawn pawn in (from t in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()) where t is Pawn select t).Cast <Pawn>()) { pawn.story.bodyType = bodyType; PortraitsCache.SetDirty(pawn); PortraitsCache.PortraitsCacheUpdate(); pawn.Drawer.renderer.graphics.SetAllGraphicsDirty(); pawn.Drawer.renderer.graphics.ResolveAllGraphics(); DebugActionsUtility.DustPuffFrom(pawn); } })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public static Pawn MakePawnFromGenomeSequence(GenomeSequence genomeSequence, Thing creator) { //int adultAge = (int)genome.pawnKindDef.RaceProps.lifeStageAges.Last().minAge; QEEMod.TryLog("Generating pawn..."); PawnGenerationRequest request = new PawnGenerationRequest( genomeSequence.pawnKindDef, faction: creator.Faction, forceGenerateNewPawn: true, canGeneratePawnRelations: false, fixedGender: genomeSequence.gender, fixedBiologicalAge: 0, fixedChronologicalAge: 0, allowFood: false); Pawn pawn = PawnGenerator.GeneratePawn(request); //No pregenerated equipment. pawn?.equipment?.DestroyAllEquipment(); pawn?.apparel?.DestroyAll(); pawn?.inventory?.DestroyAll(); //No pregenerated hediffs. pawn.health.hediffSet.Clear(); //Add Hediff marking them as a clone. QEEMod.TryLog("Adding hediffs to generated pawn"); pawn.health.AddHediff(QEHediffDefOf.QE_CloneStatus); if (genomeSequence.hediffInfos != null && genomeSequence.hediffInfos.Count > 0) { //add hediffs to pawn from defs in HediffInfo class foreach (HediffInfo h in genomeSequence.hediffInfos) { pawn.health.AddHediff(h.def, h.part); } } //Set everything else. if (pawn.story is Pawn_StoryTracker storyTracker) { QEEMod.TryLog("Setting Pawn_StoryTracker attributes for generated pawn..."); storyTracker.bodyType = genomeSequence.bodyType; //sanity check to remove possibility of an Undefined crownType if (genomeSequence.crownType == CrownType.Undefined) { storyTracker.crownType = CrownType.Average; } else { storyTracker.crownType = genomeSequence.crownType; } storyTracker.hairColor = genomeSequence.hairColor; storyTracker.hairDef = genomeSequence.hair ?? PawnHairChooser.RandomHairDefFor(pawn, pawn.Faction.def); storyTracker.melanin = genomeSequence.skinMelanin; //headGraphicPath is private, so we need Harmony to set its value if (genomeSequence.headGraphicPath != null) { QEEMod.TryLog("Setting headGraphicPath for generated pawn"); AccessTools.Field(typeof(Pawn_StoryTracker), "headGraphicPath").SetValue(storyTracker, genomeSequence.headGraphicPath); } else { //could use this code to make a random head, instead of the static graphic paths. //AccessTools.Field(typeof(Pawn_StoryTracker), "headGraphicPath").SetValue(storyTracker, //GraphicDatabaseHeadRecords.GetHeadRandom(genomeSequence.gender, PawnSkinColors.GetSkinColor(genomeSequence.skinMelanin), genomeSequence.crownType).GraphicPath); QEEMod.TryLog("No headGraphicPath in genome template, setting to default head"); string path = genomeSequence.gender == Gender.Male ? "Things/Pawn/Humanlike/Heads/Male/Male_Average_Normal" : "Things/Pawn/Humanlike/Heads/Female/Female_Narrow_Normal"; AccessTools.Field(typeof(Pawn_StoryTracker), "headGraphicPath").SetValue(storyTracker, path); } storyTracker.traits.allTraits.Clear(); QEEMod.TryLog("Setting traits for generated pawn"); foreach (ExposedTraitEntry trait in genomeSequence.traits) { //storyTracker.traits.GainTrait(new Trait(trait.def, trait.degree)); storyTracker.traits.allTraits.Add(new Trait(trait.def, trait.degree)); if (pawn.workSettings != null) { pawn.workSettings.Notify_DisabledWorkTypesChanged(); } if (pawn.skills != null) { pawn.skills.Notify_SkillDisablesChanged(); } if (!pawn.Dead && pawn.RaceProps.Humanlike) { pawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty(); } } QEEMod.TryLog("Setting backstory for generated pawn"); //Give random vatgrown backstory. storyTracker.childhood = DefDatabase <BackstoryDef> .GetNamed("Backstory_ColonyVatgrown").GetFromDatabase(); storyTracker.adulthood = null; } if (pawn.skills is Pawn_SkillTracker skillsTracker) { foreach (SkillRecord skill in skillsTracker.skills) { skill.Level = 0; skill.passion = Passion.None; skill.Notify_SkillDisablesChanged(); } List <SkillRecord> skillPassions = new List <SkillRecord>(); int skillsPicked = 0; int iterations = 0; //Pick 4 random skills to give minor passions to. while (skillsPicked < 4 && iterations < 1000) { SkillRecord randomSkill = skillsTracker.skills.RandomElement(); if (!skillPassions.Contains(randomSkill)) { skillPassions.Add(randomSkill); randomSkill.passion = Passion.Minor; skillsPicked++; } iterations++; } skillsPicked = 0; iterations = 0; //Pick 2 random skills to give major passions to. while (skillsPicked < 2 && iterations < 1000) { SkillRecord randomSkill = skillsTracker.skills.RandomElement(); if (!skillPassions.Contains(randomSkill)) { skillPassions.Add(randomSkill); randomSkill.passion = Passion.Major; skillsPicked++; } iterations++; } } if (pawn.workSettings is Pawn_WorkSettings workSettings) { workSettings.EnableAndInitialize(); } //Alien Races compatibility. if (CompatibilityTracker.AlienRacesActive) { AlienRaceCompat.SetFieldsToAlienComp(pawn, genomeSequence); } PortraitsCache.SetDirty(pawn); PortraitsCache.PortraitsCacheUpdate(); return(pawn); }
public static Pawn MakePawnFromGenomeSequence(GenomeSequence genomeSequence, Thing creator) { //int adultAge = (int)genome.pawnKindDef.RaceProps.lifeStageAges.Last().minAge; PawnGenerationRequest request = new PawnGenerationRequest( genomeSequence.pawnKindDef, faction: creator.Faction, forceGenerateNewPawn: true, canGeneratePawnRelations: false, fixedGender: genomeSequence.gender, fixedBiologicalAge: 0, fixedChronologicalAge: 0, allowFood: false); Pawn pawn = PawnGenerator.GeneratePawn(request); //No pregenerated equipment. pawn?.equipment?.DestroyAllEquipment(); pawn?.apparel?.DestroyAll(); pawn?.inventory?.DestroyAll(); //No pregenerated hediffs. pawn.health.hediffSet.Clear(); //Set everything else. if (pawn.story is Pawn_StoryTracker storyTracker) { storyTracker.hairDef = DefDatabase <HairDef> .GetNamed("Shaved"); storyTracker.bodyType = genomeSequence.bodyType; storyTracker.crownType = genomeSequence.crownType; storyTracker.hairColor = genomeSequence.hairColor; storyTracker.melanin = genomeSequence.skinMelanin; storyTracker.traits.allTraits.Clear(); foreach (ExposedTraitEntry trait in genomeSequence.traits) { //storyTracker.traits.GainTrait(new Trait(trait.def, trait.degree)); storyTracker.traits.allTraits.Add(new Trait(trait.def, trait.degree)); if (pawn.workSettings != null) { pawn.workSettings.Notify_GainedTrait(); } if (pawn.skills != null) { pawn.skills.Notify_SkillDisablesChanged(); } if (!pawn.Dead && pawn.RaceProps.Humanlike) { pawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty(); } } //Give random vatgrown backstory. storyTracker.childhood = DefDatabase <BackstoryDef> .GetNamed("Backstory_ColonyVatgrown").GetFromDatabase(); storyTracker.adulthood = null; //Dirty hack ahoy! AccessTools.Field(typeof(Pawn_StoryTracker), "cachedDisabledWorkTypes").SetValue(storyTracker, null); //typeof(Pawn_StoryTracker).GetField("cachedDisabledWorkTypes", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(storyTracker, null); //typeof(PawnGenerator).GetMethod("GenerateSkills", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod).Invoke(null, new object[] { pawn }); } if (pawn.skills is Pawn_SkillTracker skillsTracker) { foreach (SkillRecord skill in skillsTracker.skills) { skill.Level = 0; skill.passion = Passion.None; skill.Notify_SkillDisablesChanged(); } List <SkillRecord> skillPassions = new List <SkillRecord>(); int skillsPicked = 0; int iterations = 0; //Pick 4 random skills to give minor passions to. while (skillsPicked < 4 && iterations < 1000) { SkillRecord randomSkill = skillsTracker.skills.RandomElement(); if (!skillPassions.Contains(randomSkill)) { skillPassions.Add(randomSkill); randomSkill.passion = Passion.Minor; skillsPicked++; } iterations++; } skillsPicked = 0; iterations = 0; //Pick 2 random skills to give major passions to. while (skillsPicked < 2 && iterations < 1000) { SkillRecord randomSkill = skillsTracker.skills.RandomElement(); if (!skillPassions.Contains(randomSkill)) { skillPassions.Add(randomSkill); randomSkill.passion = Passion.Major; skillsPicked++; } iterations++; } } if (pawn.workSettings is Pawn_WorkSettings workSettings) { workSettings.EnableAndInitialize(); } //Alien Races compatibility. if (CompatibilityTracker.AlienRacesActive) { AlienRaceCompat.SetFieldsToAlienComp(pawn, genomeSequence); } PortraitsCache.SetDirty(pawn); PortraitsCache.PortraitsCacheUpdate(); //Add Hediff marking them as a clone. pawn.health.AddHediff(QEHediffDefOf.QE_CloneStatus); return(pawn); }
public override void DoWindowContents(Rect inRect) { //Detect changes if (refreshAndroidPortrait) { newSleeve.Drawer.renderer.graphics.ResolveAllGraphics(); PortraitsCache.SetDirty(newSleeve); PortraitsCache.PortraitsCacheUpdate(); refreshAndroidPortrait = false; } Rect pawnRect = new Rect(inRect); pawnRect.width = PawnPortraitSize.x + 16f; pawnRect.height = PawnPortraitSize.y + 16f; pawnRect = inRect.RightHalf(); pawnRect = inRect.RightHalf(); pawnRect.x += 16f; pawnRect.y += 16f; //Draw Pawn stuff. if (newSleeve != null) { //Pawn Rect pawnRenderRect = new Rect(pawnRect.xMin + (pawnRect.width - PawnPortraitSize.x) / 2f - 10f, pawnRect.yMin + 20f, PawnPortraitSize.x, PawnPortraitSize.y); //GUI.DrawTexture(pawnRenderRect, PortraitsCache.Get(newSleeve, PawnPortraitSize, default(Vector3), 1f)); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0f, 0f, inRect.width, 32f), "AlteredCarbon.SleeveCustomization".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; //Saakra's Code //Gender Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(lblGender, "Gender".Translate() + ":"); if (Widgets.ButtonText(btnGenderMale, "Male".Translate().CapitalizeFirst())) { newSleeve = GetNewPawn(Gender.Male); } if (Widgets.ButtonText(btnGenderFemale, "Female".Translate().CapitalizeFirst())) { newSleeve = GetNewPawn(Gender.Female); } //Skin Colour Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(lblSkinColour, "SkinColour".Translate().CapitalizeFirst() + ":"); Widgets.DrawMenuSection(btnSkinColourOutline); Widgets.DrawShadowAround(btnSkinColourOutline); if (Widgets.ButtonInvisible(btnSkinColour1)) { newSleeve.story.melanin = 0.1f; UpdateSleeveGraphic(); } Widgets.DrawBoxSolid(btnSkinColour1, rgbConvert(242, 237, 224)); if (Widgets.ButtonInvisible(btnSkinColour2)) { newSleeve.story.melanin = 0.3f; UpdateSleeveGraphic(); } Widgets.DrawBoxSolid(btnSkinColour2, rgbConvert(255, 239, 213)); if (Widgets.ButtonInvisible(btnSkinColour3)) { newSleeve.story.melanin = 0.5f; UpdateSleeveGraphic(); } Widgets.DrawBoxSolid(btnSkinColour3, rgbConvert(255, 239, 189)); if (Widgets.ButtonInvisible(btnSkinColour4)) { newSleeve.story.melanin = 0.7f; UpdateSleeveGraphic(); } Widgets.DrawBoxSolid(btnSkinColour4, rgbConvert(228, 158, 90)); if (Widgets.ButtonInvisible(btnSkinColour5)) { newSleeve.story.melanin = 0.9f; UpdateSleeveGraphic(); } Widgets.DrawBoxSolid(btnSkinColour5, rgbConvert(130, 91, 48)); //Head Shape Widgets.Label(lblHeadShape, "HeadShape".Translate().CapitalizeFirst() + ":"); Widgets.DrawHighlight(btnHeadShapeOutline); if (ButtonTextSubtleCentered(btnHeadShapeArrowLeft, "<")) { if (newSleeve.gender == Gender.Male) { if (maleHeadTypeIndex == 0) { maleHeadTypeIndex = GraphicDatabaseHeadRecords.maleHeads.Count - 1; } else { maleHeadTypeIndex--; } typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story, GraphicDatabaseHeadRecords.maleHeads.ElementAt(maleHeadTypeIndex).graphicPath); } else if (newSleeve.gender == Gender.Female) { if (femaleHeadTypeIndex == 0) { femaleHeadTypeIndex = GraphicDatabaseHeadRecords.femaleHeads.Count - 1; } else { femaleHeadTypeIndex--; } typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story, GraphicDatabaseHeadRecords.femaleHeads.ElementAt(femaleHeadTypeIndex).graphicPath); } UpdateSleeveGraphic(); } if (ButtonTextSubtleCentered(btnHeadShapeSelection, "HeadTypeReplace".Translate())) { if (newSleeve.gender == Gender.Male) { FloatMenuUtility.MakeMenu <GraphicDatabaseHeadRecords.HeadGraphicRecord>(GraphicDatabaseHeadRecords.maleHeads, head => ExtractHeadLabels(head.graphicPath), (GraphicDatabaseHeadRecords.HeadGraphicRecord head) => delegate { typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story, head.graphicPath); UpdateSleeveGraphic(); }); } else if (newSleeve.gender == Gender.Female) { FloatMenuUtility.MakeMenu <GraphicDatabaseHeadRecords.HeadGraphicRecord>(GraphicDatabaseHeadRecords.femaleHeads, head => ExtractHeadLabels(head.graphicPath), (GraphicDatabaseHeadRecords.HeadGraphicRecord head) => delegate { typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story, head.graphicPath); UpdateSleeveGraphic(); }); } } if (ButtonTextSubtleCentered(btnHeadShapeArrowRight, ">")) { if (newSleeve.gender == Gender.Male) { if (maleHeadTypeIndex == GraphicDatabaseHeadRecords.maleHeads.Count - 1) { maleHeadTypeIndex = 0; } else { maleHeadTypeIndex++; } typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story, GraphicDatabaseHeadRecords.maleHeads.ElementAt(maleHeadTypeIndex).graphicPath); } else if (newSleeve.gender == Gender.Female) { if (femaleHeadTypeIndex == GraphicDatabaseHeadRecords.femaleHeads.Count - 1) { femaleHeadTypeIndex = 0; } else { femaleHeadTypeIndex++; } typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story, GraphicDatabaseHeadRecords.femaleHeads.ElementAt(femaleHeadTypeIndex).graphicPath); } UpdateSleeveGraphic(); } //Body Shape Widgets.Label(lblBodyShape, "BodyShape".Translate().CapitalizeFirst() + ":"); Widgets.DrawHighlight(btnBodyShapeOutline); if (ButtonTextSubtleCentered(btnBodyShapeArrowLeft, "<")) { if (newSleeve.gender == Gender.Male) { if (maleBodyTypeIndex == 0) { maleBodyTypeIndex = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).Count() - 1; } else { maleBodyTypeIndex--; } newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).ElementAt(maleBodyTypeIndex); } else if (newSleeve.gender == Gender.Female) { if (femaleBodyTypeIndex == 0) { femaleBodyTypeIndex = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).Count() - 1; } else { femaleBodyTypeIndex--; } newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).ElementAt(femaleBodyTypeIndex); } UpdateSleeveGraphic(); } if (ButtonTextSubtleCentered(btnBodyShapeSelection, "BodyTypeReplace".Translate())) { if (newSleeve.gender == Gender.Male) { IEnumerable <BodyTypeDef> bodyTypes = from bodyType in DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female) select bodyType; FloatMenuUtility.MakeMenu <BodyTypeDef>(bodyTypes, bodyType => bodyType.defName, (BodyTypeDef bodyType) => delegate { newSleeve.story.bodyType = bodyType; UpdateSleeveGraphic(); }); } else if (newSleeve.gender == Gender.Female) { IEnumerable <BodyTypeDef> bodyTypes = from bodyType in DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male) select bodyType; FloatMenuUtility.MakeMenu <BodyTypeDef>(bodyTypes, bodyType => bodyType.defName, (BodyTypeDef bodyType) => delegate { newSleeve.story.bodyType = bodyType; UpdateSleeveGraphic(); }); } } if (ButtonTextSubtleCentered(btnBodyShapeArrowRight, ">")) { if (newSleeve.gender == Gender.Male) { if (maleBodyTypeIndex == DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).Count() - 1) { maleBodyTypeIndex = 0; } else { maleBodyTypeIndex++; } newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).ElementAt(maleBodyTypeIndex); } else if (newSleeve.gender == Gender.Female) { if (femaleBodyTypeIndex == DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).Count() - 1) { femaleBodyTypeIndex = 0; } else { femaleBodyTypeIndex++; } newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).ElementAt(femaleBodyTypeIndex); } UpdateSleeveGraphic(); } //Hair Colour Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(lblHairColour, "HairColour".Translate().CapitalizeFirst() + ":"); Widgets.DrawMenuSection(btnHairColourOutlinePremade); Widgets.DrawShadowAround(btnHairColourOutlinePremade); Widgets.DrawBoxSolid(btnHairColour1, rgbConvert(51, 51, 51)); Widgets.DrawBoxSolid(btnHairColour2, rgbConvert(79, 71, 66)); Widgets.DrawBoxSolid(btnHairColour3, rgbConvert(64, 51, 38)); Widgets.DrawBoxSolid(btnHairColour4, rgbConvert(77, 51, 26)); Widgets.DrawBoxSolid(btnHairColour5, rgbConvert(90, 58, 32)); Widgets.DrawBoxSolid(btnHairColour6, rgbConvert(132, 83, 47)); Widgets.DrawBoxSolid(btnHairColour7, rgbConvert(193, 146, 85)); Widgets.DrawBoxSolid(btnHairColour8, rgbConvert(237, 202, 156)); if (Widgets.ButtonInvisible(btnHairColour1)) { setHair(rgbConvert(51, 51, 51)); } else if (Widgets.ButtonInvisible(btnHairColour2)) { setHair(rgbConvert(79, 71, 66)); } else if (Widgets.ButtonInvisible(btnHairColour3)) { setHair(rgbConvert(64, 51, 38)); } else if (Widgets.ButtonInvisible(btnHairColour4)) { setHair(rgbConvert(77, 51, 26)); } else if (Widgets.ButtonInvisible(btnHairColour5)) { setHair(rgbConvert(90, 58, 32)); } else if (Widgets.ButtonInvisible(btnHairColour6)) { setHair(rgbConvert(132, 83, 47)); } else if (Widgets.ButtonInvisible(btnHairColour7)) { setHair(rgbConvert(193, 146, 85)); } else if (Widgets.ButtonInvisible(btnHairColour8)) { setHair(rgbConvert(237, 202, 156)); } Widgets.DrawMenuSection(btnHairColourOutline); Widgets.DrawTextureFitted(btnHairColourOutline, texColor, 1); Widgets.DrawMenuSection(btnHairColourOutline2); Widgets.DrawTextureFitted(btnHairColourOutline2, texDarkness, 1); //if click in texColour box if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Mouse.IsOver(btnHairColourOutline)) { Vector2 mPos = Event.current.mousePosition; float x = mPos.x - btnHairColourOutline.x; float y = mPos.y - btnHairColourOutline.y; //Log.Message(x.ToString()); //Log.Message(y.ToString()); setHair(texColor.GetPixel(Convert.ToInt32(x), Convert.ToInt32(btnHairColourOutline.height - y))); Event.current.Use(); } //if click in Darkness box if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Mouse.IsOver(btnHairColourOutline2)) { Vector2 mPos = Event.current.mousePosition; float x = mPos.x - btnHairColourOutline2.x; float y = mPos.y - btnHairColourOutline2.y; //Log.Message(x.ToString()); //Log.Message(y.ToString()); selectedColorFinal = texDarkness.GetPixel(Convert.ToInt32(x), Convert.ToInt32(btnHairColourOutline2.height - y)); updateColors(); newSleeve.story.hairColor = selectedColorFinal; refreshAndroidPortrait = true; Event.current.Use(); } //Hair Type Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(lblHairType, "HairType".Translate().CapitalizeFirst() + ":"); Widgets.DrawHighlight(btnHairTypeOutline); if (ButtonTextSubtleCentered(btnHairTypeArrowLeft, "<")) { if (hairTypeIndex == 0) { hairTypeIndex = DefDatabase <HairDef> .AllDefs.Count() - 1; } else { hairTypeIndex--; } newSleeve.story.hairDef = DefDatabase <HairDef> .AllDefs.ElementAt(hairTypeIndex); UpdateSleeveGraphic(); } if (ButtonTextSubtleCentered(btnHairTypeSelection, newSleeve.story.hairDef.LabelCap)) { IEnumerable <HairDef> hairs = from hairdef in DefDatabase <HairDef> .AllDefs select hairdef; FloatMenuUtility.MakeMenu <HairDef>(hairs, hairDef => hairDef.LabelCap, (HairDef hairDef) => delegate { newSleeve.story.hairDef = hairDef; UpdateSleeveGraphic(); }); } if (ButtonTextSubtleCentered(btnHairTypeArrowRight, ">")) { if (hairTypeIndex == DefDatabase <HairDef> .AllDefs.Count() - 1) { hairTypeIndex = 0; } else { hairTypeIndex++; } newSleeve.story.hairDef = DefDatabase <HairDef> .AllDefs.ElementAt(hairTypeIndex); UpdateSleeveGraphic(); } //Time to Grow Widgets.Label(lblTimeToGrow, "TimeToGrow".Translate().CapitalizeFirst() + ": " + GenDate.ToStringTicksToDays(baseTicksToGrow + baseTicksToGrow2 + baseTicksToGrow3));//PUT TIME TO GROW INFO HERE //Require Biomass Widgets.Label(lblRequireBiomass, "RequireBiomass".Translate().CapitalizeFirst() + ": " + (baseMeatCost + baseMeatCost2 + baseMeatCost3));//PUT REQUIRED BIOMASS HERE //Vertical Divider //Widgets.DrawLineVertical((pawnBox.x + (btnGenderFemale.x + btnGenderFemale.width)) / 2, pawnBox.y, InitialSize.y - pawnBox.y - (buttonHeight + 53)); //Pawn Box Widgets.DrawMenuSection(pawnBox); Widgets.DrawShadowAround(pawnBox); GUI.DrawTexture(pawnBoxPawn, PortraitsCache.Get(newSleeve, pawnBoxPawn.size, default(Vector3), 1f)); //Levels of Beauty Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(lblLevelOfBeauty, "LevelOfBeauty".Translate().CapitalizeFirst() + ": " + beautyLevel); if (Widgets.ButtonText(btnLevelOfBeauty1, "1")) { RemoveAllTraits(newSleeve); newSleeve.story.traits.GainTrait(new Trait(TraitDefOf.Beauty, -2)); baseTicksToGrow2 = -420000; baseMeatCost2 = -50; beautyLevel = 1; } if (Widgets.ButtonText(btnLevelOfBeauty2, "2")) { RemoveAllTraits(newSleeve); baseTicksToGrow2 = 0; baseMeatCost2 = 0; beautyLevel = 2; } if (Widgets.ButtonText(btnLevelOfBeauty3, "3")) { RemoveAllTraits(newSleeve); newSleeve.story.traits.GainTrait(new Trait(TraitDefOf.Beauty, 2)); baseTicksToGrow2 = 420000; baseTicksToGrow2 = 420; baseMeatCost2 = 50; beautyLevel = 3; } //Levels of Quality Widgets.Label(lblLevelOfQuality, "LevelofQuality".Translate().CapitalizeFirst() + ": " + qualityLevel); if (Widgets.ButtonText(btnLevelOfQuality1, "1")) { baseTicksToGrow3 = -420000; baseMeatCost3 = -50; RemoveAllHediffs(newSleeve); newSleeve.health.AddHediff(AlteredCarbonDefOf.AC_Sleeve_Quality_Low, null); qualityLevel = 1; } if (Widgets.ButtonText(btnLevelOfQuality2, "2")) { baseTicksToGrow3 = 0; baseMeatCost3 = 0; RemoveAllHediffs(newSleeve); newSleeve.health.AddHediff(AlteredCarbonDefOf.AC_Sleeve_Quality_Standart, null); qualityLevel = 2; } if (Widgets.ButtonText(btnLevelOfQuality3, "3")) { baseTicksToGrow3 = 420000; baseTicksToGrow3 = 420; baseMeatCost3 = 50; RemoveAllHediffs(newSleeve); newSleeve.health.AddHediff(AlteredCarbonDefOf.AC_Sleeve_Quality_High, null); qualityLevel = 3; } if (Widgets.ButtonText(btnAccept, "Accept".Translate().CapitalizeFirst())) { sleeveGrower.StartGrowth(newSleeve, baseTicksToGrow + baseTicksToGrow2 + baseTicksToGrow3, baseMeatCost + baseMeatCost2 + baseMeatCost3); this.Close(); } if (Widgets.ButtonText(btnCancel, "Cancel".Translate().CapitalizeFirst())) { this.Close(); } } Text.Anchor = TextAnchor.UpperLeft; }
public void UpdateSleeveGraphic() { newSleeve.Drawer.renderer.graphics.ResolveAllGraphics(); PortraitsCache.SetDirty(newSleeve); PortraitsCache.PortraitsCacheUpdate(); }