Skip to content

Game.Creditworthiness

Assembly:
Assembly-CSharp (Game code / modding assembly)

Namespace: Game.Simulation

Type:
struct

Base:
IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a simple, serializable component that stores an integer "creditworthiness" amount for an entity in the simulation. Designed to be used with Unity's ECS (IComponentData) and to participate in queries (IQueryTypeParameter). Implements ISerializable so the value can be written to and read from the game's save/load serialization system.


Fields

  • public int m_Amount
    Holds the creditworthiness amount as a plain integer. Default value is 0 for a freshly constructed struct. This field is serialized/deserialized by the ISerializable implementation. Use this value to represent whatever credit metric the simulation requires (credit score, credit balance, etc.).

Properties

  • This type does not expose any C# properties. It uses a public field for data storage.

Constructors

  • public Creditworthiness()
    The type is a value type (struct) and therefore has a default parameterless constructor that initializes m_Amount to 0. You can construct with an object initializer: new Creditworthiness { m_Amount = 100 }.

Methods

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the stored integer value from the provided reader and assigns it to m_Amount. The reader must support Read(out int) or the equivalent expected by the game's serialization API.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes m_Amount to the provided writer. The writer must support Write(int) or the equivalent expected by the game's serialization API.

Notes: - The generic constraints indicate these methods accept any reader/writer types used by the engine that implement the IReader/IWriter contracts. - Because the struct is a plain blittable integer, it is cheap to copy and safe to use in ECS jobs and component storage.

Usage Example

// Create and assign the component to an entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = entityManager.CreateEntity();
entityManager.AddComponentData(e, new Creditworthiness { m_Amount = 750 });

// Read the component later
Creditworthiness cw = entityManager.GetComponentData<Creditworthiness>(e);
int current = cw.m_Amount;

// Serialization (conceptual example — actual writer/reader come from the game's save/load system)
public void SaveComponent<TWriter>(ref Creditworthiness component, TWriter writer) where TWriter : IWriter
{
    component.Serialize(writer);
}

public void LoadComponent<TReader>(out Creditworthiness component, TReader reader) where TReader : IReader
{
    component = new Creditworthiness();
    component.Deserialize(reader);
}