Skip to content

Commit

Permalink
Fixed serializing of appearence data when sending mails
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Jan 19, 2025
1 parent d803424 commit a30e913
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/GameLogic/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,15 @@ public static ItemAppearance GetAppearance(this Item item)
/// </summary>
/// <param name="itemAppearance">The item appearance.</param>
/// <param name="persistenceContext">The persistence context where the object should be added.</param>
/// <param name="gameConfiguration">The game configuration.</param>
/// <returns>A persistent instance of the given <see cref="ItemAppearance"/>.</returns>
public static ItemAppearance MakePersistent(this ItemAppearance itemAppearance, IContext persistenceContext)
public static ItemAppearance MakePersistent(this ItemAppearance itemAppearance, IContext persistenceContext, GameConfiguration gameConfiguration)
{
var persistent = persistenceContext.CreateNew<ItemAppearance>();
persistent.ItemSlot = itemAppearance.ItemSlot;
persistent.Definition = itemAppearance.Definition;
persistent.Level = itemAppearance.Level;
itemAppearance.VisibleOptions.Distinct().ForEach(o => persistent.VisibleOptions.Add(o));
itemAppearance.VisibleOptions.Distinct().ForEach(o => persistent.VisibleOptions.Add(gameConfiguration.ItemOptionTypes.First(iot => iot.Equals(o))));
return persistent;
}

Expand Down
2 changes: 1 addition & 1 deletion src/GameLogic/PlayerActions/Messenger/LetterSendAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private LetterHeader CreateLetter(IContext context, Player player, string receiv
letterBody.Message = message;
letterBody.SenderAppearance = context.CreateNew<AppearanceData>();
letterBody.SenderAppearance.CharacterClass = player.AppearanceData.CharacterClass;
player.AppearanceData.EquippedItems.Select(i => i.MakePersistent(context)).ForEach(letterBody.SenderAppearance.EquippedItems.Add);
player.AppearanceData.EquippedItems.Select(i => i.MakePersistent(context, player.GameContext.Configuration)).ForEach(letterBody.SenderAppearance.EquippedItems.Add);
letterBody.Rotation = rotation;
letterBody.Animation = animation;
return letterHeader;
Expand Down

0 comments on commit a30e913

Please sign in to comment.