Beispiel #1
0
        private void HandleActiveTossedBallGrounded(DebrisObject obj)
        {
            obj.OnGrounded -= this.HandleActiveTossedBallGrounded;
            MonsterBall component = obj.GetComponent <MonsterBall>();
            //component.spriteAnimator.Play("monster_ball_open");
            AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(component.m_storedEnemyGuid);

            if (orLoadByGuid == null)
            {
                if (m_Debug)
                {
                    ETGModConsole.Log("[Monster_Ball] Tried to spawn an unknown AIActor! (Enemy GUID not found)");
                }
                component.m_containsEnemy   = false;
                component.m_wasBlackPhantom = false;
                component.m_storedEnemyGuid = string.Empty;
                component.IsCurrentlyActive = false;
                component.ApplyCooldown(this.LastOwner);
                return;
            }
            IntVector2 bestRewardLocation = obj.transform.position.GetAbsoluteRoom().GetBestRewardLocation(orLoadByGuid.Clearance, obj.sprite.WorldCenter, true);
            AIActor    m_CachedEnemy      = AIActor.Spawn(orLoadByGuid, bestRewardLocation, obj.transform.position.GetAbsoluteRoom(), true, AIActor.AwakenAnimationType.Default, true);

            // m_CachedEnemy.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
            this.MakeCompanion(this.LastOwner, m_CachedEnemy, component.m_wasBlackPhantom);
            LootEngine.DoDefaultItemPoof(m_CachedEnemy.CenterPosition, false, false);
            component.m_containsEnemy   = false;
            component.m_storedEnemyGuid = string.Empty;
            component.IsCurrentlyActive = false;
            component.ApplyCooldown(this.LastOwner);
        }
Beispiel #2
0
        protected override void DoActiveEffect(PlayerController user)
        {
            if (GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.END_TIMES)
            {
                return;
            }
            DebrisObject debrisObject = user.DropActiveItem(this, 10f, false);

            if (debrisObject)
            {
                AIActor[] currentActors = FindObjectsOfType <AIActor>();
                if (currentActors != null && currentActors.Length > 0)
                {
                    foreach (AIActor actor in currentActors)
                    {
                        if (!string.IsNullOrEmpty(actor.name))
                        {
                            if (actor.name.ToLower().Contains("companionpet"))
                            {
                                LootEngine.DoDefaultItemPoof(actor.CenterPosition, false, false);
                                actor.EraseFromExistence(false);
                            }
                        }
                    }
                }
                MonsterBall component = debrisObject.GetComponent <MonsterBall>();
                // component.spriteAnimator.Play("monster_ball_throw");
                component.m_containsEnemy   = this.m_containsEnemy;
                component.m_storedEnemyGuid = this.m_storedEnemyGuid;
                component.m_wasBlackPhantom = this.m_wasBlackPhantom;
                component.m_Debug           = this.m_Debug;
                DebrisObject debrisObject2 = debrisObject;
                debrisObject2.OnGrounded += this.HandleActiveTossedBallGrounded;
            }
        }
Beispiel #3
0
        public override void Start()
        {
            FakePrefabHooks.Init();
            ItemBuilder.Init();

            KatanaDash.Init();
            CueBullets.Init();
            ThirstForVengeance.Init();
            OldJournal.Init();
            //RingOfLightningResistance.Init();
            HungryCaterpillar.Init();
            TableTechHole.Init();
            TableTechMirror.Init();
            Thunderbolt.Init();
            BrittleBullets.Init();
            BubbleShield.Init();
            MonsterBall.Init();

            //e9fa6544000942a79ad05b6e4afb62db

            new Hook(typeof(CaterpillarDevourHeartBehavior).GetMethod("IsHeartInRoom", BindingFlags.NonPublic | BindingFlags.Instance), typeof(HungryCaterpillar).GetMethod("IsHeartInRoom"));
            new Hook(typeof(CaterpillarDevourHeartBehavior).GetMethod("MunchHeart", BindingFlags.NonPublic | BindingFlags.Instance), typeof(HungryCaterpillar).GetMethod("MunchHeart"));

            new Hook(typeof(PlayerController).GetMethod("InitializeCallbacks", BindingFlags.NonPublic | BindingFlags.Instance), typeof(ThirstForVengeance).GetMethod("InitializeCallbacks"));
            new Hook(typeof(PlayerController).GetMethod("RevengeRevive", BindingFlags.NonPublic | BindingFlags.Instance), typeof(ThirstForVengeance).GetMethod("NoRevengeFullHeal"));

            new Hook(typeof(CompanionController).GetMethod("HandleCompanionPostProcessProjectile", BindingFlags.NonPublic | BindingFlags.Instance), typeof(MonsterBall).GetMethod("HandleCompanionPostProcessProjectile", BindingFlags.Public | BindingFlags.Instance), typeof(CompanionController));
        }
Beispiel #4
0
        protected override void DoEffect(PlayerController user)
        {
            if (GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.END_TIMES)
            {
                return;
            }
            DebrisObject debrisObject = user.DropActiveItem(this, 10f, false);

            if (debrisObject)
            {
                MonsterBall component = debrisObject.GetComponent <MonsterBall>();
                //component.spriteAnimator.Play("monster_ball_throw");
                component.m_containsEnemy   = this.m_containsEnemy;
                component.m_storedEnemyGuid = this.m_storedEnemyGuid;
                DebrisObject debrisObject2 = debrisObject;
                debrisObject2.OnGrounded += this.HandleTossedBallGrounded;
            }
        }
