Exemplo n.º 1
0
        public void Explode()
        {
            if (dead == true)
            {
                return;
            }
            dead = true;

            if (exploderConfig.NoExplosionOnDeath)
            {
                return;
            }

            enemyAgent.Appearance.InterpolateGlow(glowColor, 0.1f);
            var fx = s_explodeFXPool.AquireEffect();

            fx.Play(null, enemyAgent.Position, Quaternion.LookRotation(enemyAgent.TargetLookDir));

            var noise = new NM_NoiseData()
            {
                noiseMaker = null,
                position   = enemyAgent.Position,
                radiusMin  = exploderConfig.NoiseMin,
                radiusMax  = exploderConfig.NoiseMax,
                yScale     = 1,
                node       = enemyAgent.CourseNode,
                type       = NM_NoiseType.InstaDetect,
                includeToNeightbourAreas = true,
                raycastFirstNode         = false
            };

            ExplosionUtil.TriggerExplodion(enemyAgent.EyePosition, exploderConfig.Damage, exploderConfig.Radius, noise);
        }
Exemplo n.º 2
0
        public static void Postfix(pReactorState newState, pReactorState oldState, LG_WardenObjective_Reactor __instance)
        {
            if (newState.status == oldState.status)
            {
                return;
            }

            if (newState.status == eReactorStatus.Shutdown_intro)
            {
                __instance.m_sound.Post(EVENTS.LIGHTS_OFF_GLOBAL);
                __instance.m_sound.Post(EVENTS.REACTOR_SHUTDOWN);
                var noise = new NM_NoiseData()
                {
                    noiseMaker = null,
                    position   = __instance.m_terminalAlign.position,
                    radiusMin  = 7,
                    radiusMax  = 100,
                    yScale     = 1f,
                    node       = __instance.SpawnNode,
                    type       = NM_NoiseType.InstaDetect,
                    includeToNeightbourAreas = false,
                    raycastFirstNode         = false
                };
                NoiseManager.MakeNoise(noise);
            }
        }
        public override bool Trigger()
        {
            Activated = true;
            Agent.Locomotion.ChangeState((int)ES_StateEnum.Dead);

            Agent.Appearance.InterpolateGlow(GlowColor, 0.1f);
            var fx = s_explodeFXPool.AquireEffect();

            fx.Play(null, Agent.Position, Quaternion.LookRotation(Agent.TargetLookDir));

            var noise = new NM_NoiseData()
            {
                noiseMaker = null,
                position   = Agent.Position,
                radiusMin  = ExploderConfig.NoiseMin,
                radiusMax  = ExploderConfig.NoiseMax,
                yScale     = 1,
                node       = Agent.CourseNode,
                type       = NM_NoiseType.InstaDetect,
                includeToNeightbourAreas = true,
                raycastFirstNode         = false
            };

            ExplosionUtil.TriggerExplodion(Agent.EyePosition, ExploderConfig.Damage, ExploderConfig.Radius, noise);
            PlaySplatter();
            return(false);
        }
        public void Activate(uint enemyID, int count, LG_LayerType layer, eLocalZoneIndex zoneIndex, string areaName)
        {
            var enemies  = UnityEngine.Object.FindObjectsOfType <EnemyAgent>();
            int curCount = 0;

            for (int index = 0; index < enemies.Count && (count == -1 || curCount < count); index++)
            {
                var enemy = enemies[index];

                var node = enemy.CourseNode;
                if (node != null && node.LayerType == layer && node.m_zone.LocalIndex == zoneIndex && node.m_area.m_navInfo.Suffix.ToLower() == areaName)
                {
                    if (enemy.EnemyData.persistentID == enemyID && enemy.AI != null && enemy.Alive)
                    {
                        NM_NoiseData data = new NM_NoiseData()
                        {
                            noiseMaker = null,
                            position   = enemy.Position,
                            radiusMin  = 0f,
                            radiusMax  = 100f,
                            yScale     = 1f,
                            node       = enemy.CourseNode,
                            type       = NM_NoiseType.InstaDetect,
                            includeToNeightbourAreas = true,
                            raycastFirstNode         = false
                        };

                        NoiseManager.MakeNoise(data);
                        curCount++;
                    }
                }
            }
        }
        public static void TriggerExplodion(Vector3 position, float damage, float range, NM_NoiseData noiseData)
        {
            CellSound.Post(EVENTS.STICKYMINEEXPLODE, position);
            _ = LightFlash(position);
            if (SNet.IsMaster)
            {
                var pos     = position;
                var targets = Physics.OverlapSphere(pos, range, LayerManager.MASK_EXPLOSION_TARGETS);

                foreach (var target in targets)
                {
                    Vector3 targetPos = target.transform.position;

                    Agent agent = target.GetComponent <Agent>();
                    if (agent != null)
                    {
                        targetPos = agent.EyePosition;
                    }
                    Vector3 direction = (targetPos - position).normalized;
                    bool    hit       = false;

                    if (!Physics.Raycast(pos, direction.normalized, out RaycastHit raycastHit, range, LayerManager.MASK_EXPLOSION_BLOCKERS))
                    {
                        hit = true;
                        var comp = target.GetComponent <IDamageable>();

                        if (comp != null)
                        {
                            comp.ExplosionDamage(damage, pos, Vector3.up * 1000);
                        }
                    }
                    else
                    {
#if DEBUG
                        //GameObject mySphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                        //mySphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                        //mySphere.transform.position = raycastHit.point;
                        //var col = mySphere.GetComponent<Collider>();
                        //var mesh = mySphere.GetComponent<MeshRenderer>();
                        //mesh.material.color = Color.red;
                        //GameObject.Destroy(col);
#endif
                    }


#if DEBUG
                    //GameObject line = new GameObject();
                    //line.AddComponent<LineRenderer>();
                    //LineRenderer lineRender = line.GetComponent<LineRenderer>();
                    //lineRender.material = new Material(Shader.Find("Sprites/Default"));
                    //lineRender.widthMultiplier = 0.05f;
                    //lineRender.SetColors(Color.green, Color.green);
                    //lineRender.SetPositions(new Vector3[] { pos, targetPos });
                    //
                    //if (hit == false)
                    //{
                    //    lineRender.SetColors(Color.red, Color.red);
                    //    lineRender.SetPositions(new Vector3[] { pos, raycastHit.point });
                    //}
#endif
                }