示例#1
0
    public GameObject SpawnPrefabInternal(int prefabId, int networkId, int owner, int controller, params object[] args)
    {
        Debug.Log("SpawnPrefabInternal : " + prefabId + " :" + networkId + " : " + owner + " : " + controller);

        if (GetConnection(owner) == null)
        {
            Debug.Log("SpawnPrefabInternal:: No connection with index: " + owner + ". Ignoring this SpawnPrefabInternal call");
        }

        GameObject    prefab = GetPrefab(prefabId);
        NetworkEntity ngo    = null;

        if (prefab != null)
        {
            GameObject g = GameObject.Instantiate(prefab);
            ngo            = g.GetComponent <NetworkEntity>();
            ngo.prefabId   = prefabId;
            ngo.networkId  = networkId;
            ngo.owner      = owner;
            ngo.controller = controller;
            ngo.OnSpawn(args);
        }

        //add it to the owners entity list
        if (ngo != null)
        {
            //SteamConnection c = GetConnection(owner);
            StoreEntity(owner, networkId, ngo);
            //c.entities[networkId] = ngo;
        }

        return(ngo.gameObject);
    }