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();
                }
            }
        }
    }
 protected virtual void Spawn(int numToSpawn)
 {
     numToSpawn = Mathf.Min(numToSpawn, this.maxPopulation - this.currentPopulation);
     for (int index = 0; index < numToSpawn; ++index)
     {
         Vector3        pos;
         Quaternion     rot;
         BaseSpawnPoint spawnPoint = this.GetSpawnPoint(out pos, out rot);
         if (Object.op_Implicit((Object)spawnPoint))
         {
             BaseEntity entity = GameManager.server.CreateEntity(this.GetPrefab(), pos, rot, false);
             if (Object.op_Implicit((Object)entity))
             {
                 entity.enableSaving = false;
                 ((Component)entity).get_gameObject().AwakeFromInstantiate();
                 entity.Spawn();
                 this.PostSpawnProcess(entity, spawnPoint);
                 M0 m0 = ((Component)entity).get_gameObject().AddComponent <SpawnPointInstance>();
                 ((SpawnPointInstance)m0).parentSpawnGroup = this;
                 ((SpawnPointInstance)m0).parentSpawnPoint = spawnPoint;
                 ((SpawnPointInstance)m0).Notify();
             }
         }
     }
 }
Exemple #3
0
 protected override void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
 {
     base.PostSpawnProcess(entity, spawnPoint);
     if (attachToParent != null)
     {
         entity.SetParent(attachToParent, true);
     }
 }
Exemple #4
0
 protected override void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
 {
     base.PostSpawnProcess(entity, spawnPoint);
     if (!Object.op_Inequality((Object)this.attachToParent, (Object)null))
     {
         return;
     }
     entity.SetParent(this.attachToParent, true, false);
 }
Exemple #5
0
    protected override void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
    {
        HTNPlayer hTNPlayer = entity as HTNPlayer;

        if (hTNPlayer != null && hTNPlayer.AiDomain != null)
        {
            hTNPlayer.AiDomain.Movement       = Movement;
            hTNPlayer.AiDomain.MovementRadius = MovementRadius;
        }
    }
    protected override void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
    {
        HTNPlayer movement = entity as HTNPlayer;

        if (movement != null && movement.AiDomain != null)
        {
            movement.AiDomain.Movement       = this.Movement;
            movement.AiDomain.MovementRadius = this.MovementRadius;
        }
    }
    protected override void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
    {
        HTNPlayer htnPlayer = entity as HTNPlayer;

        if (!Object.op_Inequality((Object)htnPlayer, (Object)null) || !Object.op_Inequality((Object)htnPlayer.AiDomain, (Object)null))
        {
            return;
        }
        htnPlayer.AiDomain.Movement       = this.Movement;
        htnPlayer.AiDomain.MovementRadius = this.MovementRadius;
    }
    protected virtual BaseSpawnPoint GetSpawnPoint(out Vector3 pos, out Quaternion rot)
    {
        BaseSpawnPoint baseSpawnPoint = (BaseSpawnPoint)null;

        pos = Vector3.get_zero();
        rot = Quaternion.get_identity();
        int num = Random.Range(0, this.spawnPoints.Length);

        for (int index = 0; index < this.spawnPoints.Length; ++index)
        {
            baseSpawnPoint = this.spawnPoints[(num + index) % this.spawnPoints.Length];
            if (Object.op_Implicit((Object)baseSpawnPoint) && ((Component)baseSpawnPoint).get_gameObject().get_activeSelf())
            {
                break;
            }
        }
        if (Object.op_Implicit((Object)baseSpawnPoint))
        {
            baseSpawnPoint.GetLocation(out pos, out rot);
        }
        return(baseSpawnPoint);
    }
