Esempio n. 1
0
    private void TrySpawnEntity()
    {
        if (IsSpawned)
        {
            return;
        }
        if (!HasSpaceToSpawn())
        {
            nextSpawnTime = Time.time + Random.Range(respawnDelayMin, respawnDelayMax);
            return;
        }
        BaseEntity baseEntity = GameManager.server.CreateEntity(entityPrefab.resourcePath, base.transform.position, base.transform.rotation, false);

        if (baseEntity != null)
        {
            baseEntity.enableSaving = false;
            PoolableEx.AwakeFromInstantiate(baseEntity.gameObject);
            baseEntity.Spawn();
            SpawnPointInstance spawnPointInstance = baseEntity.gameObject.AddComponent <SpawnPointInstance>();
            spawnPointInstance.parentSpawnPointUser = this;
            spawnPointInstance.Notify();
        }
        else
        {
            Debug.LogError("IndividualSpawner failed to spawn entity.", base.gameObject);
        }
    }
Esempio n. 2
0
    public GameObject CreatePrefab(string strPrefab, Vector3 pos, Quaternion rot, bool active = true)
    {
        GameObject gameObject = Instantiate(strPrefab, pos, rot);

        if ((bool)gameObject && active)
        {
            PoolableEx.AwakeFromInstantiate(gameObject);
        }
        return(gameObject);
    }
Esempio n. 3
0
    public GameObject CreatePrefab(string strPrefab, Vector3 pos, Quaternion rot, Vector3 scale, bool active = true)
    {
        GameObject gameObject = Instantiate(strPrefab, pos, rot);

        if ((bool)gameObject)
        {
            gameObject.transform.localScale = scale;
            if (active)
            {
                PoolableEx.AwakeFromInstantiate(gameObject);
            }
        }
        return(gameObject);
    }
Esempio n. 4
0
    public GameObject CreatePrefab(string strPrefab, Transform parent, bool active = true)
    {
        GameObject gameObject = Instantiate(strPrefab, parent.position, parent.rotation);

        if ((bool)gameObject)
        {
            gameObject.transform.SetParent(parent, false);
            TransformEx.Identity(gameObject);
            if (active)
            {
                PoolableEx.AwakeFromInstantiate(gameObject);
            }
        }
        return(gameObject);
    }
Esempio n. 5
0
    public GameObject InstantiateSkin(BaseEntity parent)
    {
        if (!onServer && isServer)
        {
            return(null);
        }
        GameObject gameObject = gameManager.CreatePrefab(prefab.resourcePath, parent.transform, false);

        if ((bool)gameObject)
        {
            gameObject.transform.localPosition = worldPosition;
            gameObject.transform.localRotation = worldRotation;
            PoolableEx.AwakeFromInstantiate(gameObject);
        }
        return(gameObject);
    }