using System.Collections.Generic;
public interface IMyEntityInterface
public int ID { get; set; }
public struct MyEntityType : IMyEntityInterface {
public int ID { get; set; }
public IMyEntityInterface[] entities = new IMyEntityInterface[3];
private int entityCount = 0;
public int AddEntity(IMyEntityInterface entity)
entities[entity.ID] = entity;
public IMyEntityInterface GetEntity(int id)
public void PrintAllEntities()
Console.WriteLine($"Entities in scene (total {entityCount}):");
for (int i = 0; i < entityCount; i++)
Console.WriteLine(entities[i].ID);
private static void CopyEntityByID(ref MyScene scene, int id)
IMyEntityInterface entity = scene.GetEntity(id);
public static void Main()
MyEntityType entityA = new();
scene.AddEntity(entityA);
Console.WriteLine("First entity ID:");
Console.WriteLine(scene.entities[0].ID);
CopyEntityByID(ref scene, 0);
scene.PrintAllEntities();
MyEntityType entityB = new();
scene.AddEntity(entityB);
scene.PrintAllEntities();