Game.Net.Upgraded
Assembly: Game
Namespace: Game.Net
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Upgraded is a lightweight ECS component (struct) used to mark an entity that has been "upgraded" and to carry composition flags associated with that upgrade. It implements ISerializable so that the flags are written to and read from the game's entity serialization stream. The component is suitable as a marker in queries (IQueryTypeParameter) and for storage via Unity.Entities (IComponentData).
Fields
public CompositionFlags m_Flags
Stores the composition flags for the upgraded entity. CompositionFlags is a bitmask/enum (defined elsewhere in the codebase) representing aspects of the upgrade that should be preserved/serialized. As a public field on a struct, it will be default-initialized (usually zero/None) if the struct is created with the default constructor.
Properties
- None.
This struct exposes no properties; data is held directly in the public field(s).
Constructors
public Upgraded()
No explicit constructor is declared in the source. As a value type (struct), Upgraded has the implicit default constructor which zero-initializes m_Flags (equivalent to CompositionFlags.None or 0 depending on the enum definition).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes the component by writing the m_Flags value to the provided writer. This method is called by the game's serialization pipeline when saving entity state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Deserializes the component by reading m_Flags from the provided reader. This method is called by the game's deserialization pipeline when restoring entity state.
Notes: - The method implementations are small and focused: Serialize writes a single field, Deserialize reads a single field. - Because the component implements ISerializable, custom save/load logic that processes ISerializable components will include this component automatically.
Usage Example
// Add the component to an entity and set flags
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity(typeof(Upgraded));
// Replace "CompositionFlags.SomeFlag" with the actual flag(s) defined in your codebase
entityManager.SetComponentData(entity, new Upgraded {
m_Flags = CompositionFlags.SomeFlag
});
// When the game's serializer runs, it will call Upgraded.Serialize<TWriter>(...) and
// write m_Flags to the save stream. On load, Upgraded.Deserialize<TReader>(...) will be called.