public async Task Apply(ActorViewModel actor, SaveModes mode) { if (actor.Customize == null) { return; } Log.Information("Reading appearance from file"); actor.AutomaticRefreshEnabled = false; actor.MemoryMode = MemoryModes.None; if (actor.ModelObject?.ExtendedAppearance != null) { actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.None; } if (!string.IsNullOrEmpty(this.Nickname)) { actor.Nickname = this.Nickname; } actor.ModelType = this.ModelType; if (this.IncludeSection(SaveModes.EquipmentWeapons, mode)) { this.MainHand?.Write(actor.MainHand); this.OffHand?.Write(actor.OffHand); } if (this.IncludeSection(SaveModes.EquipmentGear, mode)) { this.HeadGear?.Write(actor.Equipment?.Head); this.Body?.Write(actor.Equipment?.Chest); this.Hands?.Write(actor.Equipment?.Arms); this.Legs?.Write(actor.Equipment?.Legs); this.Feet?.Write(actor.Equipment?.Feet); } if (this.IncludeSection(SaveModes.EquipmentAccessories, mode)) { this.Ears?.Write(actor.Equipment?.Ear); this.Neck?.Write(actor.Equipment?.Neck); this.Wrists?.Write(actor.Equipment?.Wrist); this.RightRing?.Write(actor.Equipment?.RFinger); this.LeftRing?.Write(actor.Equipment?.LFinger); } if (this.IncludeSection(SaveModes.AppearanceHair, mode)) { actor.Customize.Hair = (byte)this.Hair !; actor.Customize.EnableHighlights = (bool)this.EnableHighlights !; actor.Customize.HairTone = (byte)this.HairTone !; actor.Customize.Highlights = (byte)this.Highlights !; } if (this.IncludeSection(SaveModes.AppearanceFace, mode) || this.IncludeSection(SaveModes.AppearanceBody, mode)) { actor.Customize.Race = (Appearance.Races) this.Race !; actor.Customize.Gender = (Appearance.Genders) this.Gender !; actor.Customize.Tribe = (Appearance.Tribes) this.Tribe !; actor.Customize.Age = (Appearance.Ages) this.Age !; } if (this.IncludeSection(SaveModes.AppearanceFace, mode)) { actor.Customize.Head = (byte)this.Head !; actor.Customize.REyeColor = (byte)this.REyeColor !; actor.Customize.FacialFeatures = (Appearance.FacialFeature) this.FacialFeatures !; actor.Customize.LimbalEyes = (byte)this.LimbalEyes !; actor.Customize.Eyebrows = (byte)this.Eyebrows !; actor.Customize.LEyeColor = (byte)this.LEyeColor !; actor.Customize.Eyes = (byte)this.Eyes !; actor.Customize.Nose = (byte)this.Nose !; actor.Customize.Jaw = (byte)this.Jaw !; actor.Customize.Mouth = (byte)this.Mouth !; actor.Customize.LipsToneFurPattern = (byte)this.LipsToneFurPattern !; actor.Customize.FacePaint = (byte)this.FacePaint !; actor.Customize.FacePaintColor = (byte)this.FacePaintColor !; } if (this.IncludeSection(SaveModes.AppearanceBody, mode)) { actor.Customize.Height = (byte)this.Height !; actor.Customize.Skintone = (byte)this.Skintone !; actor.Customize.EarMuscleTailSize = (byte)this.EarMuscleTailSize !; actor.Customize.TailEarsType = (byte)this.TailEarsType !; actor.Customize.Bust = (byte)this.Bust !; } actor.WriteToMemory(true); await actor.RefreshAsync(); // Setting customize values will reset the extended appearance, which me must read. await actor.ReadFromMemoryAsync(true); if (actor.ModelObject?.ExtendedAppearance != null) { await actor.ModelObject.ExtendedAppearance.ReadFromMemoryAsync(true); } // write everything that is reset by actor refreshes /*if (this.IncludeSection(SaveModes.EquipmentGear, mode)) * { * if (this.MainHand != null) * { * actor.SetValue(Offsets.Main.MainHandColor, this.MainHand.Color); * actor.SetValue(Offsets.Main.MainHandScale, this.MainHand.Scale); * } * * if (this.OffHand != null) * { * actor.SetValue(Offsets.Main.OffhandColor, this.OffHand.Color); * actor.SetValue(Offsets.Main.OffhandScale, this.OffHand.Scale); * } * }*/ if (actor.ModelObject?.ExtendedAppearance != null) { bool usedExAppearance = false; if (this.IncludeSection(SaveModes.AppearanceHair, mode)) { actor.ModelObject.ExtendedAppearance.HairColor = this.HairColor ?? actor.ModelObject.ExtendedAppearance.HairColor; actor.ModelObject.ExtendedAppearance.HairGloss = this.HairGloss ?? actor.ModelObject.ExtendedAppearance.HairGloss; actor.ModelObject.ExtendedAppearance.HairHighlight = this.HairHighlight ?? actor.ModelObject.ExtendedAppearance.HairHighlight; usedExAppearance |= this.HairColor != null; usedExAppearance |= this.HairGloss != null; usedExAppearance |= this.HairHighlight != null; } if (this.IncludeSection(SaveModes.AppearanceFace, mode)) { actor.ModelObject.ExtendedAppearance.LeftEyeColor = this.LeftEyeColor ?? actor.ModelObject.ExtendedAppearance.LeftEyeColor; actor.ModelObject.ExtendedAppearance.RightEyeColor = this.RightEyeColor ?? actor.ModelObject.ExtendedAppearance.RightEyeColor; actor.ModelObject.ExtendedAppearance.LimbalRingColor = this.LimbalRingColor ?? actor.ModelObject.ExtendedAppearance.LimbalRingColor; actor.ModelObject.ExtendedAppearance.MouthColor = this.MouthColor ?? actor.ModelObject.ExtendedAppearance.MouthColor; usedExAppearance |= this.LeftEyeColor != null; usedExAppearance |= this.RightEyeColor != null; usedExAppearance |= this.LimbalRingColor != null; usedExAppearance |= this.MouthColor != null; } if (this.IncludeSection(SaveModes.AppearanceBody, mode)) { actor.ModelObject.ExtendedAppearance.SkinColor = this.SkinColor ?? actor.ModelObject.ExtendedAppearance.SkinColor; actor.ModelObject.ExtendedAppearance.SkinGloss = this.SkinGloss ?? actor.ModelObject.ExtendedAppearance.SkinGloss; actor.ModelObject.ExtendedAppearance.MuscleTone = this.MuscleTone ?? actor.ModelObject.ExtendedAppearance.MuscleTone; actor.Transparency = this.Transparency ?? actor.Transparency; actor.ModelObject.Height = this.HeightMultiplier ?? actor.ModelObject.Height; if (actor.ModelObject.Bust?.Scale != null) { actor.ModelObject.Bust.Scale = this.BustScale ?? actor.ModelObject.Bust.Scale; } usedExAppearance |= this.SkinColor != null; usedExAppearance |= this.SkinGloss != null; usedExAppearance |= this.MuscleTone != null; } ////actor.ModelObject.ExtendedAppearance.Freeze = usedExAppearance; actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.ReadWrite; actor.ModelObject.ExtendedAppearance.WriteToMemory(true); } actor.MemoryMode = MemoryModes.ReadWrite; actor.WriteToMemory(true); actor.AutomaticRefreshEnabled = true; }
public async Task Apply(ActorViewModel actor, SaveModes mode) { if (actor.Customize == null) { return; } Log.Write("Reading appearance from file", "AppearanceFile"); actor.AutomaticRefreshEnabled = false; actor.MemoryMode = MemoryModes.None; if (actor.ModelObject?.ExtendedAppearance != null) { actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.None; } actor.ModelType = this.ModelType; bool changedRace = actor.Customize.Race != this.Race; if (this.IncludeSection(SaveModes.EquipmentWeapons, mode)) { this.MainHand?.Write(actor.MainHand); this.OffHand?.Write(actor.OffHand); } if (this.IncludeSection(SaveModes.EquipmentGear, mode)) { this.HeadGear?.Write(actor.Equipment?.Head); this.Body?.Write(actor.Equipment?.Chest); this.Hands?.Write(actor.Equipment?.Arms); this.Legs?.Write(actor.Equipment?.Legs); this.Feet?.Write(actor.Equipment?.Feet); } if (this.IncludeSection(SaveModes.EquipmentAccessories, mode)) { this.Ears?.Write(actor.Equipment?.Ear); this.Neck?.Write(actor.Equipment?.Neck); this.Wrists?.Write(actor.Equipment?.Wrist); this.RightRing?.Write(actor.Equipment?.RFinger); this.LeftRing?.Write(actor.Equipment?.LFinger); } if (this.IncludeSection(SaveModes.AppearanceHair, mode)) { actor.Customize.Hair = (byte)this.Hair !; actor.Customize.EnableHighlights = (bool)this.EnableHighlights !; actor.Customize.HairTone = (byte)this.HairTone !; actor.Customize.Highlights = (byte)this.Highlights !; } if (this.IncludeSection(SaveModes.AppearanceFace, mode) || this.IncludeSection(SaveModes.AppearanceBody, mode)) { actor.Customize.Race = (Appearance.Races) this.Race !; actor.Customize.Gender = (Appearance.Genders) this.Gender !; actor.Customize.Tribe = (Appearance.Tribes) this.Tribe !; actor.Customize.Age = (Appearance.Ages) this.Age !; } if (this.IncludeSection(SaveModes.AppearanceFace, mode)) { actor.Customize.Head = (byte)this.Head !; actor.Customize.REyeColor = (byte)this.REyeColor !; actor.Customize.FacialFeatures = (Appearance.FacialFeature) this.FacialFeatures !; actor.Customize.LimbalEyes = (byte)this.LimbalEyes !; actor.Customize.Eyebrows = (byte)this.Eyebrows !; actor.Customize.LEyeColor = (byte)this.LEyeColor !; actor.Customize.Eyes = (byte)this.Eyes !; actor.Customize.Nose = (byte)this.Nose !; actor.Customize.Jaw = (byte)this.Jaw !; actor.Customize.Mouth = (byte)this.Mouth !; actor.Customize.LipsToneFurPattern = (byte)this.LipsToneFurPattern !; actor.Customize.FacePaint = (byte)this.FacePaint !; actor.Customize.FacePaintColor = (byte)this.FacePaintColor !; } if (this.IncludeSection(SaveModes.AppearanceBody, mode)) { actor.Customize.Height = (byte)this.Height !; actor.Customize.Skintone = (byte)this.Skintone !; actor.Customize.EarMuscleTailSize = (byte)this.EarMuscleTailSize !; actor.Customize.TailEarsType = (byte)this.TailEarsType !; actor.Customize.Bust = (byte)this.Bust !; } actor.WriteToMemory(true); await actor.RefreshAsync(); // If we have changed race, we do a second actor refresh to avoid cases where // FFXIV has not loaded the correct skin texture for the new race in time for // the charater to render, causing the new model to show with the old skin. if (changedRace) { await actor.RefreshAsync(); } // Setting customize values will reset the extended appearance, which me must read. await actor.ReadFromMemoryAsync(true); if (actor.ModelObject?.ExtendedAppearance != null) { await actor.ModelObject.ExtendedAppearance.ReadFromMemoryAsync(true); } // write everything that is reset by actor refreshes /*if (this.IncludeSection(SaveModes.EquipmentGear, mode)) * { * if (this.MainHand != null) * { * actor.SetValue(Offsets.Main.MainHandColor, this.MainHand.Color); * actor.SetValue(Offsets.Main.MainHandScale, this.MainHand.Scale); * } * * if (this.OffHand != null) * { * actor.SetValue(Offsets.Main.OffhandColor, this.OffHand.Color); * actor.SetValue(Offsets.Main.OffhandScale, this.OffHand.Scale); * } * }*/ if (actor.ModelObject?.ExtendedAppearance != null) { bool usedExAppearance = false; if (this.IncludeSection(SaveModes.AppearanceHair, mode)) { actor.ModelObject.ExtendedAppearance.HairColor = this.HairColor ?? actor.ModelObject.ExtendedAppearance.HairColor; actor.ModelObject.ExtendedAppearance.HairGloss = this.HairGloss ?? actor.ModelObject.ExtendedAppearance.HairGloss; actor.ModelObject.ExtendedAppearance.HairHighlight = this.HairHighlight ?? actor.ModelObject.ExtendedAppearance.HairHighlight; usedExAppearance |= this.HairColor != null; usedExAppearance |= this.HairGloss != null; usedExAppearance |= this.HairHighlight != null; } if (this.IncludeSection(SaveModes.AppearanceFace, mode)) { actor.ModelObject.ExtendedAppearance.LeftEyeColor = this.LeftEyeColor ?? actor.ModelObject.ExtendedAppearance.LeftEyeColor; actor.ModelObject.ExtendedAppearance.RightEyeColor = this.RightEyeColor ?? actor.ModelObject.ExtendedAppearance.RightEyeColor; actor.ModelObject.ExtendedAppearance.LimbalRingColor = this.LimbalRingColor ?? actor.ModelObject.ExtendedAppearance.LimbalRingColor; actor.ModelObject.ExtendedAppearance.MouthColor = this.MouthColor ?? actor.ModelObject.ExtendedAppearance.MouthColor; usedExAppearance |= this.LeftEyeColor != null; usedExAppearance |= this.RightEyeColor != null; usedExAppearance |= this.LimbalRingColor != null; usedExAppearance |= this.MouthColor != null; } if (this.IncludeSection(SaveModes.AppearanceBody, mode)) { actor.ModelObject.ExtendedAppearance.SkinColor = this.SkinColor ?? actor.ModelObject.ExtendedAppearance.SkinColor; actor.ModelObject.ExtendedAppearance.SkinGloss = this.SkinGloss ?? actor.ModelObject.ExtendedAppearance.SkinGloss; ////actor.SetValue(Offsets.Main.Transparency, this.Transparency); ////actor.SetValue(Offsets.Main.BustScale, this.BustScale); ////actor.SetValue(Offsets.Main.UniqueFeatureScale, this.FeatureScale); usedExAppearance |= this.SkinColor != null; usedExAppearance |= this.SkinGloss != null; } actor.ModelObject.ExtendedAppearance.Freeze = usedExAppearance; actor.ModelObject.ExtendedAppearance.MemoryMode = MemoryModes.ReadWrite; actor.ModelObject.ExtendedAppearance.WriteToMemory(true); } actor.MemoryMode = MemoryModes.ReadWrite; actor.WriteToMemory(true); actor.AutomaticRefreshEnabled = true; }