public Color SkinColor(Pawn alien, bool first = true) { AlienComp alienComp = alien.TryGetComp <AlienComp>(); ExposableValueTuple <Color, Color, Color> skinColors = alienComp.GetChannel(channel: "skin"); return(first ? skinColors.first : skinColors.second); }
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); }
public Color SkinColor(Pawn alien, bool first = true) { AlienComp alienComp = alien.TryGetComp <AlienComp>(); if (alienComp.skinColor == Color.clear) { alienComp.skinColor = (this.alienskincolorgen != null ? this.alienskincolorgen.NewRandomizedColor() : PawnSkinColors.GetSkinColor(alien.story.melanin)); alienComp.skinColorSecond = (this.alienskinsecondcolorgen != null ? this.alienskinsecondcolorgen.NewRandomizedColor() : alienComp.skinColor); } return(first ? alienComp.skinColor : alienComp.skinColorSecond); }
private static void RegenerateColorchannels() { foreach (Pawn pawn in Find.CurrentMap.mapPawns.AllPawns) { AlienComp comp = pawn.TryGetComp <AlienComp>(); if (comp != null) { comp.colorChannels = null; } } }
public static void SetFieldsToAlienComp(Pawn pawn, GenomeSequence genomeSequence) { AlienComp alienComp = pawn.TryGetComp <AlienComp>(); if (alienComp != null) { alienComp.skinColor = genomeSequence.skinColor; alienComp.skinColorSecond = genomeSequence.skinColorSecond; alienComp.hairColorSecond = genomeSequence.hairColorSecond; alienComp.crownType = genomeSequence.crownTypeAlien; } }
public static void GetFieldsFromAlienComp(Pawn pawn, GenomeSequence genomeSequence) { AlienComp alienComp = pawn.TryGetComp <AlienComp>(); if (alienComp != null) { genomeSequence.isAlien = true; genomeSequence.skinColor = alienComp.skinColor; genomeSequence.skinColorSecond = alienComp.skinColorSecond; genomeSequence.hairColorSecond = alienComp.hairColorSecond; genomeSequence.crownTypeAlien = alienComp.crownType; } }
public Color SkinColor(Pawn alien, bool first = true) { AlienComp alienComp = alien.TryGetComp <AlienComp>(); if (alienComp.skinColor != Color.clear) { return(first ? alienComp.skinColor : alienComp.skinColorSecond); } alienComp.skinColor = this.alienskincolorgen?.NewRandomizedColor() ?? PawnSkinColors.GetSkinColor(melanin: alien.story.melanin); alienComp.skinColorSecond = this.alienskinsecondcolorgen?.NewRandomizedColor() ?? alienComp.skinColor; return(first ? alienComp.skinColor : alienComp.skinColorSecond); }
internal override void SetCrownType(object value) { //AlienPartGenerator apg = (base.Pawn.def as ThingDef_AlienRace)?.alienRace?.generalSettings?.alienPartGenerator; AlienComp ac = base.Pawn.TryGetComp <AlienComp>(); if (ac != null) { var split = value.ToString().Split('/'); if (split.Count() > 0) { ac.crownType = split.Last().Replace("Male_", "").Replace("Female_", ""); typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this.Pawn.story, value); } } }
public Color SkinColor(Pawn alien, int channel = 1) { AlienComp alienComp = alien.TryGetComp <AlienComp>(); ExposableValueTuple <Color, Color, Color> skinColors = alienComp.GetChannel(channel: "skin"); switch (channel) { default: return(skinColors.first); case 2: return(skinColors.second); case 3: return(skinColors.third); } }
public static void SetFieldsToAlienComp(Pawn pawn, GenomeSequence genomeSequence) { AlienComp alienComp = pawn.TryGetComp <AlienComp>(); if (alienComp != null) { alienComp.GetChannel("skin").first = genomeSequence.skinColor; alienComp.GetChannel("skin").second = genomeSequence.skinColorSecond; alienComp.GetChannel("hair").second = genomeSequence.hairColorSecond; alienComp.crownType = genomeSequence.crownTypeAlien; if (genomeSequence.addonVariants.Count > 0) { alienComp.addonVariants = genomeSequence.addonVariants; } } }
public override void Undo() { base.Undo(); AlienComp alienComp = customizationWindow.newAndroid.TryGetComp <AlienComp>(); if (alienComp != null) { alienComp.ColorChannels["skin"].first = originalSkinColor; alienComp.ColorChannels["skin"].second = originalSkinColorTwo; customizationWindow.refreshAndroidPortrait = true; } else { Log.Error("alienComp is null! Impossible to alter skin color without it."); } }
public static void GetFieldsFromAlienComp(Pawn pawn, GenomeSequence genomeSequence) { AlienComp alienComp = pawn.TryGetComp <AlienComp>(); if (alienComp != null) { genomeSequence.isAlien = true; genomeSequence.skinColor = alienComp.GetChannel("skin").first; genomeSequence.skinColorSecond = alienComp.GetChannel("skin").second; genomeSequence.hairColorSecond = alienComp.GetChannel("hair").second; genomeSequence.crownTypeAlien = alienComp.crownType; if (alienComp.addonVariants != null && alienComp.addonVariants.Count > 0) { genomeSequence.addonVariants = alienComp.addonVariants; } } }
public Color SkinColor(Pawn alien, int number = 1) { AlienComp alienComp = alien.TryGetComp <AlienComp>(); ExposableValueTuple <Color, Color, Color> skinColors = alienComp.GetChannel(channel: "skin"); if (number == 1) { return(skinColors.first); } if (number == 2) { return(skinColors.second); } if (number == 3) { return(skinColors.third); } return(skinColors.first); //return first ? skinColors.first : skinColors.second; }
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."); } }
protected override void Initialize() { AlienComp ac = base.Pawn.TryGetComp <AlienComp>(); if (ac == null || !(base.Pawn.def is ThingDef_AlienRace ar)) { Log.Error("Failed to get alien race for " + base.Pawn.Name.ToStringShort); return; } AlienSettings raceSettings = ar.alienRace; GeneralSettings generalSettings = raceSettings?.generalSettings; if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserAlienSkinColor)) { #if ALIEN_DEBUG Log.Warning("AlienDresserDTO.initialize - start"); #endif if (raceSettings != null) { HairSettings hairSettings = raceSettings.hairSettings; var c = ac.GetChannel("skin"); if (c != null) { base.AlienSkinColorPrimary = new SelectionColorWidgetDTO(c.first); base.AlienSkinColorPrimary.SelectionChangeListener += this.PrimarySkinColorChange; base.AlienSkinColorSecondary = new SelectionColorWidgetDTO(c.second); base.AlienSkinColorPrimary.SelectionChangeListener += this.SecondarySkinColorChange; } if (hairSettings?.hasHair == true) { base.HairColorSelectionDto = new HairColorSelectionDTO(this.Pawn.story.hairColor, IOUtil.LoadColorPresets(ColorPresetType.Hair)); base.HairColorSelectionDto.SelectionChangeListener += this.PrimaryHairColorChange; ColorPresetsDTO hairColorPresets = IOUtil.LoadColorPresets(ColorPresetType.Hair); if (GradientHairColorUtil.IsGradientHairAvailable) { if (!GradientHairColorUtil.GetGradientHair(this.Pawn, out bool enabled, out Color color)) { enabled = false; color = Color.white; } base.GradientHairColorSelectionDto = new HairColorSelectionDTO(color, hairColorPresets, enabled); base.GradientHairColorSelectionDto.SelectionChangeListener += this.GradientHairColorChange; } } } } if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserHair)) { if (raceSettings != null) { HairSettings hairSettings = raceSettings.hairSettings; base.HasHair = hairSettings?.hasHair == true; #if ALIEN_DEBUG Log.Warning("initialize - got hair settings: HasHair = " + base.HasHair); #endif if (base.HasHair) { List <string> hairTags = hairSettings.hairTags; if (hairTags != null) { IEnumerable <HairDef> hairDefs = from hair in DefDatabase <HairDef> .AllDefs where hair.hairTags.SharesElementWith(hairTags) select hair; #if ALIEN_DEBUG System.Text.StringBuilder sb = new System.Text.StringBuilder("Hair Defs: "); foreach (HairDef d in hairDefs) { sb.Append(d.defName); sb.Append(", "); } Log.Warning("initialize - " + sb.ToString()); #endif /*if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserHair)) * { * if (hairSettings != null) * { * List<string> filter = (List<string>)hairSettings.GetType().GetField("hairTags")?.GetValue(hairSettings); * base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender, filter); * } * }*/ base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender, hairDefs); } else { base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender); } } else { #if ALIEN_DEBUG Log.Warning("initialize - remove hair editors"); #endif base.EditorTypeSelectionDto.Remove(CurrentEditorEnum.ChangeDresserHair);//, CurrentEditorEnum.ChangeDresserAlienHairColor); #if ALIEN_DEBUG Log.Warning("initialize - hair editors removed"); #endif } } } if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserBody)) { var apg = generalSettings?.alienPartGenerator; if (apg != null) { List <string> crownTypes = apg.aliencrowntypes; if (ac.crownType != null && ac.crownType != "" && crownTypes?.Count > 1) { this.HeadTypeSelectionDto = new HeadTypeSelectionDTO(ac.crownType, this.Pawn.gender, crownTypes); } List <BodyTypeDef> alienbodytypes = apg.alienbodytypes; if (alienbodytypes != null && alienbodytypes.Count > 1) { this.BodyTypeSelectionDto = new BodyTypeSelectionDTO(this.Pawn.story.bodyType, this.Pawn.gender, alienbodytypes); } else { Log.Warning("No alien body types found. Defaulting to human."); this.BodyTypeSelectionDto = new BodyTypeSelectionDTO(this.Pawn.story.bodyType, this.Pawn.gender); } } if (generalSettings.maleGenderProbability > 0f && generalSettings.maleGenderProbability < 1f) { base.GenderSelectionDto = new GenderSelectionDTO(base.Pawn.gender); base.GenderSelectionDto.SelectionChangeListener += GenderChange; } #if ALIEN_DEBUG Log.Warning("initialize - done"); #endif } }
public static void DrawAddons(bool portrait, Pawn pawn, Vector3 vector) { if (pawn.def is ThingDef_AlienRace alienProps) { List <BodyAddon> addons = alienProps.alienRace.generalSettings.alienPartGenerator.bodyAddons; AlienComp alienComp = pawn.GetComp <AlienComp>(); for (int i = 0; i < addons.Count; i++) { BodyAddon ba = addons[i]; if (ba.CanDrawAddon(pawn)) { Mesh mesh = portrait ? ba.addonPortraitMeshFlipped : ba.addonMesh; Rot4 rotation = pawn.Rotation; if (portrait) { rotation = Rot4.South; } RotationOffset offset = rotation == Rot4.South ? ba.offsets.front : rotation == Rot4.North ? ba.offsets.back : ba.offsets.side; // Log.Message("front: " + (offset == ba.offsets.front).ToString() + "\nback: " + (offset == ba.offsets.back).ToString() + "\nside :" + (offset == ba.offsets.side).ToString()); Vector2 bodyOffset = offset?.bodyTypes?.FirstOrDefault(to => to.BodyTypeDef == pawn.story.bodyType) ?.offset ?? Vector2.zero; Vector2 crownOffset = offset?.crownTypes?.FirstOrDefault(to => to.crownType == alienComp.crownType)?.offset ?? Vector2.zero; // front 0.42f, -0.3f, -0.22f // back 0f, 0.3f, -0.55f // side -0.42f, -0.3f, -0.22f float MoffsetX = 0.42f; float MoffsetZ = -0.22f; float MoffsetY = ba.inFrontOfBody ? 0.3f : -0.3f; float num = ba.angle; if (rotation == Rot4.North) { MoffsetX = 0f; MoffsetY = !ba.inFrontOfBody ? 0.3f : -0.3f; MoffsetZ = -0.55f; num = 0; } MoffsetX += bodyOffset.x + crownOffset.x; MoffsetZ += bodyOffset.y + crownOffset.y; if (rotation == Rot4.East) { MoffsetX = -MoffsetX; num = -num; // Angle mesh = ba.addonMeshFlipped; } Vector3 scaleVector = new Vector3(MoffsetX, MoffsetY, MoffsetZ); scaleVector.x *= 1f + (1f - (portrait ? alienProps.alienRace.generalSettings.alienPartGenerator .customPortraitDrawSize : alienProps.alienRace.generalSettings.alienPartGenerator .customDrawSize).x); scaleVector.z *= 1f + (1f - (portrait ? alienProps.alienRace.generalSettings.alienPartGenerator .customPortraitDrawSize : alienProps.alienRace.generalSettings.alienPartGenerator .customDrawSize).y); GenDraw.DrawMeshNowOrLater( mesh, vector + scaleVector, Quaternion.AngleAxis(num, Vector3.up), alienComp.addonGraphics[i].MatAt(rotation), portrait); } } } }