Exemple #9
0
        private BaseSpawnPoint GetSpawnPoint(out Vector3 pos, out Quaternion rot)
        {
            BaseSpawnPoint spawnPoints = null;

            pos = Vector3.zero;
            rot = Quaternion.identity;
            int num = UnityEngine.Random.Range(0, (int)this.SpawnPoints.Length);

            for (int i = 0; i < (int)this.SpawnPoints.Length; i++)
            {
                spawnPoints = this.SpawnPoints[(num + i) % (int)this.SpawnPoints.Length];
                if (spawnPoints && spawnPoints.gameObject.activeSelf)
                {
                    break;
                }
            }
            if (spawnPoints)
            {
                spawnPoints.GetLocation(out pos, out rot);
            }
            return(spawnPoints);
        }
    protected virtual BaseSpawnPoint GetSpawnPoint(out Vector3 pos, out Quaternion rot)
    {
        BaseSpawnPoint baseSpawnPoint = null;

        pos = Vector3.zero;
        rot = Quaternion.identity;
        int num = UnityEngine.Random.Range(0, (int)this.spawnPoints.Length);

        for (int i = 0; i < (int)this.spawnPoints.Length; i++)
        {
            baseSpawnPoint = this.spawnPoints[(num + i) % (int)this.spawnPoints.Length];
            if (baseSpawnPoint && baseSpawnPoint.gameObject.activeSelf)
            {
                break;
            }
        }
        if (baseSpawnPoint)
        {
            baseSpawnPoint.GetLocation(out pos, out rot);
        }
        return(baseSpawnPoint);
    }
        protected override void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
        {
            Scientist component = (Scientist)((Component)entity).GetComponent <Scientist>();

            if (!Object.op_Implicit((Object)component))
            {
                return;
            }
            component.Stats.Hostility              = this.SpawnHostile ? 1f : 0.0f;
            component.Stats.Defensiveness          = this.SpawnHostile ? 1f : (this.IsBandit ? 1f : 0.0f);
            component.Stats.OnlyAggroMarkedTargets = this.OnlyAggroMarkedTargets;
            component.Stats.IsMobile = this.Mobile;
            component.NeverMove      = this.NeverMove;
            component.WaypointSet    = this.Waypoints;
            if (this.LookAtInterestPointsStationary != null && this.LookAtInterestPointsStationary.Length != 0)
            {
                component.LookAtInterestPointsStationary = this.LookAtInterestPointsStationary;
            }
            component.RadioEffectRepeatRange = this.RadioEffectRepeatRange;
            component.SetFact(NPCPlayerApex.Facts.IsPeacekeeper, this.IsPeacekeeper ? (byte)1 : (byte)0, true, true);
            component.SetFact(NPCPlayerApex.Facts.IsBandit, this.IsBandit ? (byte)1 : (byte)0, true, true);
            component.SetFact(NPCPlayerApex.Facts.IsMilitaryTunnelLab, this.IsMilitaryTunnelLab ? (byte)1 : (byte)0, true, true);
            component.Stats.MaxRangeToSpawnLoc = this.MaxRangeToSpawnLoc;
            if (!this.SpawnHostile)
            {
                component.SetPlayerFlag(BasePlayer.PlayerFlags.Relaxed, true);
                component.SetFact(NPCPlayerApex.Facts.Speed, (byte)0, true, true);
            }
            if (Object.op_Equality((Object)this._mgr, (Object)null))
            {
                this._mgr = (AiLocationManager)((Component)this).GetComponentInParent <AiLocationManager>();
            }
            if (!Object.op_Inequality((Object)this._mgr, (Object)null))
            {
                return;
            }
            component.AiContext.AiLocationManager = this._mgr;
        }
 protected virtual void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
 {
 }
        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();
                    }
                }
            }
        }
        protected override void Spawn(int numToSpawn)
        {
            if (!AI.npc_enable)
            {
                this.maxPopulation        = 0;
                this.numToSpawnPerTickMax = 0;
                this.numToSpawnPerTickMin = 0;
            }
            else
            {
                if (numToSpawn == 0)
                {
                    if (this.IsMainSpawner)
                    {
                        if (this.Location == AiLocationSpawner.SquadSpawnerLocation.MilitaryTunnels)
                        {
                            this.maxPopulation        = AI.npc_max_population_military_tunnels;
                            this.numToSpawnPerTickMax = AI.npc_spawn_per_tick_max_military_tunnels;
                            this.numToSpawnPerTickMin = AI.npc_spawn_per_tick_min_military_tunnels;
                            numToSpawn = Random.Range(this.numToSpawnPerTickMin, this.numToSpawnPerTickMax + 1);
                        }
                        else
                        {
                            this.maxPopulation        = this.defaultMaxPopulation;
                            this.numToSpawnPerTickMax = this.defaultNumToSpawnPerTickMax;
                            this.numToSpawnPerTickMin = this.defaultNumToSpawnPerTickMin;
                            numToSpawn = Random.Range(this.numToSpawnPerTickMin, this.numToSpawnPerTickMax + 1);
                        }
                    }
                    else
                    {
                        this.maxPopulation        = this.defaultMaxPopulation;
                        this.numToSpawnPerTickMax = this.defaultNumToSpawnPerTickMax;
                        this.numToSpawnPerTickMin = this.defaultNumToSpawnPerTickMin;
                        numToSpawn = Random.Range(this.numToSpawnPerTickMin, this.numToSpawnPerTickMax + 1);
                    }
                }
                float num = this.chance;
                switch (this.Location)
                {
                case AiLocationSpawner.SquadSpawnerLocation.JunkpileA:
                    num = AI.npc_junkpile_a_spawn_chance;
                    break;

                case AiLocationSpawner.SquadSpawnerLocation.JunkpileG:
                    num = AI.npc_junkpile_g_spawn_chance;
                    break;
                }
                if (numToSpawn == 0 || (double)Random.get_value() > (double)num || (this.Location == AiLocationSpawner.SquadSpawnerLocation.JunkpileA || this.Location == AiLocationSpawner.SquadSpawnerLocation.JunkpileG) && NPCPlayerApex.AllJunkpileNPCs.Count >= AI.npc_max_junkpile_count)
                {
                    return;
                }
                numToSpawn = Mathf.Min(numToSpawn, this.maxPopulation - this.currentPopulation);
                for (int index = 0; index < numToSpawn; ++index)
                {
                    Vector3        pos;
                    Quaternion     rot;
                    BaseSpawnPoint spawnPoint = this.GetSpawnPoint(out pos, out rot);
                    if (Object.op_Implicit((Object)spawnPoint))
                    {
                        BaseEntity entity = GameManager.server.CreateEntity(this.GetPrefab(), pos, rot, true);
                        if (Object.op_Implicit((Object)entity))
                        {
                            if (Object.op_Inequality((Object)this.Manager, (Object)null))
                            {
                                NPCPlayerApex npc = entity as NPCPlayerApex;
                                if (Object.op_Inequality((Object)npc, (Object)null))
                                {
                                    npc.AiContext.AiLocationManager = this.Manager;
                                    if (Object.op_Inequality((Object)this.Junkpile, (Object)null))
                                    {
                                        this.Junkpile.AddNpc(npc);
                                    }
                                }
                            }
                            entity.Spawn();
                            M0 m0 = ((Component)entity).get_gameObject().AddComponent <SpawnPointInstance>();
                            ((SpawnPointInstance)m0).parentSpawnGroup = (SpawnGroup)this;
                            ((SpawnPointInstance)m0).parentSpawnPoint = spawnPoint;
                            ((SpawnPointInstance)m0).Notify();
                        }
                    }
                }
            }
        }
        protected override void PostSpawnProcess(BaseEntity entity, BaseSpawnPoint spawnPoint)
        {
            float     single;
            object    obj;
            object    obj1;
            object    obj2;
            Scientist component = entity.GetComponent <Scientist>();

            if (component)
            {
                component.Stats.Hostility = (this.SpawnHostile ? 1f : 0f);
                if (this.SpawnHostile)
                {
                    single = 1f;
                }
                else
                {
                    single = (this.IsBandit ? 1f : 0f);
                }
                component.Stats.Defensiveness          = single;
                component.Stats.OnlyAggroMarkedTargets = this.OnlyAggroMarkedTargets;
                component.Stats.IsMobile = this.Mobile;
                component.NeverMove      = this.NeverMove;
                component.WaypointSet    = this.Waypoints;
                if (this.LookAtInterestPointsStationary != null && this.LookAtInterestPointsStationary.Length != 0)
                {
                    component.LookAtInterestPointsStationary = this.LookAtInterestPointsStationary;
                }
                component.RadioEffectRepeatRange = this.RadioEffectRepeatRange;
                Scientist scientist = component;
                if (this.IsPeacekeeper)
                {
                    obj = 1;
                }
                else
                {
                    obj = null;
                }
                scientist.SetFact(NPCPlayerApex.Facts.IsPeacekeeper, (byte)obj, true, true);
                Scientist scientist1 = component;
                if (this.IsBandit)
                {
                    obj1 = 1;
                }
                else
                {
                    obj1 = null;
                }
                scientist1.SetFact(NPCPlayerApex.Facts.IsBandit, (byte)obj1, true, true);
                Scientist scientist2 = component;
                if (this.IsMilitaryTunnelLab)
                {
                    obj2 = 1;
                }
                else
                {
                    obj2 = null;
                }
                scientist2.SetFact(NPCPlayerApex.Facts.IsMilitaryTunnelLab, (byte)obj2, true, true);
                component.Stats.MaxRangeToSpawnLoc = this.MaxRangeToSpawnLoc;
                if (!this.SpawnHostile)
                {
                    component.SetPlayerFlag(BasePlayer.PlayerFlags.Relaxed, true);
                    component.SetFact(NPCPlayerApex.Facts.Speed, 0, true, true);
                }
                if (this._mgr == null)
                {
                    this._mgr = base.GetComponentInParent <AiLocationManager>();
                }
                if (this._mgr != null)
                {
                    component.AiContext.AiLocationManager = this._mgr;
                }
            }
        }