MauryDev.KoGaMa.ModelAPI.Official 1.0.0

dotnet add package MauryDev.KoGaMa.ModelAPI.Official --version 1.0.0
                    
NuGet\Install-Package MauryDev.KoGaMa.ModelAPI.Official -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.ModelAPI.Official" 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.ModelAPI.Official" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MauryDev.KoGaMa.ModelAPI.Official" />
                    
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.ModelAPI.Official --version 1.0.0
                    
#r "nuget: MauryDev.KoGaMa.ModelAPI.Official, 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.ModelAPI.Official@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.ModelAPI.Official&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MauryDev.KoGaMa.ModelAPI.Official&version=1.0.0
                    
Install as a Cake Tool

KoGaMa Model API - Official Implementation

MauryDev.KoGaMa.ModelAPI.Official is a specialized implementation of the KoGaMa model serialization system. It provides the logic required to convert in-memory models into the official binary format used by the game, focusing on high-efficiency data compression and spatial optimization.

This library is built on top of the base MauryDev.KoGaMa.ModelAPI and targets .NET Standard 2.0, ensuring compatibility across .NET Framework, .NET Core, and .NET 5+.

🚀 Core Features

The official implementation focuses on minimizing the binary footprint of models through two main components:

🧊 CubeGrouper (Spatial Optimization)

The CubeGrouper is the optimization engine that reduces redundancy in geometry. Instead of storing every cube as a separate entity, it identifies and groups adjacent cubes that are identical in properties.

Logic Flow:

  1. Spatial Sorting: Cubes are sorted by Z, then Y, and finally X coordinates.
  2. Linear Scanning: The algorithm scans for sequences of cubes aligned specifically along the X-axis.
  3. Property Matching: To be grouped into a "row," cubes must:
    • Be in consecutive positions on the X-axis.
    • Share the exact same material array (6 faces).
    • Share the exact same corner configuration.
  4. Limit: A single group can contain up to 63 cubes.

This significantly reduces the amount of coordinate data written to the stream.

💾 OfficialSerializer (Binary Implementation)

The OfficialSerializer implements the ISerializer interface. It transforms the grouped data into a compact binary stream using a bit-flag system to omit redundant information.

Compression Flags:

The serializer uses a flag byte to notify the reader about the data structure:

  • FlagIdentityCorners: If the group's corners match the standard identity corners, the flag is set and the 8-byte corner data is completely omitted.
  • FlagUniformMaterials: If all 6 faces of the cubes in the group use the same material, the flag is set and only one byte is written instead of six.
  • Row Compression: The number of cubes in a row (calculated by CubeGrouper) is shifted into the flag byte (rowCount << 2), allowing the deserializer to expand the row back into individual cubes.
Low-Level I/O:

To handle the specific binary requirements of the official format, the library uses ReverseReader and ReverseWriter, which manage custom byte-ordering and cached reads.


🛠️ Usage Example

using MauryDev.KoGaMa.ModelAPI.Model;
using MauryDev.KoGaMa.ModelAPI.Official;
using System.IO;

// 1. Setup your model (from the base ModelAPI library)
ModelInfo myModel = new ModelInfo();
myModel.AddCube(new Cube(new IntVector(0, 0, 0), materials, corners));

// 2. Use the Official Serializer
var serializer = new OfficialSerializer();

// 3. Serialize to the official binary format
using (var stream = File.OpenWrite("model.bin"))
{
    serializer.Serialize(stream, myModel);
}

// 4. Deserialize back into a ModelInfo object
using (var stream = File.OpenRead("model.bin"))
{
    ModelInfo loadedModel = serializer.Deserialize(stream);
}

📊 Technical Specifications

Specification Detail
Target Framework .NET Standard 2.0
Max Row Length 63 cubes
Material Compression 6 bytes → 1 byte (if uniform)
Corner Compression 8 bytes → 0 bytes (if identity)
Sorting Order Z → Y → X
Dependencies MauryDev.KoGaMa.ModelAPI

📦 Project Architecture

  • MauryDev.KoGaMa.ModelAPI: (Dependency) Core interfaces, ModelInfo, and Cube definitions.
  • MauryDev.KoGaMa.ModelAPI.Official:
    • CubeGrouper: Spatial logic for row optimization.
    • OfficialSerializer: Binary logic and flag management.
    • Official.IO: Low-level ReverseReader and ReverseWriter.
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 108 6/23/2026