static void ChooseCompanionColor(CharacterSettings characterSettings, UnitEntityData unitEntityData) { if (GUILayout.Button("Create Doll", GUILayout.Width(DefaultLabelWidth))) { var race = unitEntityData.Descriptor.Progression.Race; var options = unitEntityData.Descriptor.Gender == Gender.Male ? race.MaleOptions : race.FemaleOptions; var dollState = new DollState(); dollState.SetRace(unitEntityData.Descriptor.Progression.Race); //Race must be set before class //This is a hack to work around harmony not allowing calls to the unpatched method CharacterManager.disableEquipmentClassPatch = true; dollState.SetClass(unitEntityData.Descriptor.Progression.GetEquipmentClass()); CharacterManager.disableEquipmentClassPatch = false; dollState.SetGender(unitEntityData.Descriptor.Gender); dollState.SetRacePreset(race.Presets[0]); unitEntityData.Descriptor.LeftHandedOverride = false; if (options.Hair.Length > 0) { dollState.SetHair(options.Hair[0]); } if (options.Heads.Length > 0) { dollState.SetHead(options.Hair[0]); } if (options.Beards.Length > 0) { dollState.SetBeard(options.Hair[0]); } dollState.Validate(); unitEntityData.Descriptor.Doll = dollState.CreateData(); unitEntityData.Descriptor.ForcceUseClassEquipment = true; CharacterManager.RebuildCharacter(unitEntityData); } GUILayout.Label("Note: Colors only applies to non-default outfits, the default companion custom voice is None"); { GUILayout.BeginHorizontal(); GUILayout.Label("Primary Outfit Color ", GUILayout.Width(DefaultLabelWidth)); var newIndex = (int)Math.Round(GUILayout.HorizontalSlider(characterSettings.companionPrimary, -1, 35, GUILayout.Width(DefaultSliderWidth)), 0); GUILayout.Label(" " + newIndex, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (newIndex != characterSettings.companionPrimary) { characterSettings.companionPrimary = newIndex; CharacterManager.UpdateModel(unitEntityData.View); } } { GUILayout.BeginHorizontal(); GUILayout.Label("Secondary Outfit Color ", GUILayout.Width(DefaultLabelWidth)); var newIndex = (int)Math.Round(GUILayout.HorizontalSlider(characterSettings.companionSecondary, -1, 35, GUILayout.Width(DefaultSliderWidth)), 0); GUILayout.Label(" " + newIndex, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (newIndex != characterSettings.companionSecondary) { characterSettings.companionSecondary = newIndex; CharacterManager.UpdateModel(unitEntityData.View); } } ChoosePortrait(unitEntityData); ChooseAsks(unitEntityData); }
static void ChooseRace(UnitEntityData unitEntityData, DollState doll) { var currentRace = doll.Race; var races = BlueprintRoot.Instance.Progression.CharacterRaces; var index = Array.FindIndex(races, (race) => race == currentRace); GUILayout.BeginHorizontal(); ChooseFromList("Race", races, ref index, () => { doll.SetRace(races[index]); unitEntityData.Descriptor.Doll = doll.CreateData(); CharacterManager.RebuildCharacter(unitEntityData); }); GUILayout.Label(" " + races[index].Name); GUILayout.EndHorizontal(); }
static private DollState CreateDollState(UnitEntityData unitEntityData) { var dollState = new DollState(); var dollData = unitEntityData.Descriptor.Doll; dollState.SetRace(unitEntityData.Descriptor.Progression.Race); //Race must be set before class //This is a hack to work around harmony not allowing calls to the unpatched method CharacterManager.disableEquipmentClassPatch = true; dollState.SetClass(unitEntityData.Descriptor.Progression.GetEquipmentClass()); CharacterManager.disableEquipmentClassPatch = false; dollState.SetGender(dollData.Gender); dollState.SetRacePreset(dollData.RacePreset); dollState.SetLeftHanded(dollData.LeftHanded); dollState.SetEquipColors(dollData.ClothesPrimaryIndex, dollData.ClothesSecondaryIndex); foreach (var assetID in dollData.EquipmentEntityIds) { if (head.ContainsKey(assetID)) { dollState.SetHead(head[assetID]); if (dollData.EntityRampIdices.ContainsKey(assetID)) { dollState.SetSkinColor(dollData.EntityRampIdices[assetID]); } } if (hair.ContainsKey(assetID)) { dollState.SetHair(hair[assetID]); if (dollData.EntityRampIdices.ContainsKey(assetID)) { dollState.SetHairColor(dollData.EntityRampIdices[assetID]); } } if (beard.ContainsKey(assetID)) { dollState.SetBeard(beard[assetID]); if (dollData.EntityRampIdices.ContainsKey(assetID)) { dollState.SetHairColor(dollData.EntityRampIdices[assetID]); } } if (skin.ContainsKey(assetID)) { if (dollData.EntityRampIdices.ContainsKey(assetID)) { dollState.SetSkinColor(dollData.EntityRampIdices[assetID]); } } if (horns.ContainsKey(assetID)) { dollState.SetHorn(horns[assetID]); if (dollData.EntityRampIdices.ContainsKey(assetID)) { dollState.SetHornsColor(dollData.EntityRampIdices[assetID]); } } if (skin.ContainsKey(assetID)) { if (dollData.EntityRampIdices.ContainsKey(assetID)) { dollState.SetSkinColor(dollData.EntityRampIdices[assetID]); } } if (classOutfits.ContainsKey(assetID)) { if (dollData.EntityRampIdices.ContainsKey(assetID) && dollData.EntitySecondaryRampIdices.ContainsKey(assetID)) { dollState.SetEquipColors(dollData.EntityRampIdices[assetID], dollData.EntitySecondaryRampIdices[assetID]); } } } dollState.Validate(); return(dollState); }