Exemplo n.º 1
0
        public static void DestroyNetworkEntity(int id)
        {
            if (!entities.ContainsKey(id))
            {
                Debug.LogWarning($"Tried to destroy entity (ID: {id}), but no such entity with that ID exists!");
                return;
            }

            ClientNetworkEntity entity = entities[id];

            entities.Remove(id);

            Destroy(entity.gameObject);
        }
Exemplo n.º 2
0
        public static ClientNetworkEntity SpawnNetworkEntity(int id, string entityType, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            if (entities.ContainsKey(id))
            {
                Debug.LogWarning($"Tried to spawn entity (type: {entityType}) with ID {id}, but an entity with that ID has already been added!");
                return(null);
            }

            ClientNetworkEntity entity = ClientNetworkEntityManager.SpawnClientNetworkEntity(entityType, position, rotation, scale)
                                         .AddComponent <ClientNetworkEntity>();

            entity.Initialize(id, entityType);
            entities.Add(entity.id, entity);
            return(entity);
        }