internal static void Postfix(CyclopsSonarDisplay __instance)
        {
            foreach (CyclopsSonarDisplay.EntityPing entity in __instance.entitysOnSonar)
            {
                if (entity == null || entity.ping == null)
                {
                    continue;
                }

                CyclopsHUDSonarPing ping = entity.ping.GetComponent <CyclopsHUDSonarPing>();

                // Are there any aggressive creatures on sonar?
                if (ping.currentColor == ping.aggressiveColor)
                {
                    SubRoot cyclops = __instance.GetComponentInParent <SubRoot>();

                    if (cyclops == null)
                    {
                        QuickLogger.Error("Unable to find Cyclops SubRoot in CyclopsSonarDisplay parent");
                        return;
                    }

                    MCUServices.Find.AuxCyclopsManager <Zapper>(cyclops)?.Zap();
                }
            }
        }
Example #2
0
        internal static void Postfix(CyclopsSonarDisplay __instance)
        {
            SubRoot cyclops = __instance?.noiseManager?.subRoot;

            if (cyclops == null)
            {
                QuickLogger.Error("Unable to find Cyclops SubRoot in CyclopsSonarDisplay parent");
                return;
            }

            foreach (CyclopsSonarDisplay.EntityPing entity in __instance.entitysOnSonar)
            {
                CyclopsHUDSonarPing ping = entity?.ping?.GetComponent <CyclopsHUDSonarPing>();

                if (ping == null)
                {
                    continue;
                }

                // Are there any aggressive creatures on sonar?
                if (ping.currentColor != ping.aggressiveColor)
                {
                    return;
                }

                // Yes, both auto-defense zappers can be activated at the same time
                MCUServices.Find.AuxCyclopsManager <AutoDefenser>(cyclops)?.Zap();
                MCUServices.Find.AuxCyclopsManager <AutoDefenserMk2>(cyclops)?.Zap();
            }
        }
Example #3
0
        internal static void Postfix(CyclopsSonarCreatureDetector.EntityData entityData, CyclopsSonarDisplay __instance)
        {
            if (entityData.entityType != CyclopsSonarDisplay.EntityType.Creature)
            {
                return;
            }

            if (entityData.attackCyclops == null)
            {
                return;
            }

            SubRoot cyclops = __instance?.noiseManager?.subRoot;

            if (cyclops == null)
            {
                QuickLogger.Error("Unable to find Cyclops SubRoot in CyclopsSonarDisplay parent", true);
                return;
            }

            // Did we just detect an aggressive creature on sonar?
            if (!entityData.attackCyclops.IsAggressiveTowardsCyclops(cyclops.gameObject))
            {
                return;
            }

            // Yes, both auto-defense zappers can be activated at the same time
            var defenser = MCUServices.Find.AuxCyclopsManager <AutoDefenser>(cyclops);

            if (defenser != null)
            {
                defenser.Zap(entityData);
            }
            else
            {
                QuickLogger.Warning("Unable to find AutoDefenser AuxCyclopsManager", true);
            }

            var defenserMk2 = MCUServices.Find.AuxCyclopsManager <AutoDefenserMk2>(cyclops);

            if (defenserMk2 != null)
            {
                defenserMk2.Zap(entityData);
            }
            else
            {
                QuickLogger.Warning("Unable to find AutoDefenserMk2 AuxCyclopsManager", true);
            }
        }
        internal static void Postfix(CyclopsSonarCreatureDetector.EntityData entityData, CyclopsSonarDisplay __instance)
        {
            if (entityData.entityType != CyclopsSonarDisplay.EntityType.Creature)
            {
                return;
            }

            if (entityData.attackCyclops == null)
            {
                return;
            }

            SubRoot cyclops = __instance.GetComponentInParent <SubRoot>();

            if (cyclops == null)
            {
                QuickLogger.Error("Unable to find Cyclops SubRoot in CyclopsSonarDisplay parent");
                return;
            }

            // Did we just detect an aggressive creature on sonar?
            if (!entityData.attackCyclops.IsAggressiveTowardsCyclops(cyclops.gameObject))
            {
                return;
            }

            MCUServices.Find.AuxCyclopsManager <Zapper>(cyclops)?.Zap(entityData);
        }