Beispiel #5
0
        // Re-use code from baby dragun NPC to make Enemy get sucked into ball. Looks cooler then a simple poof effect. :D
        private IEnumerator SuckUpEnemy(AIActor targetEnemy, DebrisObject obj, PlayerController owner)
        {
            float          elapsed      = 0f;
            float          duration     = 0.5f;
            Vector3        startPos     = targetEnemy.transform.position;
            Vector3        finalOffset  = obj.sprite.WorldCenter - startPos.XY();
            tk2dBaseSprite targetSprite = targetEnemy.GetComponentInChildren <tk2dBaseSprite>();

            targetEnemy.behaviorSpeculator.InterruptAndDisable();
            Destroy(targetEnemy);
            Destroy(targetEnemy.specRigidbody);
            yield return(null);

            AkSoundEngine.PostEvent("Play_NPC_BabyDragun_Munch_01", obj.gameObject);
            while (elapsed < duration)
            {
                elapsed += BraveTime.DeltaTime;
                if (!targetSprite || !targetSprite.transform)
                {
                    yield return(null);
                }
                else
                {
                    targetSprite.transform.localScale = Vector3.Lerp(Vector3.one, new Vector3(0.01f, 0.01f, 1f), elapsed / duration);
                    targetSprite.transform.position   = Vector3.Lerp(startPos, startPos + finalOffset, elapsed / duration);
                }
                yield return(null);
            }
            Destroy(targetSprite.gameObject);

            MonsterBall monsterBall = obj.GetComponent <MonsterBall>();

            if (monsterBall)
            {
                if (monsterBall.AutoPickup)
                {
                    yield return(new WaitForSeconds(0.2f));

                    LootEngine.DoDefaultItemPoof(obj.transform.position, false, false);
                    monsterBall.Pickup(owner);
                }
            }
            yield break;
        }
Beispiel #6
0
        private void HandleTossedBallGrounded(DebrisObject obj)
        {
            obj.OnGrounded -= this.HandleTossedBallGrounded;
            MonsterBall component = obj.GetComponent <MonsterBall>();
            // component.spriteAnimator.Play("monster_ball_open");
            float   distance        = -1f;
            float   nearestDistance = float.MaxValue;
            AIActor nearestEnemy    = null;

            try
            {
                List <AIActor> activeEnemies = obj.transform.position.GetAbsoluteRoom().GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
                if (activeEnemies == null)
                {
                    goto SKIP;
                }
                for (int i = 0; i < activeEnemies.Count; i++)
                {
                    AIActor enemy = activeEnemies[i];
                    if (!enemy.IsMimicEnemy && enemy.healthHaver && !enemy.healthHaver.IsBoss && enemy.healthHaver.IsVulnerable)
                    {
                        if (!enemy.healthHaver.IsDead)
                        {
                            if (!BannedMonsterBallEnemies.Contains(enemy.EnemyGuid))
                            {
                                float num = Vector2.Distance(obj.sprite.WorldCenter, enemy.CenterPosition);
                                if (num < nearestDistance)
                                {
                                    nearestDistance = num;
                                    nearestEnemy    = enemy;
                                }
                            }
                        }
                    }
                }
SKIP:
                if (nearestEnemy == null)
                {
                    AIActor[] AllEnemiesOnFloor = FindObjectsOfType <AIActor>();
                    if (AllEnemiesOnFloor == null)
                    {
                        if (component.m_Debug)
                        {
                            ETGModConsole.Log("[Monster_Ball] No Enemies present on the floor?");
                        }
                    }
                    else
                    {
                        for (int i = 0; i < AllEnemiesOnFloor.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(AllEnemiesOnFloor[i].name))
                            {
                                if (AllEnemiesOnFloor[i].name.ToLower().Contains("companionpet"))
                                {
                                    nearestEnemy    = AllEnemiesOnFloor[i];
                                    nearestDistance = component.EnemySearchRadius;
                                }
                            }
                        }
                    }
                }
                if (component.m_Debug && nearestEnemy == null)
                {
                    ETGModConsole.Log("[Monster_Ball] activeEnemies is null.");
                }
                if (nearestEnemy && distance <= component.EnemySearchRadius)
                {
                    if (component.m_Debug)
                    {
                        ETGModConsole.Log("Monster_Ball: Attempting to capture: " + nearestEnemy.GetActorName());
                    }
                    component.m_containsEnemy   = true;
                    component.m_storedEnemyGuid = nearestEnemy.EnemyGuid;
                    component.m_wasBlackPhantom = nearestEnemy.IsBlackPhantom;
                    GameManager.Instance.StartCoroutine(SuckUpEnemy(nearestEnemy, obj, this.LastOwner));
                }
                else
                {
                    component.m_containsEnemy   = false;
                    component.m_storedEnemyGuid = string.Empty;
                    component.m_wasBlackPhantom = false;
                    if (component.m_Debug && nearestEnemy == null)
                    {
                        ETGModConsole.Log("[Monster_Ball] No enemies in room!");
                    }
                    else if (component.m_Debug && nearestEnemy != null && distance > component.EnemySearchRadius)
                    {
                        ETGModConsole.Log("[Monster_Ball] No enemy in range!");
                    }
                    return;
                }
            }
            catch (Exception)
            {
                if (component.m_Debug)
                {
                    ETGModConsole.Log("[Monster Ball] Exception in HandleTossedBallGrounded!");
                }
                component.m_containsEnemy   = false;
                component.m_storedEnemyGuid = string.Empty;
                component.m_wasBlackPhantom = false;
            }
        }