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
<PackageReference Include="MauryDev.KoGaMa.AvatarAPI.KoGaMaTools" Version="1.0.0" />
<PackageVersion Include="MauryDev.KoGaMa.AvatarAPI.KoGaMaTools" Version="1.0.0" />
<PackageReference Include="MauryDev.KoGaMa.AvatarAPI.KoGaMaTools" />
paket add MauryDev.KoGaMa.AvatarAPI.KoGaMaTools --version 1.0.0
#r "nuget: MauryDev.KoGaMa.AvatarAPI.KoGaMaTools, 1.0.0"
#:package MauryDev.KoGaMa.AvatarAPI.KoGaMaTools@1.0.0
#addin nuget:?package=MauryDev.KoGaMa.AvatarAPI.KoGaMaTools&version=1.0.0
#tool nuget:?package=MauryDev.KoGaMa.AvatarAPI.KoGaMaTools&version=1.0.0
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
IAvatarMapperto 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
IAvatarMapperinterface.
📦 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
CubeInfodefinitions. - MauryDev.KoGaMa.AvatarAPI: Contains the base
AvatarInfodefinitions. - MauryDev.KoGaMa.ModelAPI.KoGaMaTools: Contains the base
ModelMapperdefinitions.
🛠 Architecture
The library is divided into three main components:
KGMTSerializer: The primary service. It orchestrates the process:Serialize: Domain → Mapper → DTO → MessagePack-> Stream.Deserialize: Stream → MessagePack → DTO → Mapper → Domain.
AvatarMapper: Responsible for translating theAvatarInfodictionary-like structure into a flatAvatarInfoDTOobject.AvatarInfoDTO: A lightweight data transfer object optimized for binary serialization, containing arrays ofCubeInfoDTOfor 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)whereNis the number of cubes in the avatar. - Space Complexity:
O(N)to hold the DTO temporary representation before writing to the stream.
| Product | Versions 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. |
-
.NETStandard 2.0
- MauryDev.KoGaMa.AvatarAPI (>= 1.0.1)
- MauryDev.KoGaMa.ModelAPI.KoGaMaTools (>= 1.0.1)
- MessagePack (>= 3.1.7)
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 |