MauryDev.KoGaMa.AvatarAPI.KoGaMaTools 1.0.0

dotnet add package MauryDev.KoGaMa.AvatarAPI.KoGaMaTools --version 1.0.0
                    
NuGet\Install-Package MauryDev.KoGaMa.AvatarAPI.KoGaMaTools -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MauryDev.KoGaMa.AvatarAPI.KoGaMaTools" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MauryDev.KoGaMa.AvatarAPI.KoGaMaTools" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MauryDev.KoGaMa.AvatarAPI.KoGaMaTools" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MauryDev.KoGaMa.AvatarAPI.KoGaMaTools --version 1.0.0
                    
#r "nuget: MauryDev.KoGaMa.AvatarAPI.KoGaMaTools, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MauryDev.KoGaMa.AvatarAPI.KoGaMaTools@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MauryDev.KoGaMa.AvatarAPI.KoGaMaTools&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MauryDev.KoGaMa.AvatarAPI.KoGaMaTools&version=1.0.0
                    
Install as a Cake Tool

Since the provided code is part of a larger ecosystem (MauryDev.KoGaMa), the README should be professional, technical, and clearly explain the separation between the Domain Model and the Data Transfer Object (DTO).

KoGaMa Avatar Serializer (KGMT)

A specialized serialization library designed to handle KoGaMa avatar data. This library provides a robust way to convert complex avatar domain models into a compact binary format using MessagePack, ensuring efficient storage and transmission of avatar information.

🚀 Overview

The KGMTSerializer acts as a bridge between the internal domain representation of a KoGaMa avatar (AvatarInfo) and a serialized binary stream. To maintain a clean architecture, the library utilizes the Mapper Pattern, separating the data structure used for serialization (DTO) from the business logic model (Domain).

Key Features

  • Efficient Binary Serialization: Leverages MessagePack for high-performance, low-size binary data.
  • Decoupled Architecture: Uses an IAvatarMapper to ensure that changes in the domain model do not necessarily break the serialization format.
  • Stream-Based: Works directly with System.IO.Stream, making it compatible with files, network sockets, or memory streams.
  • Extensible: Allows for the injection of custom mapping logic via the IAvatarMapper interface.

📦 Dependencies

To use this library, you will need the following dependencies:

  • .NET Standard 2.0+ / .NET Core / .NET 5+
  • MessagePack: Used for the actual binary serialization.
  • MauryDev.KoGaMa.ModelAPI: Contains the base CubeInfo definitions.
  • MauryDev.KoGaMa.AvatarAPI: Contains the base AvatarInfo definitions.
  • MauryDev.KoGaMa.ModelAPI.KoGaMaTools: Contains the base ModelMapper definitions.

🛠 Architecture

The library is divided into three main components:

  1. KGMTSerializer: The primary service. It orchestrates the process:
    • Serialize: Domain → Mapper → DTO → MessagePack-> Stream.
    • Deserialize: Stream → MessagePack → DTO → Mapper → Domain.
  2. AvatarMapper: Responsible for translating the AvatarInfo dictionary-like structure into a flat AvatarInfoDTO object.
  3. AvatarInfoDTO: A lightweight data transfer object optimized for binary serialization, containing arrays of CubeInfoDTO for each body part (Head, Torso, Arms, Legs).

💻 Usage

Basic Example

using System.IO;
using MauryDev.KoGaMa.AvatarAPI.KoGaMaTools;
using MauryDev.KoGaMa.ModelAPI.KoGaMaTools;

// 1. Setup the serializer
var serializer = new KGMTSerializer();

// 2. Your AvatarInfo domain object
AvatarInfo myAvatar = GetAvatarFromGame(); 

// --- SERIALIZATION ---
using (FileStream fs = new FileStream("avatar.kgmt", FileMode.Create))
{
    serializer.Serialize(fs, myAvatar);
}

// --- DESERIALIZATION ---
using (FileStream fs = new FileStream("avatar.kgmt", FileMode.Open))
{
    AvatarInfo loadedAvatar = serializer.Deserialize(fs);
    // Use your loaded avatar here
}

Advanced Usage (Custom Mapping)

If you need to change how the domain model is mapped to the DTO, you can implement your own IAvatarMapper:

public class MyCustomMapper : IAvatarMapper 
{
    public AvatarInfoDTO ToDto(AvatarInfo avatarInfo) { /* Custom Logic */ }
    public AvatarInfo ToDomain(AvatarInfoDTO dto) { /* Custom Logic */ }
}

// Inject the custom mapper into the serializer
var serializer = new KGMTSerializer(new MyCustomMapper());

📋 API Reference

KGMTSerializer

Method Parameters Description
Serialize(Stream, AvatarInfo) Stream stream, AvatarInfo avatar Converts the domain model to a DTO and writes the MessagePack binary to the stream.
Deserialize(Stream) Stream stream Reads MessagePack binary from the stream, converts it to a DTO, and maps it back to the domain model.

IAvatarMapper

Method Description
ToDto(AvatarInfo) Converts the domain object to a serializable DTO.
ToDomain(AvatarInfoDTO) Converts the serialized DTO back into the domain object.

🛠 Technical Details

Data Mapping Logic

The AvatarMapper specifically handles the mapping of Enums.PartIndex (Head, Torso, etc.) to the corresponding properties in the AvatarInfoDTO. This ensures that the order and integrity of the avatar's body parts are preserved during the binary conversion.

Complexity

  • Time Complexity: O(N) where N is the number of cubes in the avatar.
  • Space Complexity: O(N) to hold the DTO temporary representation before writing to the stream.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 0 6/19/2026