CSNC/Client/Unity/GameObjectRegistry.cs
2025-01-02 18:22:20 -05:00

36 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameObjectRegistry : MonoBehaviour
{
public static GameObjectRegistry instance; //instance of gameobject registry in scene
public string uuid; //unique identifier for this client
public List<GameObject> gameObjects; //list to make it easy to register new gameobjects
public List<string> types;
public Dictionary<string, GameObject> registry = new Dictionary<string, GameObject>(); //registry of game objects that can be synced (needs to be identical on both clients
public List<SyncData> registeredObjects = new List<SyncData>(); //game objcets that are currently being synced
void Start()
{
GameObjectRegistry.instance = this;
uuid = System.Guid.NewGuid().ToString(); //create a uuid for this player
initializeRegistry();
}
void initializeRegistry()
{
int i = 0;
foreach (string id in types)
{
registry.Add(id, gameObjects[i]);
i++;
}
}
}