Ejemplo 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);
        }
    }
Ejemplo n.º 2
0
    protected virtual void Spawn(int numToSpawn)
    {
        Vector3    vector3;
        Quaternion quaternion;

        numToSpawn = Mathf.Min(numToSpawn, this.maxPopulation - this.currentPopulation);
        for (int i = 0; i < numToSpawn; i++)
        {
            BaseSpawnPoint spawnPoint = this.GetSpawnPoint(out vector3, out quaternion);
            if (spawnPoint)
            {
                BaseEntity baseEntity = GameManager.server.CreateEntity(this.GetPrefab(), vector3, quaternion, false);
                if (baseEntity)
                {
                    baseEntity.enableSaving = false;
                    baseEntity.gameObject.AwakeFromInstantiate();
                    baseEntity.Spawn();
                    this.PostSpawnProcess(baseEntity, spawnPoint);
                    SpawnPointInstance spawnPointInstance = baseEntity.gameObject.AddComponent <SpawnPointInstance>();
                    spawnPointInstance.parentSpawnGroup = this;
                    spawnPointInstance.parentSpawnPoint = spawnPoint;
                    spawnPointInstance.Notify();
                }
            }
        }
    }
 public override void ObjectSpawned(SpawnPointInstance instance)
 {
     if (this.spawnEffect.isValid)
     {
         Effect.server.Run(this.spawnEffect.resourcePath, instance.GetComponent <BaseEntity>(), 0, Vector3.zero, Vector3.up, null, false);
     }
     this.OnObjectSpawnedEvent.Invoke();
     base.gameObject.SetActive(false);
 }
 public override void ObjectSpawned(SpawnPointInstance instance)
 {
     if (this.spawnEffect.isValid)
     {
         Effect.server.Run(this.spawnEffect.resourcePath, (BaseEntity)((Component)instance).GetComponent <BaseEntity>(), 0U, Vector3.get_zero(), Vector3.get_up(), (Connection)null, false);
     }
     this.OnObjectSpawnedEvent.Invoke();
     ((Component)this).get_gameObject().SetActive(false);
 }
 public override void ObjectRetired(SpawnPointInstance instance)
 {
     this.OnObjectRetiredEvent.Invoke();
     base.gameObject.SetActive(true);
 }
 public abstract void ObjectSpawned(SpawnPointInstance instance);
Ejemplo n.º 7
0
 public void ObjectRetired(SpawnPointInstance instance)
 {
     spawnInstance = null;
     nextSpawnTime = Time.time + Random.Range(respawnDelayMin, respawnDelayMax);
 }
Ejemplo n.º 8
0
 public void ObjectSpawned(SpawnPointInstance instance)
 {
     spawnInstance = instance;
 }
Ejemplo n.º 9
0
 public void ObjectRetired(SpawnPointInstance instance)
 {
     this.spawnInstances.Remove(instance);
 }
Ejemplo n.º 10
0
 public void ObjectSpawned(SpawnPointInstance instance)
 {
     this.spawnInstances.Add(instance);
 }
Ejemplo n.º 11
0
 public override void ObjectRetired(SpawnPointInstance instance)
 {
 }
        protected override void Spawn(int numToSpawn)
        {
            AiLocationSpawner.SquadSpawnerLocation location;
            Vector3    vector3;
            Quaternion quaternion;

            if (!ConVar.AI.npc_enable)
            {
                this.maxPopulation        = 0;
                this.numToSpawnPerTickMax = 0;
                this.numToSpawnPerTickMin = 0;
                return;
            }
            if (numToSpawn == 0)
            {
                if (!this.IsMainSpawner)
                {
                    this.maxPopulation        = this.defaultMaxPopulation;
                    this.numToSpawnPerTickMax = this.defaultNumToSpawnPerTickMax;
                    this.numToSpawnPerTickMin = this.defaultNumToSpawnPerTickMin;
                    numToSpawn = UnityEngine.Random.Range(this.numToSpawnPerTickMin, this.numToSpawnPerTickMax + 1);
                }
                else
                {
                    location = this.Location;
                    if (location != AiLocationSpawner.SquadSpawnerLocation.MilitaryTunnels)
                    {
                        this.maxPopulation        = this.defaultMaxPopulation;
                        this.numToSpawnPerTickMax = this.defaultNumToSpawnPerTickMax;
                        this.numToSpawnPerTickMin = this.defaultNumToSpawnPerTickMin;
                        numToSpawn = UnityEngine.Random.Range(this.numToSpawnPerTickMin, this.numToSpawnPerTickMax + 1);
                    }
                    else
                    {
                        this.maxPopulation        = ConVar.AI.npc_max_population_military_tunnels;
                        this.numToSpawnPerTickMax = ConVar.AI.npc_spawn_per_tick_max_military_tunnels;
                        this.numToSpawnPerTickMin = ConVar.AI.npc_spawn_per_tick_min_military_tunnels;
                        numToSpawn = UnityEngine.Random.Range(this.numToSpawnPerTickMin, this.numToSpawnPerTickMax + 1);
                    }
                }
            }
            float npcJunkpileASpawnChance = this.chance;

            location = this.Location;
            if (location == AiLocationSpawner.SquadSpawnerLocation.JunkpileA)
            {
                npcJunkpileASpawnChance = ConVar.AI.npc_junkpile_a_spawn_chance;
            }
            else if (location == AiLocationSpawner.SquadSpawnerLocation.JunkpileG)
            {
                npcJunkpileASpawnChance = ConVar.AI.npc_junkpile_g_spawn_chance;
            }
            if (numToSpawn == 0 || UnityEngine.Random.@value > npcJunkpileASpawnChance || (this.Location == AiLocationSpawner.SquadSpawnerLocation.JunkpileA || this.Location == AiLocationSpawner.SquadSpawnerLocation.JunkpileG) && NPCPlayerApex.AllJunkpileNPCs.Count >= ConVar.AI.npc_max_junkpile_count)
            {
                return;
            }
            numToSpawn = Mathf.Min(numToSpawn, this.maxPopulation - base.currentPopulation);
            for (int i = 0; i < numToSpawn; i++)
            {
                BaseSpawnPoint spawnPoint = this.GetSpawnPoint(out vector3, out quaternion);
                if (spawnPoint)
                {
                    BaseEntity baseEntity = GameManager.server.CreateEntity(base.GetPrefab(), vector3, quaternion, true);
                    if (baseEntity)
                    {
                        if (this.Manager != null)
                        {
                            NPCPlayerApex manager = baseEntity as NPCPlayerApex;
                            if (manager != null)
                            {
                                manager.AiContext.AiLocationManager = this.Manager;
                                if (this.Junkpile != null)
                                {
                                    this.Junkpile.AddNpc(manager);
                                }
                            }
                        }
                        baseEntity.Spawn();
                        SpawnPointInstance spawnPointInstance = baseEntity.gameObject.AddComponent <SpawnPointInstance>();
                        spawnPointInstance.parentSpawnGroup = this;
                        spawnPointInstance.parentSpawnPoint = spawnPoint;
                        spawnPointInstance.Notify();
                    }
                }
            }
        }
Ejemplo n.º 13
0
 public override void ObjectRetired(SpawnPointInstance instance)
 {
     this.OnObjectRetiredEvent.Invoke();
     ((Component)this).get_gameObject().SetActive(true);
 }