public static NetworkedEntity RegenerateEntity(int id, long prefab, int authority, Vector3 pos, long uniqueId = 0) { // TODO: Separate preplaced entities from dynamically created ents Debug.Log("Has regen"); if (uniqueId != 0) { Debug.Log("Has UniqueId " + uniqueId); if (registeredPreplacedEnts.ContainsKey(uniqueId)) { Debug.Log("Has PreplacedEnt"); NetworkedEntity e = registeredPreplacedEnts[uniqueId]; e.SetEntityIndex(id); e.GetComponent <NetworkAuthority>()?.SetAuthority(authority); registeredPreplacedEnts.Remove(uniqueId); return(e); } } if (registeredPrefabs.ContainsKey(prefab)) { GameObject newObject = MonoBehaviour.Instantiate(registeredPrefabs[prefab], pos, Quaternion.identity); newObject.GetComponent <NetworkedEntity>().SetEntityIndex(id); newObject.GetComponent <NetworkAuthority>()?.SetAuthority(authority); return(newObject.GetComponent <NetworkedEntity>()); } else { Debug.LogError("Entity manager does not have prefab " + prefab); } return(null); }
public static void RegisterEntity(NetworkedEntity e, int id) { e.SetEntityIndex(id, false); ents[id] = e; }
public static uint RegisterEntity(NetworkedEntity e) { ents[nextNormalEnt++] = e; e.SetEntityIndex(nextNormalEnt - 1, false); return((uint)(nextNormalEnt - 1)); }