public CharacterCode CreateFrom(FacGenRecordData item) { CharacterCode characterCode = CharacterCode.CreateEmpty(); BodyProperties bodyProperties = BodyProperties.Default; BodyProperties.FromString(item.BodyPropertiesString, out bodyProperties); characterCode.BodyProperties = bodyProperties; string text = new Equipment().CalculateEquipmentCode(); ReflectUtils.ReflectPropertyAndSetValue("EquipmentCode", text, characterCode); ReflectUtils.ReflectPropertyAndSetValue("IsHero", true, characterCode); MBStringBuilder mBStringBuilder = default(MBStringBuilder); mBStringBuilder.Initialize(16, "CreateFrom"); mBStringBuilder.Append <string>("@---@"); mBStringBuilder.Append <string>(text); mBStringBuilder.Append <string>("@---@"); mBStringBuilder.Append <string>(characterCode.BodyProperties.ToString()); mBStringBuilder.Append <string>("@---@"); mBStringBuilder.Append <string>(item.IsFemale ? "1" : "0"); mBStringBuilder.Append <string>("@---@"); mBStringBuilder.Append <string>(characterCode.IsHero ? "1" : "0"); mBStringBuilder.Append <string>("@---@"); mBStringBuilder.Append <string>(((int)characterCode.FormationClass).ToString()); mBStringBuilder.Append <string>("@---@"); ReflectUtils.ReflectPropertyAndSetValue("Code", mBStringBuilder.ToStringAndRelease(), characterCode); return(characterCode); }
public void ExecuteLoadSelected() { if (null != this._lastSelectedItem) { InformationUtils.ShowComfirInformation(new TextObject("{=tips_cr_ConfirmLoad}Confirm to load"), null, () => { String propertiesString = this._lastSelectedItem.GetFacGenRecordData().BodyPropertiesString; BodyProperties bodyProperties = BodyProperties.Default; BodyProperties.FromString(propertiesString, out bodyProperties); this._generatorView.DataSource.SetBodyProperties(bodyProperties, !TaleWorlds.Core.FaceGen.ShowDebugValues, -1, true); this._generatorView.DataSource.SelectedGender = this._lastSelectedItem.GetFacGenRecordData().IsFemale ? 1 : 0; }); } }
private void btnBodyPropsPaste_Click(object sender, EventArgs e) { var hero = selectedHero; if (hero != null) { var props = Clipboard.GetText(); if (BodyProperties.FromString(props, out var bp)) { hero.CharacterObject.UpdatePlayerCharacterBodyProperties(bp, hero.IsFemale); //#if MBVER_010403 // hero.CharacterObject.UpdatePlayerCharacterBodyProperties(bp, hero.IsFemale); //#else // hero.ModifyPlayersFamilyAppearance(bp.StaticProperties); // hero.BodyProperties.DynamicProperties = bp.DynamicProperties; //#endif } } }
public void SetBodyProperties(string bodyPropertiesCode) { if (this._bodyPropertiesCode != bodyPropertiesCode) { this._bodyPropertiesCode = bodyPropertiesCode; BodyProperties bodyProperties; if (!string.IsNullOrEmpty(bodyPropertiesCode) && BodyProperties.FromString(bodyPropertiesCode, out bodyProperties)) { this._bodyProperties = bodyProperties; } else { this._bodyProperties = BodyProperties.Default; } this._initialized = false; this.RefreshCharacterTableau(null); this.ForceRefresh(); } }
private void OnToLoadHeroCharacter(HeroAdminCharacter data, bool include) { if (include) { this._heroAdminCharacter = data; } else { string tmp = this._heroAdminCharacter.BodyPropertiesString; bool isFemale = this._heroAdminCharacter.IsFemale; this._heroAdminCharacter = data; this._heroAdminCharacter.BodyPropertiesString = tmp; this._heroAdminCharacter.IsFemale = isFemale; } //this._heroAdminCharacterVM.RefreshHeroData(); BodyProperties bodyProperties = BodyProperties.Default; BodyProperties.FromString(this._heroAdminCharacter.BodyPropertiesString, out bodyProperties); this._heroAdminCharacterVM.FillFrom(bodyProperties, this._hero.CharacterObject.FirstBattleEquipment, this._hero.Culture, this._heroAdminCharacter.IsFemale); ResetData(); }
public void ToHero(Hero hero) { /// hero.HeroDeveloper.ClearHero(); BodyProperties bodyProperties = BodyProperties.Default; hero.Level = this.Level; BodyProperties.FromString(this.BodyPropertiesString, out bodyProperties); HeroUtils.UpdateHeroCharacterBodyProperties(hero.CharacterObject, bodyProperties, this.IsFemale); HeroAdminCharacterAttribute attr; hero.ClearAttributes(); for (int i = 0; i < 6; i++) { attr = this.Attributes.FirstOrDefault((obj) => obj.AttributeName == Enum.GetName(typeof(CharacterAttributesEnum), i)); if (null != attr) { hero.SetAttributeValue((CharacterAttributesEnum)i, attr.AttributeValue); // hero.HeroDeveloper.AddAttribute((CharacterAttributesEnum)i, attr.AttributeValue, false); } } HeroAdminCharacterSkill adminCharacterSkill; hero.ClearSkills(); foreach (SkillObject current in SkillObject.All) { adminCharacterSkill = Skills.FirstOrDefault((obj) => obj.StringId.Equals(current.StringId)); if (null != adminCharacterSkill) { // hero.SetSkillValue(current, adminCharacterSkill.SkillValue); int xpRequiredForSkillLevel = Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(adminCharacterSkill.SkillValue); hero.HeroDeveloper.SetPropertyValue(current, (float)xpRequiredForSkillLevel); hero.SetSkillValue(current, adminCharacterSkill.SkillValue); ReflectUtils.ReflectMethodAndInvoke("SetFocus", hero.HeroDeveloper, new object[] { current, adminCharacterSkill.SkillFocus }); ///hero.HeroDeveloper.AddFocus(current, adminCharacterSkill.SkillFocus, false); } } hero.ClearPerks(); foreach (PerkObject perk in PerkObject.All) { HeroAdminCharacterPerk result = this.Perks.FirstOrDefault(cp => cp.StringId.Equals(perk.StringId)); if (null != result) { // hero.SetPerkValue(current, true); // 直接修改数据,因为上面方法会发送事件 CharacterPerks heroPerks = ReflectUtils.ReflectField <CharacterPerks>("_heroPerks", hero); if (null != heroPerks) { heroPerks.SetPropertyValue(perk, result.Enable ? 1: 0); } } } hero.ClearTraits(); foreach (TraitObject trait in TraitObject.All) { HeroAdminCharacterTrait characterTrait = Traits.FirstOrDefault((obj) => obj.StringId.Equals(trait.StringId)); if (null != characterTrait) { hero.SetTraitLevel(trait, characterTrait.Level); } } }