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);
        }
    }
Example #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);
    }
Example #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);
    }
Example #4
0
    private void SetChoice(GameObject selection)
    {
        bool shouldDestroy = !PoolableEx.SupportsPoolingInParent(base.gameObject);

        ApplyChoice(selection, Arid, shouldDestroy);
        ApplyChoice(selection, Temperate, shouldDestroy);
        ApplyChoice(selection, Tundra, shouldDestroy);
        ApplyChoice(selection, Arctic, shouldDestroy);
        if (selection != null)
        {
            selection.SetActive(true);
        }
        GameManager.Destroy(this);
    }
Example #5
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);
    }
Example #6
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);
    }
Example #7
0
 public void Retire(GameObject instance)
 {
     if (!instance)
     {
         return;
     }
     using (TimeWarning.New("GameManager.Retire"))
     {
         if (BaseEntityEx.IsValid(instance.GetComponent <BaseEntity>()))
         {
             Debug.LogError("Trying to retire an entity without killing it first: " + instance.name);
         }
         if (!Rust.Application.isQuitting && ConVar.Pool.enabled && PoolableEx.SupportsPooling(instance))
         {
             pool.Push(instance);
         }
         else
         {
             Object.Destroy(instance);
         }
     }
 }