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); }
private void SetupNewCharacher() { this.Unit.Unit.View.UpdateAsks(); this.Unit.BirthDay = this.BirthDay; this.Unit.BirthMonth = this.BirthMonth; if (this.Doll != null) { this.Unit.Doll = this.Doll.CreateData(); this.Unit.LeftHandedOverride = new bool?(this.Doll.LeftHanded); } if (this.State.Mode != LevelUpState.CharBuildMode.PreGen) { ItemsCollection.DoWithoutEvents(delegate { LevelUpHelper.AddStartingItems(this.Unit); }); } else { this.Unit.Body.Initialize(); } this.Unit.AddStartingInventory(); foreach (Spellbook spellbook in this.Unit.Spellbooks) { spellbook.UpdateAllSlotsSize(true); int num = spellbook.GetTotalFreeSlotsCount(); for (int i = 0; i < 100; i++) { if (num <= 0) { break; } foreach (BlueprintAbility blueprint in BlueprintRoot.Instance.Progression.CharGenMemorizeSpells) { AbilityData data = new AbilityData(blueprint, spellbook); spellbook.Memorize(data, null); } int totalFreeSlotsCount = spellbook.GetTotalFreeSlotsCount(); if (num <= totalFreeSlotsCount) { break; } num = totalFreeSlotsCount; } } RestController.ApplyRest(this.Unit); if (this.Unit.IsCustomCompanion() && this.State.Mode != LevelUpState.CharBuildMode.Respec) { Game.Instance.EntityCreator.AddEntity(this.Unit.Unit, Game.Instance.Player.CrossSceneState); Game.Instance.Player.RemoteCompanions.Add(this.Unit.Unit); Game.Instance.Player.InvalidateCharacterLists(); this.Unit.Unit.IsInGame = false; this.Unit.Unit.AttachToViewOnLoad(null); if (this.Unit.Unit.View != null) { this.Unit.Unit.View.transform.SetParent(Game.Instance.DynamicRoot, true); } } }
static void ChooseRamp(UnitEntityData unitEntityData, DollState doll, string label, List <Texture2D> textures, int currentRamp, Action <int> setter) { ChooseFromList(label, textures, ref currentRamp, () => { setter(currentRamp); unitEntityData.Descriptor.Doll = doll.CreateData(); CharacterManager.RebuildCharacter(unitEntityData); }); }
static void ChooseEEL(UnitEntityData unitEntityData, DollState doll, string label, EquipmentEntityLink[] links, EquipmentEntityLink link, Action <EquipmentEntityLink> setter) { var index = links.ToList().FindIndex((eel) => eel.AssetId == link.AssetId); ChooseFromList(label, links, ref index, () => { setter(links[index]); unitEntityData.Descriptor.Doll = doll.CreateData(); CharacterManager.RebuildCharacter(unitEntityData); }); }
/* static void ChooseRace(UnitEntityData unitEntityData, DollState doll) * { * var currentRace = doll.Race; * var racess = new List<BlueprintRace> { }; * foreach(BlueprintRace race in BlueprintRoot.Instance.Progression.CharacterRaces) * { * racess.AddItem(race); * } * var races = racess.ToArray(); * foreach(BlueprintRace race in races) * { * Main.logger.Log(race.NameForAcronym); * } * /// var index = Array.FindIndex(races, (race) => race == currentRace); * var index = 1; * 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 void ChooseVisualPreset(UnitEntityData unitEntityData, DollState doll, string label, BlueprintRaceVisualPreset[] presets, BlueprintRaceVisualPreset currentPreset) { var index = Array.FindIndex(presets, (vp) => vp == currentPreset); ChooseFromList(label, presets, ref index, () => { doll.SetRacePreset(presets[index]); unitEntityData.Descriptor.Doll = doll.CreateData(); CharacterManager.RebuildCharacter(unitEntityData); }); }
static void ChooseEEL(UnitEntityData unitEntityData, DollState doll, string label, EquipmentEntityLink[] links, EquipmentEntityLink link, Action <EquipmentEntityLink> setter) { if (links.Length == 0) { GUILayout.Label($"Missing equipment for {label}"); } var index = links.ToList().FindIndex((eel) => eel != null && eel.AssetId == link?.AssetId); ChooseFromList(label, links, ref index, () => { setter(links[index]); unitEntityData.Descriptor.Doll = doll.CreateData(); CharacterManager.RebuildCharacter(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(); }
private TestLevelUpController([NotNull] UnitDescriptor unit, bool autoCommit, [CanBeNull] JToken unitJson, LevelUpState.CharBuildMode mode) { this.LevelUpActions = new List <ILevelUpAction>(); this.Unit = unit; this.AutoCommit = autoCommit; if (this.AutoCommit) { this.Preview = unit; } else { this.StartPreviewThread(unitJson); this.Preview = this.RequestPreview(); } this.State = new LevelUpState(this.Preview, mode); if ((this.State.Mode == LevelUpState.CharBuildMode.CharGen && !this.AutoCommit) || this.State.Mode == LevelUpState.CharBuildMode.Respec) { this.Doll = new DollState(); } this.ApplyLevelUpPlan(false); }
public void SetState(DollState state) { this.state = state; switch (state) { case DollState.Idle: skelAnim.AnimationName = "wait"; break; case DollState.Following: skelAnim.AnimationName = "move"; break; case DollState.Selected: skelAnim.AnimationName = "attack"; break; default: skelAnim.AnimationName = "wait"; break; } }
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); }