Beispiel #1
0
        public static void BuildPrefab()
        {
            if (prefab == null || !EnemyBuilder.Dictionary.ContainsKey(guid))
            {
                //Sets up the prefab of the enemy. The spritepath, "CakeMod/Resources/Waterbulon/Idle/milton_idle_001", determines the setup sprite for your enemy. vvvv This bool right here determines whether or not an enemy has an AiShooter or not. AIShooters are necessary if you want your enemy to hold a gun for example. An example of this can be seen in Humphrey.
                prefab = EnemyBuilder.BuildPrefab("Waterbulon", guid, "CakeMod/Resources/Waterbulon/Idle/waterbulon_idle_001", new IntVector2(0, 0), new IntVector2(0, 0), false);
                //This line extends a BraveBehavior called EnemyBehavior, this is a generic behavior I use for setting up things that can't be setup in BuildPrefab.
                var enemy = prefab.AddComponent <EnemyBehavior>();
                //Here you can setup various things like movement speed, weight, and health. There's a lot you can do with the AiActor parameter so feel free to experiment.
                enemy.aiActor.MovementSpeed        = 6.7f;
                enemy.aiActor.knockbackDoer.weight = 500;
                enemy.aiActor.IgnoreForRoomClear   = false;
                enemy.aiActor.CollisionDamage      = 1f;
                enemy.aiActor.healthHaver.ForceSetCurrentHealth(15f);
                enemy.aiActor.healthHaver.SetHealthMaximum(15f, null, false);

                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider

                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 19,
                    ManualHeight           = 14,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 19,
                    ManualHeight           = 14,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });

                //This is where you setup your animations. Most animations need specific frame names to be recognized like idle or die.
                //The AddAnimation lines gets sprites from the folder specified in second phrase of the this line. At the very least you need an animation that contains the word idle for the idle animations for example.
                //AnimationType determines what kind of animation your making. In Gungeon there are 7 different Animation Types: Move, Idle, Fidget, Flight, Hit, Talk, Other. For a majority of these animations, these play automatically, however specific animations need to be told when to play such as Attack.
                //DirectionType determines the amount of ways an animation can face. You'll have to change your animation names to correspond with the DirectionType. For example if you want an animation to face eight ways you'll have to name your animations something like ""attack_south_west", "attack_north_east",  "attack_east", "attack_south_east",  "attack_north",  "attack_south", "attack_west", "attack_north_west" and change DirectionType to  DirectionType.EightWayOrdinal.
                //I suggest looking at the sprites of base game enemies to determine the names for the different directions.
                prefab.AddAnimation("idle_left", "CakeMod/Resources/Waterbulon/Idle", fps: 7, AnimationType.Idle, DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("idle_right", "CakeMod/Resources/Waterbulon/Idle", fps: 7, AnimationType.Idle, DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("run_left", "CakeMod/Resources/Waterbulon/Run", fps: 7, AnimationType.Move, DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("run_right", "CakeMod/Resources/Waterbulon/Run", fps: 7, AnimationType.Move, DirectionType.TwoWayHorizontal);
                //Note that the "die" and "attack" animations are only set to Move because they will be overwritten later.
                //tk2dSpriteAnimationClip.WrapMode.Once determines how an animation plays out. If you don't want it to loop, leave it to Once, otherwise you can change it to Loop or something.
                //Assign animation well assigns an animation to an animation type. By default this is on, but since we're overwritting this set this to false.
                prefab.AddAnimation("attack_left", "CakeMod/Resources/Waterbulon/Attack", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("attack_right", "CakeMod/Resources/Waterbulon/Attack", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_left", "CakeMod/Resources/Waterbulon/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_right", "CakeMod/Resources/Waterbulon/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                //Here we create a new DirectionalAnimation for our enemy to pull from.
                //Make sure the AnimNames correspong to the AddAnimation names.
                DirectionalAnimation attack = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "attack_right", "attack_left" },
                    Flipped   = new FlipType[] { FlipType.None, FlipType.None },
                    Type      = DirectionType.TwoWayHorizontal,
                    Prefix    = string.Empty
                };
                DirectionalAnimation die = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "die_right", "die_left" },
                    Flipped   = new FlipType[] { FlipType.None, FlipType.None },
                    Type      = DirectionType.TwoWayHorizontal,
                    Prefix    = string.Empty
                };
                //Because Dodge Roll is Dodge Roll and there is no animation types for attack and death, we have to assign them to the Other category.
                enemy.aiAnimator.AssignDirectionalAnimation("attack", attack, AnimationType.Other);
                enemy.aiAnimator.AssignDirectionalAnimation("die", die, AnimationType.Other);
                //This is where we get into the meat and potatoes of our enemy. This is where all the behaviors of our enemy are made.
                //This shootpoint block of code determines where our bullets will orginate from. In this case, the center of the enemy.
                shootpoint = new GameObject("Waterbuloncenter");
                shootpoint.transform.parent   = enemy.transform;
                shootpoint.transform.position = enemy.sprite.WorldCenter;
                GameObject position = enemy.transform.Find("Waterbuloncenter").gameObject;
                //this line adds a BehaviorSpeculator to our enemy which is the base for adding behaviors on to.
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                //Here we will add some basic behaviors such as TargetPlayerBehavior and SeekTargetBehavior.
                //You can change many things in these behaviors so feel free to go nuts.
                BehaviorSpeculator BEHAVIORIAL = EnemyDatabase.GetOrLoadByGuid("0239c0680f9f467dbe5c4aab7dd1eca6").behaviorSpeculator;
                BehaviorSpeculator spec        = enemy.behaviorSpeculator;
                spec.OverrideBehaviors               = BEHAVIORIAL.OverrideBehaviors;
                spec.OtherBehaviors                  = BEHAVIORIAL.OtherBehaviors;
                spec.TargetBehaviors                 = BEHAVIORIAL.TargetBehaviors;
                spec.AttackBehaviors                 = BEHAVIORIAL.AttackBehaviors;
                spec.MovementBehaviors               = BEHAVIORIAL.MovementBehaviors;
                spec.InstantFirstTick                = BEHAVIORIAL.InstantFirstTick;
                spec.TickInterval                    = BEHAVIORIAL.TickInterval;
                spec.PostAwakenDelay                 = BEHAVIORIAL.PostAwakenDelay;
                spec.RemoveDelayOnReinforce          = BEHAVIORIAL.RemoveDelayOnReinforce;
                spec.OverrideStartingFacingDirection = BEHAVIORIAL.OverrideStartingFacingDirection;
                spec.StartingFacingDirection         = BEHAVIORIAL.StartingFacingDirection;
                spec.SkipTimingDifferentiator        = BEHAVIORIAL.SkipTimingDifferentiator;
                //Now this is one of the most important behaviors because it allows our enemy to shoot.
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootBehavior()
                    {
                        ShootPoint = position,
                        //This line selects our Bullet Script
                        BulletScript        = new CustomBulletScriptSelector(typeof(MiltonScript)),
                        LeadAmount          = 0f,
                        AttackCooldown      = 4f,
                        FireAnimation       = "attack",
                        RequiresLineOfSight = true,
                        Uninterruptible     = false,
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = false,
                        CustomRange         = 15f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };
                //Adds the enemy to MTG spawn pool and spawn command
                Game.Enemies.Add("cak:waterbulon", enemy.aiActor);
            }
        }
Beispiel #2
0
        public static void BuildPrefab()
        {
            // source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93");
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("mimekin", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight         = 200;
                companion.aiActor.MovementSpeed                = 2f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow          = false;
                companion.aiActor.IgnoreForRoomClear = false;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(25f);
                companion.aiActor.CollisionKnockbackStrength = 5f;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(25f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 12,
                    ManualHeight           = 26,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 12,
                    ManualHeight           = 26,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle",
                        "idle_two"
                    }
                };
                bool flag3 = RoyalJesterletCollection == null;
                if (flag3)
                {
                    RoyalJesterletCollection = SpriteBuilder.ConstructCollection(prefab, "RoyalJesterlet_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(RoyalJesterletCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], RoyalJesterletCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, RoyalJesterletCollection, new List <int>
                    {
                        2,
                        3
                    }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, RoyalJesterletCollection, new List <int>
                    {
                        0,
                        1
                    }, "idle_two", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;
                }
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;
                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = false,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                shootpoint = new GameObject("f**k");
                shootpoint.transform.parent   = companion.transform;
                shootpoint.transform.position = companion.sprite.WorldCenter;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject;
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootBehavior()
                    {
                        ShootPoint          = m_CachedGunAttachPoint,
                        BulletScript        = new CustomBulletScriptSelector(typeof(TransparentBulletScript)),
                        LeadAmount          = 0f,
                        InitialCooldown     = 3f,
                        AttackCooldown      = 5f,
                        RequiresLineOfSight = false,
                        ChargeTime          = 1f,
                        Uninterruptible     = true
                    },
                };
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cak:mimekin", companion.aiActor);
                SpriteBuilder.AddSpriteToCollection("CakeMod/Resources/mimekin/mime_left_001", SpriteBuilder.ammonomiconCollection);
                if (companion.GetComponent <EncounterTrackable>() != null)
                {
                    UnityEngine.Object.Destroy(companion.GetComponent <EncounterTrackable>());
                }
                companion.encounterTrackable               = companion.gameObject.AddComponent <EncounterTrackable>();
                companion.encounterTrackable.journalData   = new JournalEntry();
                companion.encounterTrackable.EncounterGuid = "cak:mimekin";
                companion.encounterTrackable.prerequisites = new DungeonPrerequisite[0];
                companion.encounterTrackable.journalData.SuppressKnownState    = false;
                companion.encounterTrackable.journalData.IsEnemy               = true;
                companion.encounterTrackable.journalData.SuppressInAmmonomicon = false;
                companion.encounterTrackable.ProxyEncounterGuid              = "";
                companion.encounterTrackable.journalData.AmmonomiconSprite   = "CakeMod/Resources/mimekin/mime_left_001";
                companion.encounterTrackable.journalData.enemyPortraitSprite = ItemAPI.ResourceExtractor.GetTextureFromResource("CakeMod\\Resources\\mimepic.png");
                ItemsMod.Strings.Enemies.Set("#THE_MIME", "Mime Kin");
                ItemsMod.Strings.Enemies.Set("#THE_MIME_SHORTDESC", "Invisible Man");
                ItemsMod.Strings.Enemies.Set("#THE_MIME_LONGDESC", "Masters of mimicking and mimery, these clever bullets use their connection to a silent force to enchant bullets with a fraction of their power.");
                companion.encounterTrackable.journalData.PrimaryDisplayName           = "#THE_MIME";
                companion.encounterTrackable.journalData.NotificationPanelDescription = "#THE_MIME_SHORTDESC";
                companion.encounterTrackable.journalData.AmmonomiconFullEntry         = "#THE_MIME_LONGDESC";
                EnemyBuilder.AddEnemyToDatabase(companion.gameObject, "cak:mimekin");
                EnemyDatabase.GetEntry("cak:mimekin").ForcedPositionInAmmonomicon = 32;
                EnemyDatabase.GetEntry("cak:mimekin").isInBossTab   = false;
                EnemyDatabase.GetEntry("cak:mimekin").isNormalEnemy = true;
            }
        }
Beispiel #3
0
        public static void BuildPrefab()
        {
            //
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("Flame_Clone", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true);
                companion.aiActor.EffectResistances = new ActorEffectResistance[] { new ActorEffectResistance()
                                                                                    {
                                                                                        resistAmount = 1, resistType = EffectResistanceType.Fire
                                                                                    }, };
                companion.aiActor.knockbackDoer.weight = 800;
                companion.aiActor.MovementSpeed        = 5f;
                companion.aiActor.name = "Killinder Clone";
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage                  = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = false;
                companion.aiActor.CollisionKnockbackStrength       = 5f;
                companion.aiActor.healthHaver.SetHealthMaximum(15f, null, false);
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle"
                    }
                };

                bool flag3 = OphaimCollection == null;
                if (flag3)
                {
                    OphaimCollection = SpriteBuilder.ConstructCollection(prefab, "Inflamed_Eye_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(OphaimCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], OphaimCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, OphaimCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3
                    }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;
                }
                var     bs     = prefab.GetComponent <BehaviorSpeculator>();
                float[] angles = { 135, 45, 125, 45 };
                prefab.GetComponent <ObjectVisibilityManager>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;
                bs.OverrideBehaviors          = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors             = behaviorSpeculator.OtherBehaviors;
                shootpoint                    = new GameObject("f**k");
                shootpoint.transform.parent   = companion.transform;
                shootpoint.transform.position = companion.sprite.WorldCenter;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject;
                bs.TargetBehaviors = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = true,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f,
                    }
                };
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootBehavior()
                    {
                        ShootPoint          = m_CachedGunAttachPoint,
                        BulletScript        = new CustomBulletScriptSelector(typeof(FlameShooter)),
                        LeadAmount          = 0f,
                        AttackCooldown      = 3f,
                        RequiresLineOfSight = false,
                        Uninterruptible     = true
                    }
                };
                companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").CorpseObject;
                bs.InstantFirstTick            = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cak:flame_clone", companion.aiActor);
            }
        }
Beispiel #4
0
        public static void BuildPrefab()
        {
            //
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                //float AttackAnimationThingAMaWhatIts = 0.5f;
                prefab = EnemyBuilder.BuildPrefab("ammomimic_cakaaaa", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight         = 100;
                companion.aiActor.MovementSpeed                = 2.5f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 50f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = true;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(20f);
                companion.aiActor.CollisionKnockbackStrength = 1f;
                companion.aiActor.procedurallyOutlined       = false;
                companion.aiActor.CanTargetPlayers           = false;
                companion.aiActor.healthHaver.SetHealthMaximum(20f, null, false);
                companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true);
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider


                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 13,
                    ManualHeight           = 13,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 13,
                    ManualHeight           = 13,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.PlayerCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 13,
                    ManualHeight           = 13,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.PlayerBlocker,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 13,
                    ManualHeight           = 13,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;

                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "die",
                        anim = new DirectionalAnimation
                        {
                            Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                            Flipped   = new DirectionalAnimation.FlipType[2],
                            AnimNames = new string[]
                            {
                                "die_left",
                                "die_right"
                            }
                        }
                    }
                };
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle_left",
                        "idle_right"
                    }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "run_left",
                        "run_right"
                    }
                };
                bool flag3 = ammomimicCollection == null;
                if (flag3)
                {
                    ammomimicCollection = SpriteBuilder.ConstructCollection(prefab, "ammomimic_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(ammomimicCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], ammomimicCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, ammomimicCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                    }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, ammomimicCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                    }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, ammomimicCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                    }, "run_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, ammomimicCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                    }, "run_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, ammomimicCollection, new List <int>
                    {
                        0
                    }, "die_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, ammomimicCollection, new List <int>
                    {
                        0
                    }, "die_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f;

                    //companion.aiActor.gameObject.AddComponent<ColliderComponent>();
                    var bs = prefab.GetComponent <BehaviorSpeculator>();
                    prefab.GetComponent <ObjectVisibilityManager>();
                    BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("9b4fb8a2a60a457f90dcf285d34143ac").behaviorSpeculator;
                    bs.OverrideBehaviors          = behaviorSpeculator.OverrideBehaviors;
                    bs.OtherBehaviors             = behaviorSpeculator.OtherBehaviors;
                    shootpoint                    = new GameObject("ammosh");
                    shootpoint.transform.parent   = companion.transform;
                    shootpoint.transform.position = companion.sprite.WorldCenter;
                    GameObject m_CachedGunAttachPoint = companion.transform.Find("ammosh").gameObject;
                    bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                    bs.TickInterval                    = behaviorSpeculator.TickInterval;
                    bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                    bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                    bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                    bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                    bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                    Game.Enemies.Add("cak:ammomimic", companion.aiActor);
                    ItemsMod.Strings.Enemies.Set("#AMMOMIMIC", "Ammomimic");
                    companion.aiActor.OverrideDisplayName = "#AMMOMIMIC";
                    companion.aiActor.ActorName           = "#AMMOMIMIC";
                    companion.aiActor.name = "#AMMOMIMIC";
                }
            }
        }
Beispiel #5
0
        public static void BuildPrefab()
        {
            //
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                //float AttackAnimationThingAMaWhatIts = 0.5f;
                prefab = EnemyBuilder.BuildPrefab("ink_book", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight         = 100;
                companion.aiActor.MovementSpeed                = 2.5f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = true;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(20f);
                companion.aiActor.CollisionKnockbackStrength = 0f;
                companion.aiActor.procedurallyOutlined       = false;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(20f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true);
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider


                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 13,
                    ManualHeight           = 13,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 13,
                    ManualHeight           = 13,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });

                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;

                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "die",
                        anim = new DirectionalAnimation
                        {
                            Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                            Flipped   = new DirectionalAnimation.FlipType[2],
                            AnimNames = new string[]
                            {
                                "die_left",
                                "die_right"
                            }
                        }
                    }
                };
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle_left",
                        "idle_right"
                    }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "run_left",
                        "run_right"
                    }
                };
                bool flag3 = InkedBook == null;
                if (flag3)
                {
                    InkedBook = SpriteBuilder.ConstructCollection(prefab, "InkBooklet_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(InkedBook);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], InkedBook);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, InkedBook, new List <int>
                    {
                        0,
                        1
                    }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, InkedBook, new List <int>
                    {
                        0,
                        1
                    }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, InkedBook, new List <int>
                    {
                        0,
                        1
                    }, "run_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, InkedBook, new List <int>
                    {
                        0,
                        1
                    }, "run_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, InkedBook, new List <int>
                    {
                        2,
                        3,
                        4,
                        5,
                        6
                    }, "die_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, InkedBook, new List <int>
                    {
                        2,
                        3,
                        4,
                        5,
                        6
                    }, "die_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f;

                    //companion.aiActor.gameObject.AddComponent<ColliderComponent>();
                    var bs = prefab.GetComponent <BehaviorSpeculator>();
                    prefab.GetComponent <ObjectVisibilityManager>();
                    BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").behaviorSpeculator;
                    bs.OverrideBehaviors          = behaviorSpeculator.OverrideBehaviors;
                    bs.OtherBehaviors             = behaviorSpeculator.OtherBehaviors;
                    shootpoint                    = new GameObject("beepskysmash");
                    shootpoint.transform.parent   = companion.transform;
                    shootpoint.transform.position = companion.sprite.WorldCenter;
                    GameObject m_CachedGunAttachPoint = companion.transform.Find("beepskysmash").gameObject;
                    bs.TargetBehaviors = new List <TargetBehaviorBase>
                    {
                        new TargetPlayerBehavior
                        {
                            Radius              = 35f,
                            LineOfSight         = true,
                            ObjectPermanence    = true,
                            SearchInterval      = 0.25f,
                            PauseOnTargetSwitch = false,
                            PauseTime           = 0.25f,
                        }
                    };
                    bs.AttackBehaviors = new List <AttackBehaviorBase>()
                    {
                        new ShootBehavior()
                        {
                            ShootPoint          = m_CachedGunAttachPoint,
                            BulletScript        = new CustomBulletScriptSelector(typeof(SkellScript)),
                            LeadAmount          = 0f,
                            AttackCooldown      = 5f,
                            InitialCooldown     = 1f,
                            RequiresLineOfSight = true,
                            StopDuring          = ShootBehavior.StopType.Attack,
                            Uninterruptible     = true,
                        }
                    };
                    bs.MovementBehaviors = new List <MovementBehaviorBase>
                    {
                        new SeekTargetBehavior
                        {
                            StopWhenInRange     = true,
                            CustomRange         = 7f,
                            LineOfSight         = false,
                            ReturnToSpawn       = false,
                            SpawnTetherDistance = 0f,
                            PathInterval        = 0.5f,
                            SpecifyRange        = false,
                            MinActiveRange      = 0f,
                            MaxActiveRange      = 0f
                        }
                    };

                    bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                    bs.TickInterval                    = behaviorSpeculator.TickInterval;
                    bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                    bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                    bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                    bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                    bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                    Game.Enemies.Add("cak:ink_booklet", companion.aiActor);
                    ItemsMod.Strings.Enemies.Set("#INKBOOK", "Ink Booklet");
                    companion.aiActor.OverrideDisplayName = "#INKBOOK";
                    companion.aiActor.ActorName           = "#INKBOOK";
                    companion.aiActor.name = "#INKBOOK";
                }
            }
        }
Beispiel #6
0
        public static void BuildPrefab()
        {
            if (prefab == null || !EnemyBuilder.Dictionary.ContainsKey(guid))
            {
                //Sets up the prefab of the enemy. The spritepath, "CakeMod/Resources/DemonGuy/Idle/milton_idle_001", determines the setup sprite for your enemy. vvvv This bool right here determines whether or not an enemy has an AiShooter or not. AIShooters are necessary if you want your enemy to hold a gun for example. An example of this can be seen in here.
                prefab = EnemyBuilder.BuildPrefab("DemonGuy", guid, "CakeMod/Resources/DemonGuy/Idle/bullet_demon_idle_001", new IntVector2(0, 0), new IntVector2(0, 0), true);
                //This line extends a BraveBehavior called EnemyBehavior, this is a generic behavior I use for setting up things that can't be setup in BuildPrefab.
                var enemy = prefab.AddComponent <EnemyBehavior>();
                //Here you can setup various things like movement speed, weight, and health. There's a lot you can do with the AiActor parameter so feel free to experiment.
                //For DemonGuy let's make him a flying enemy
                enemy.aiActor.MovementSpeed        = 2f;
                enemy.aiActor.knockbackDoer.weight = 100;
                enemy.aiActor.IgnoreForRoomClear   = false;
                enemy.aiActor.CollisionDamage      = 1f;
                enemy.aiActor.healthHaver.ForceSetCurrentHealth(30f);
                enemy.aiActor.healthHaver.SetHealthMaximum(45f, null, false);
                //This is where you setup your animations. Most animations need specific frame names to be recognized like idle or die.
                //The AddAnimation lines gets sprites from the folder specified in second phrase of the this line. At the very least you need an animation that contains the word idle for the idle animations for example.
                //AnimationType determines what kind of animation your making. In Gungeon there are 7 different Animation Types: Move, Idle, Fidget, Flight, Hit, Talk, Other. For a majority of these animations, these play automatically, however specific animations need to be told when to play such as Attack.
                //DirectionType determines the amount of ways an animation can face. You'll have to change your animation names to correspond with the DirectionType. For example if you want an animation to face eight ways you'll have to name your animations something like ""attack_south_west", "attack_north_east",  "attack_east", "attack_south_east",  "attack_north",  "attack_south", "attack_west", "attack_north_west" and change DirectionType to  DirectionType.EightWayOrdinal.
                //I suggest looking at the sprites of base game enemies to determine the names for the different directions.
                prefab.AddAnimation("idle_left", "CakeMod/Resources/DemonGuy/Idle", fps: 5, AnimationType.Idle, DirectionType.FourWay);
                prefab.AddAnimation("idle_right", "CakeMod/Resources/DemonGuy/Idle", fps: 5, AnimationType.Idle, DirectionType.FourWay);
                prefab.AddAnimation("move_front_right", "CakeMod/Resources/DemonGuy/MoveFrontRight", fps: 5, AnimationType.Move, DirectionType.FourWay);
                prefab.AddAnimation("move_back_right", "CakeMod/Resources/DemonGuy/MoveBackRight", fps: 5, AnimationType.Move, DirectionType.FourWay);
                prefab.AddAnimation("move_front_left", "CakeMod/Resources/DemonGuy/MoveFrontLeft", fps: 5, AnimationType.Move, DirectionType.FourWay);
                prefab.AddAnimation("move_back_left", "CakeMod/Resources/DemonGuy/MoveBackLeft", fps: 5, AnimationType.Move, DirectionType.FourWay);
                //Note that the "die"animations are only set to Move because they will be overwritten later.
                //tk2dSpriteAnimationClip.WrapMode.Once determines how an animation plays out. If you don't want it to loop, leave it to Once, otherwise you can change it to Loop or something.
                //Assign animation well, assigns an animation to an animation type. By default this is on, but since we're overwritting this set this to false.
                prefab.AddAnimation("die_left", "CakeMod/Resources/DemonGuy/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_right", "CakeMod/Resources/DemonGuy/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                //Here we create a new DirectionalAnimation for our enemy to pull from.
                //Make sure the AnimNames correspong to the AddAnimation names.
                DirectionalAnimation idle = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "idle_right", "idle_left" },
                    Flipped   = new FlipType[] { FlipType.None, FlipType.None },
                    Type      = DirectionType.TwoWayHorizontal,
                    Prefix    = string.Empty
                };
                DirectionalAnimation die = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "die_right", "die_left" },
                    Flipped   = new FlipType[] { FlipType.None, FlipType.None },
                    Type      = DirectionType.TwoWayHorizontal,
                    Prefix    = string.Empty
                };
                //Because Dodge Roll is Dodge Roll and there is no animation types for death, we have to assign them to the Other category.
                enemy.aiAnimator.AssignDirectionalAnimation("die", die, AnimationType.Other);
                //This is where we get into the meat and potatoes of our enemy. This is where all the behaviors of our enemy are made.

                //this line adds a BehaviorSpeculator to our enemy which is the base for adding behaviors on to.
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                //We're also going to duplicate the bulletbank and aishooter from the Bullet Kin.
                //The "762" represents the the gun id we want our enemy to hold. For a list of all gun ids, look at the items file on this github.
                //For now let's give him the finished gun.
                GameObject m_CachedGunAttachPoint = enemy.transform.Find("GunAttachPoint").gameObject;
                Vector2    offset = new Vector2(1f, -0.50f);
                m_CachedGunAttachPoint.transform.position = enemy.sprite.WorldCenter + offset;
                AIActor SourceEnemy = EnemyDatabase.GetOrLoadByGuid("5f3abc2d561b4b9c9e72b879c6f10c7e5f3abc2d561b4b9c9e72b879c6f10c7e");
                EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, SourceEnemy.aiShooter, SourceEnemy.GetComponent <AIBulletBank>(), 476, enemy.sprite.transform);

                //Here we will add some basic behaviors such as TargetPlayerBehavior and SeekTargetBehavior.
                //You can change many things in these behaviors so feel free to go nuts.
                bs.TargetBehaviors = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = true,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f,
                    }
                };
                //Now this is one of the most important behaviors because it allows our enemy to shoot.
                //If we want our enemy to shoot out of a gun, use ShootGunBehavior
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootGunBehavior()
                    {
                        GroupCooldownVariance = 0.2f,
                        LineOfSight           = false,
                        //With weapon type you can determine if you want your enemy to fire the gun directly or to use a bullet script. Let's use a Bullet Script for now. For the rest of code, let's modify it to be close to the Finished Gun.
                        WeaponType                   = WeaponType.BulletScript,
                        OverrideBulletName           = null,
                        BulletScript                 = new CustomBulletScriptSelector(typeof(DemonGuyScript)),
                        FixTargetDuringAttack        = true,
                        StopDuringAttack             = true,
                        LeadAmount                   = 0,
                        LeadChance                   = 1,
                        RespectReload                = true,
                        MagazineCapacity             = 6,
                        ReloadSpeed                  = 2f,
                        EmptiesClip                  = true,
                        SuppressReloadAnim           = false,
                        TimeBetweenShots             = -1,
                        PreventTargetSwitching       = true,
                        OverrideAnimation            = null,
                        OverrideDirectionalAnimation = null,
                        HideGun                      = false,
                        UseLaserSight                = false,
                        UseGreenLaser                = false,
                        PreFireLaserTime             = -1,
                        AimAtFacingDirectionWhenSafe = false,
                        Cooldown                     = 0.7f,
                        CooldownVariance             = 0,
                        AttackCooldown               = 0,
                        GlobalCooldown               = 0,
                        InitialCooldown              = 0,
                        InitialCooldownVariance      = 0,
                        GroupName                    = null,
                        GroupCooldown                = 0,
                        MinRange                     = 0,
                        Range                      = 16,
                        MinWallDistance            = 0,
                        MaxEnemiesInRoom           = 0,
                        MinHealthThreshold         = 0,
                        MaxHealthThreshold         = 1,
                        HealthThresholds           = new float[0],
                        AccumulateHealthThresholds = true,
                        targetAreaStyle            = null,
                        IsBlackPhantom             = false,
                        resetCooldownOnDamage      = null,
                        RequiresLineOfSight        = true,
                        MaxUsages                  = 0,
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = false,
                        CustomRange         = 15f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };
                //Adds the enemy to MTG spawn pool and spawn command
                Game.Enemies.Add("cak:greeddemon", enemy.aiActor);
            }
        }
Beispiel #7
0
        public static void BuildPrefab()
        {
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("Bullet Dog", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight         = 20;
                companion.aiActor.MovementSpeed                = 10f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = false;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(6f);
                companion.aiActor.CollisionKnockbackStrength = 5f;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(6f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 16,
                    ManualHeight           = 16,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 16,
                    ManualHeight           = 16,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "die",
                        anim = new DirectionalAnimation
                        {
                            Type      = DirectionalAnimation.DirectionType.Single,
                            Flipped   = new DirectionalAnimation.FlipType[1],
                            AnimNames = new string[]
                            {
                                "die",
                            }
                        }
                    }
                };
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle_right",
                        "idle_left"
                    }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.EightWayOrdinal,
                    Flipped   = new DirectionalAnimation.FlipType[8],
                    AnimNames = new string[]
                    {
                        "run_north",
                        "run_north_east",
                        "run_east",
                        "run_south_east",
                        "run_south",
                        "run_south_west",
                        "run_west",
                        "run_north_west"
                    }
                };
                bool flag3 = BulletDogCollection == null;
                if (flag3)
                {
                    BulletDogCollection = SpriteBuilder.ConstructCollection(prefab, "Bullet_Dog_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(BulletDogCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], BulletDogCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                    }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 8f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        5,
                        6,
                        7,
                        8,
                        9,
                    }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 8f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        10,
                        11,
                        12,
                        13,
                        14,
                    }, "run_south_west", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        15,
                        16,
                        17,
                        18,
                        19
                    }, "run_south_east", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                    }, "run_north", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        26,
                        27,
                        28,
                        29,
                        30,
                        31,
                    }, "run_north_west", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        32,
                        33,
                        34,
                        35,
                        36,
                        37
                    }, "run_north_east", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        38,
                        39,
                        40,
                        41,
                        42,
                        43
                    }, "run_west", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        44,
                        45,
                        46,
                        47,
                        48
                    }, "run_east", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        49,
                        50,
                        51,
                        52,
                        53
                    }, "run_south", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BulletDogCollection, new List <int>
                    {
                        54,
                        55,
                        56,
                        57,
                        58,
                        59
                    }, "die", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f;
                }
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;

                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = true,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = false,
                        CustomRange         = 12f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cel:bullet_dog", companion.aiActor);
            }
        }
Beispiel #8
0
        public static void BuildPrefab()
        {
            AIActor source = EnemyDatabase.GetOrLoadByGuid("e21ac9492110493baef6df02a2682a0d");
            bool    flag   = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool    flag2  = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("ChaosBeing", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                ChaosBeing.shootpoint = new GameObject("f**k");
                ChaosBeing.shootpoint.transform.parent         = companion.transform;
                ChaosBeing.shootpoint.transform.position       = companion.sprite.WorldCenter;
                companion.aiActor.knockbackDoer.weight         = 200000;
                companion.aiActor.MovementSpeed               *= 0.25f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = true;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(75f);
                companion.aiActor.CollisionKnockbackStrength = 0f;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(75f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();

                GameObject AttachPoint = companion.transform.Find("f**k").gameObject;

                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider


                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("1a78cfb776f54641b832e92c44021cf2").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;

                prefab.AddAnimation("idle_right", "BunnyMod/Resources/ChaosEnemy/IdleRight/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("idle_left", "BunnyMod/Resources/ChaosEnemy/IdleLeft/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("move_right", "BunnyMod/Resources/ChaosEnemy/MoveRight/", fps: 4, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("move_left", "BunnyMod/Resources/ChaosEnemy/MoveLeft/", fps: 4, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("death_left", "BunnyMod/Resources/ChaosEnemy/DeathLeft/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("death_right", "BunnyMod/Resources/ChaosEnemy/DeathRight/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);

                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("e21ac9492110493baef6df02a2682a0d").behaviorSpeculator;
                BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("e21ac9492110493baef6df02a2682a0d").behaviorSpeculator;
                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 1000f,
                        LineOfSight         = false,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>()
                {
                    new SeekTargetBehavior()
                    {
                        StopWhenInRange     = true,
                        CustomRange         = 6,
                        LineOfSight         = true,
                        ReturnToSpawn       = true,
                        SpawnTetherDistance = 0,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 1,
                        MaxActiveRange      = 10
                    }
                };
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootBehavior()
                    {
                        ShootPoint = AttachPoint,

                        //GroupCooldownVariance = 0.2f,
                        //LineOfSight = false,
                        //WeaponType = WeaponType.BulletScript,
                        //OverrideBulletName = null,
                        BulletScript = new CustomBulletScriptSelector(typeof(ChaosAttck)),
                        //FixTargetDuringAttack = false,
                        //StopDuringAttack = false,
                        LeadAmount = 0.7f,
                        //LeadChance = 0.62f,
                        //RespectReload = true,
                        //MagazineCapacity = 1,
                        //ReloadSpeed = 3,
                        //EmptiesClip = true,
                        //SuppressReloadAnim = false,
                        //TimeBetweenShots = 0.5f,
                        PreventTargetSwitching = false,
                        //OverrideAnimation = null,
                        //OverrideDirectionalAnimation = null,
                        HideGun = true,
                        //UseLaserSight = false,
                        //UseGreenLaser = false,
                        //PreFireLaserTime = -1,
                        //AimAtFacingDirectionWhenSafe = false,
                        Cooldown                = 1f,
                        CooldownVariance        = 0,
                        AttackCooldown          = 0,
                        GlobalCooldown          = 0,
                        InitialCooldown         = 0,
                        InitialCooldownVariance = 0,
                        GroupName               = null,
                        GroupCooldown           = 0,
                        MinRange                = 0,
                        Range                      = 16,
                        MinWallDistance            = 0,
                        MaxEnemiesInRoom           = 0,
                        MinHealthThreshold         = 0,
                        MaxHealthThreshold         = 1,
                        HealthThresholds           = new float[0],
                        AccumulateHealthThresholds = true,
                        targetAreaStyle            = null,
                        IsBlackPhantom             = false,
                        resetCooldownOnDamage      = null,
                        RequiresLineOfSight        = false,
                        MaxUsages                  = 0,
                    }
                };


                //Tools.DebugInformation(load);
                AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("e21ac9492110493baef6df02a2682a0d");
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;

                //GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject;
                //EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent<AIBulletBank>(), ChaosRevolver.ChaosRevolverID, m_CachedGunAttachPoint.transform);
                Game.Enemies.Add("bny:chaos_being", companion.aiActor);
            }
        }
Beispiel #9
0
        public static void BuildPrefab()
        {
            // source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93");
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("Jesterlet", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight         = 200;
                companion.aiActor.MovementSpeed                = 2f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0.05f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(15f);
                companion.aiActor.CollisionKnockbackStrength = 5f;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(15f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 12,
                    ManualHeight           = 26,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 12,
                    ManualHeight           = 26,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle",
                        "idle_two"
                    }
                };
                DirectionalAnimation done3456 = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.Single,
                    Prefix    = "prepare",
                    AnimNames = new string[1],
                    Flipped   = new DirectionalAnimation.FlipType[1]
                };
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "prepare",
                        anim = done3456
                    }
                };
                bool flag3 = JesterletCollection == null;
                if (flag3)
                {
                    JesterletCollection = SpriteBuilder.ConstructCollection(prefab, "Jesterlet_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(JesterletCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], JesterletCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, JesterletCollection, new List <int>
                    {
                        2,
                        3
                    }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, JesterletCollection, new List <int>
                    {
                        0,
                        1
                    }, "idle_two", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, JesterletCollection, new List <int>
                    {
                        4,
                        5,
                        6,
                        7
                    }, "prepare", tk2dSpriteAnimationClip.WrapMode.Once).fps = 4f;
                }
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;
                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = false,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                shootpoint = new GameObject("f**k");
                shootpoint.transform.parent   = companion.transform;
                shootpoint.transform.position = companion.sprite.WorldCenter;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject;
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootBehavior()
                    {
                        ShootPoint          = m_CachedGunAttachPoint,
                        BulletScript        = new CustomBulletScriptSelector(typeof(TeleportScript)),
                        LeadAmount          = 0f,
                        InitialCooldown     = 5f,
                        AttackCooldown      = 10f,
                        RequiresLineOfSight = false,
                        ChargeAnimation     = "prepare",
                        ChargeTime          = 1f,
                        Uninterruptible     = true
                    },
                };
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cak:jestlet", companion.aiActor);
            }
        }
Beispiel #10
0
        public static void BuildPrefab()
        {
            bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);

            bool flag2 = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("Peril Skull", guid, "Items/Enemies/Sprites/Peril_Skull/Idle/peril_skull_idle_001", new IntVector2(0, 0), new IntVector2(0, 0), false);
                var enemy = prefab.AddComponent <EnemyBehavior>();

                enemy.aiActor.knockbackDoer.weight         = 35;
                enemy.aiActor.MovementSpeed                = 5.5f;
                enemy.aiActor.healthHaver.PreventAllDamage = true;
                enemy.aiActor.CollisionDamage              = 1f;
                enemy.aiActor.HasShadow                        = false;
                enemy.aiActor.IgnoreForRoomClear               = true;
                enemy.aiActor.aiAnimator.HitReactChance        = 0f;
                enemy.aiActor.specRigidbody.CollideWithOthers  = true;
                enemy.aiActor.specRigidbody.CollideWithTileMap = false;
                enemy.aiActor.PreventFallingInPitsEver         = true;
                enemy.aiActor.CollisionKnockbackStrength       = 5f;
                enemy.aiActor.CanTargetPlayers                 = true;
                enemy.aiActor.healthHaver.SetHealthMaximum(999f, null, true);
                enemy.aiActor.SetIsFlying(true, "ghost", true, true);

                prefab.AddAnimation("idle", "Items/Enemies/Sprites/Peril_Skull/Idle", fps: 8, AnimationType.Idle, DirectionType.Single);
                prefab.AddAnimation("run", "Items/Enemies/Sprites/Peril_Skull/Run", fps: 8, AnimationType.Idle, DirectionType.Single);
                enemy.aiActor.specRigidbody.PixelColliders.Clear();
                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 22,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 22,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                enemy.aiActor.PreventBlackPhantom = true;
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;

                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 999f,
                        LineOfSight         = false,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = false,
                        CustomRange         = 999f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.25f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cel:peril_skull", enemy.aiActor);
            }
        }
Beispiel #11
0
        public static void BuildPrefab()
        {
            bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);

            bool flag2 = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("Hunter Kin", guid, "Items/Enemies/Sprites/Hunter_Kin/Idle_Front_Right/hunter_kin_idle_front_right_001", new IntVector2(0, 0), new IntVector2(0, 0), true, true);
                var enemy = prefab.AddComponent <EnemyBehavior>();

                enemy.aiActor.knockbackDoer.weight         = 35;
                enemy.aiActor.MovementSpeed                = 4f;
                enemy.aiActor.healthHaver.PreventAllDamage = false;
                enemy.aiActor.CollisionDamage              = 1f;
                enemy.aiActor.HasShadow                        = false;
                enemy.aiActor.IgnoreForRoomClear               = false;
                enemy.aiActor.aiAnimator.HitReactChance        = 0f;
                enemy.aiActor.specRigidbody.CollideWithOthers  = true;
                enemy.aiActor.specRigidbody.CollideWithTileMap = true;
                enemy.aiActor.PreventFallingInPitsEver         = false;
                enemy.aiActor.healthHaver.ForceSetCurrentHealth(25f);
                enemy.aiActor.CollisionKnockbackStrength = 5f;
                enemy.aiActor.CanTargetPlayers           = true;
                enemy.aiActor.healthHaver.SetHealthMaximum(25f, null, false);


                prefab.AddAnimation("idle_back_right", "Items/Enemies/Sprites/Hunter_Kin/Idle_Back_Right", fps: 5, AnimationType.Idle, DirectionType.FourWay);
                prefab.AddAnimation("idle_front_right", "Items/Enemies/Sprites/Hunter_Kin/Idle_Front_Right", fps: 5, AnimationType.Idle, DirectionType.FourWay);
                prefab.AddAnimation("idle_front_left", "Items/Enemies/Sprites/Hunter_Kin/Idle_Front_Left", fps: 5, AnimationType.Idle, DirectionType.FourWay);
                prefab.AddAnimation("idle_back_left", "Items/Enemies/Sprites/Hunter_Kin/Idle_Back_Left", fps: 5, AnimationType.Idle, DirectionType.FourWay);
                //
                prefab.AddAnimation("run_back_right", "Items/Enemies/Sprites/Hunter_Kin/Run_Back_Right", fps: 5, AnimationType.Move, DirectionType.FourWay);
                prefab.AddAnimation("run_front_right", "Items/Enemies/Sprites/Hunter_Kin/Run_Front_Right", fps: 5, AnimationType.Move, DirectionType.FourWay);
                prefab.AddAnimation("run_front_left", "Items/Enemies/Sprites/Hunter_Kin/Run_Front_Left", fps: 5, AnimationType.Move, DirectionType.FourWay);
                prefab.AddAnimation("run_back_left", "Items/Enemies/Sprites/Hunter_Kin/Run_Back_Left", fps: 5, AnimationType.Move, DirectionType.FourWay);
                //
                prefab.AddAnimation("die_north", "Items/Enemies/Sprites/Hunter_Kin/Die_North", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_north_east", "Items/Enemies/Sprites/Hunter_Kin/Die_North_East", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_east", "Items/Enemies/Sprites/Hunter_Kin/Die_East", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_south_east", "Items/Enemies/Sprites/Hunter_Kin/Die_South_East", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_south", "Items/Enemies/Sprites/Hunter_Kin/Die_South", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_south_west", "Items/Enemies/Sprites/Hunter_Kin/Die_South_West", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_west", "Items/Enemies/Sprites/Hunter_Kin/Die_West", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_north_west", "Items/Enemies/Sprites/Hunter_Kin/Die_North_West", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                //
                prefab.AddAnimation("summon", "Items/Enemies/Sprites/Hunter_Kin/Summon", fps: 7, AnimationType.Move, DirectionType.Single, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);

                DirectionalAnimation die = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "die_north", "die_north_east", "die_east", "die_south_east", "die_south", "die_south_west", "die_west", "die_north_west" },
                    Flipped   = new FlipType[] { FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, },
                    Type      = DirectionType.EightWayOrdinal,
                    Prefix    = string.Empty
                };
                DirectionalAnimation summon = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "summon" },
                    Flipped   = new FlipType[] { FlipType.None },
                    Type      = DirectionType.Single,
                    Prefix    = string.Empty
                };

                enemy.aiAnimator.AssignDirectionalAnimation("die", die, AnimationType.Other);
                enemy.aiAnimator.AssignDirectionalAnimation("summon", summon, AnimationType.Other);
                enemy.aiActor.specRigidbody.PixelColliders.Clear();
                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 14,
                    ManualHeight           = 24,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });

                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 14,
                    ManualHeight           = 24,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });

                enemy.aiActor.PreventBlackPhantom = false;

                AIAnimator aiAnimator = enemy.aiAnimator;
                var        yah        = enemy.transform.Find("GunAttachPoint").gameObject;
                yah.transform.position      = enemy.aiActor.transform.position;
                yah.transform.localPosition = new Vector2(0f, .3f);
                AIActor SourceEnemy = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5");
                EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, SourceEnemy.aiShooter, SourceEnemy.GetComponent <AIBulletBank>(), 12, yah.transform);
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;

                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 45f,
                        LineOfSight         = true,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    },
                };

                AIActor Firecracker = EnemyDatabase.GetOrLoadByGuid("5f15093e6f684f4fb09d3e7e697216b4");
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new AttackBehaviorGroup()
                    {
                    }
                };

                bs.AttackBehaviorGroup.AttackBehaviors = new List <AttackBehaviorGroup.AttackGroupItem>()
                {
                    new AttackBehaviorGroup.AttackGroupItem()
                    {
                        Probability = 1.75f,
                        Behavior    = new ShootGunBehavior()
                        {
                            WeaponType              = WeaponType.BulletScript,
                            BulletScript            = new CustomBulletScriptSelector(typeof(HunterKinScript)),
                            LeadAmount              = 0,
                            LeadChance              = 1,
                            AttackCooldown          = 1f,
                            RequiresLineOfSight     = true,
                            FixTargetDuringAttack   = true,
                            StopDuringAttack        = true,
                            RespectReload           = true,
                            MagazineCapacity        = 5,
                            ReloadSpeed             = 1f,
                            EmptiesClip             = true,
                            SuppressReloadAnim      = false,
                            CooldownVariance        = 0,
                            GlobalCooldown          = 0,
                            InitialCooldown         = 0,
                            InitialCooldownVariance = 0,
                            GroupName                  = null,
                            GroupCooldown              = 0,
                            MinRange                   = 0,
                            Range                      = 7,
                            MinWallDistance            = 0,
                            MaxEnemiesInRoom           = -1,
                            MinHealthThreshold         = 0,
                            MaxHealthThreshold         = 1,
                            HealthThresholds           = new float[0],
                            AccumulateHealthThresholds = true,
                            targetAreaStyle            = null,
                            IsBlackPhantom             = false,
                            resetCooldownOnDamage      = null,
                            MaxUsages                  = 0,
                            UseLaserSight              = true,
                            PreFireLaserTime           = .5f,
                        },
                        NickName = "Hunter Kin Shoot Arrow"
                    },
                    new AttackBehaviorGroup.AttackGroupItem()
                    {
                        Probability = 1.5f,
                        Behavior    = new SummonEnemyBehavior()
                        {
                            DefineSpawnRadius    = true,
                            MinSpawnRadius       = 3,
                            MaxSpawnRadius       = 3,
                            MaxRoomOccupancy     = 6,
                            MaxSummonedAtOnce    = 2,
                            MaxToSpawn           = -1,
                            NumToSpawn           = 2,
                            KillSpawnedOnDeath   = false,
                            CrazeAfterMaxSpawned = false,
                            EnemeyGuids          = new List <string>()
                            {
                                BulletDog.guid
                            },
                            SummonTime          = .5f,
                            DisableDrops        = true,
                            StopDuringAnimation = true,
                            SummonAnim          = "Summon",
                            HideGun             = true,
                            Cooldown            = 1f,
                            RequiresLineOfSight = false,
                            selectionType       = SummonEnemyBehavior.SelectionType.Random,
                        },
                        NickName = "Summon dat doggy"
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = true,
                        CustomRange         = 7f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cel:hunter_kin", enemy.aiActor);
            }
        }
Beispiel #12
0
        public static void BuildPrefab()
        {
            //
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5");
                prefab = EnemyBuilder.BuildPrefab("DrawnKin", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), true);
                var companion = prefab.AddComponent <EnemyBehavior>();;
                companion.aiActor.knockbackDoer.weight         = 50;
                companion.aiActor.MovementSpeed                = 2f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = false;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(30f);
                companion.aiActor.CollisionKnockbackStrength = 5f;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true);
                companion.aiActor.healthHaver.SetHealthMaximum(30f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider

                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "die",
                        anim = new DirectionalAnimation
                        {
                            Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                            Flipped   = new DirectionalAnimation.FlipType[2],
                            AnimNames = new string[]
                            {
                                "die_right",
                                "die_left"
                            }
                        }
                    }
                };
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle_front_right",
                        "idle_front_left",
                        "idle_back_right",
                        "idle_back_left"
                    }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.FourWay,
                    Flipped   = new DirectionalAnimation.FlipType[4],
                    AnimNames = new string[]
                    {
                        "run_back_right",
                        "run_front_right",
                        "run_front_left",
                        "run_back_left",
                    }
                };

                bool flag3 = DrawnKinCollection == null;
                if (flag3)
                {
                    DrawnKinCollection = SpriteBuilder.ConstructCollection(prefab, "DrawnKin_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(DrawnKinCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], DrawnKinCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        0,
                        3
                    }, "idle_back_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        1,
                        2
                    }, "idle_back_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        0,
                        3
                    }, "idle_front_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        1,
                        2
                    }, "idle_front_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        10,
                        11,
                        12,
                        13,
                        14,
                        15
                    }, "run_back_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        22,
                        23,
                        24,
                        25,
                        26,
                        27
                    }, "run_back_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        4,
                        5,
                        6,
                        7,
                        8,
                        9
                    }, "run_front_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int>
                    {
                        16,
                        17,
                        18,
                        19,
                        20,
                        21
                    }, "run_front_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f;
                }

                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;

                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = true,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootGunBehavior()
                    {
                        GroupCooldownVariance        = 0.2f,
                        LineOfSight                  = false,
                        WeaponType                   = WeaponType.BulletScript,
                        OverrideBulletName           = null,
                        BulletScript                 = new CustomBulletScriptSelector(typeof(Drawn47Script)),
                        FixTargetDuringAttack        = true,
                        StopDuringAttack             = true,
                        LeadAmount                   = 0,
                        LeadChance                   = 1,
                        RespectReload                = true,
                        MagazineCapacity             = 8,
                        ReloadSpeed                  = 5f,
                        EmptiesClip                  = true,
                        SuppressReloadAnim           = false,
                        TimeBetweenShots             = -1,
                        PreventTargetSwitching       = true,
                        OverrideAnimation            = null,
                        OverrideDirectionalAnimation = null,
                        HideGun                      = false,
                        UseLaserSight                = false,
                        UseGreenLaser                = false,
                        PreFireLaserTime             = -1,
                        AimAtFacingDirectionWhenSafe = false,
                        Cooldown                     = 0.6f,
                        CooldownVariance             = 0,
                        AttackCooldown               = 0,
                        GlobalCooldown               = 0,
                        InitialCooldown              = 0,
                        InitialCooldownVariance      = 0,
                        GroupName                    = null,
                        GroupCooldown                = 0,
                        MinRange                     = 0,
                        Range                      = 16,
                        MinWallDistance            = 0,
                        MaxEnemiesInRoom           = 0,
                        MinHealthThreshold         = 0,
                        MaxHealthThreshold         = 1,
                        HealthThresholds           = new float[0],
                        AccumulateHealthThresholds = true,
                        targetAreaStyle            = null,
                        IsBlackPhantom             = false,
                        resetCooldownOnDamage      = null,
                        RequiresLineOfSight        = true,
                        MaxUsages                  = 0,
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = true,
                        CustomRange         = 7f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };
                //BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("206405acad4d4c33aac6717d184dc8d4").behaviorSpeculator;
                //Tools.DebugInformation(load);
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject;
                EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent <AIBulletBank>(), CakeIDs.Drawn47, m_CachedGunAttachPoint.transform);
                Game.Enemies.Add("cak:drawnkin", companion.aiActor);
                ItemsMod.Strings.Enemies.Set("#DRAWNKIN", "Drawn Kin");
                companion.aiActor.OverrideDisplayName = "#DRAWNKIN";
                companion.aiActor.ActorName           = "#DRAWNKIN";
                companion.aiActor.name = "#DRAWNKIN";
            }
        }
Beispiel #13
0
        public static void BuildPrefab()
        {
            //
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("TestEnemy", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight         = 150;
                companion.aiActor.MovementSpeed                = 4.5f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = false;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(25f);
                companion.aiActor.CollisionKnockbackStrength = 0f;
                companion.aiActor.procedurallyOutlined       = true;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(25f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 19,
                    ManualHeight           = 11,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });

                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 19,
                    ManualHeight           = 11,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "die",
                        anim = new DirectionalAnimation
                        {
                            Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                            Flipped   = new DirectionalAnimation.FlipType[2],
                            AnimNames = new string[]
                            {
                                "die_left",
                                "die_right"
                            }
                        }
                    }
                };
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.FourWay,
                    Flipped   = new DirectionalAnimation.FlipType[4],
                    AnimNames = new string[]
                    {
                        "idle_back_left",
                        "idle_front_right",
                        "idle_front_left",
                        "die",
                    }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.FourWay,
                    Flipped   = new DirectionalAnimation.FlipType[4],
                    AnimNames = new string[]
                    {
                        "run_back_left",
                        "run_front_right",
                        "run_front_left",
                        "run_back_right",
                    }
                };
                bool flag3 = TestEnemyCollection == null;
                if (flag3)
                {
                    TestEnemyCollection = SpriteBuilder.ConstructCollection(prefab, "FodderBoi_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(TestEnemyCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], TestEnemyCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                    }, "idle_back_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 13f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        6,
                        7,
                        8,
                        9,
                        10,
                    }, "die", tk2dSpriteAnimationClip.WrapMode.Once).fps = 6f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                    }, "idle_front_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 13f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                    }, "idle_front_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 13f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                    }, "run_front_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 13f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                    }, "run_front_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 13f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                    }, "run_back_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 13f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                    }, "run_back_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 13f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        6,
                        7,
                        8,
                        9,
                        10,
                    }, "die_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 6f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int>
                    {
                        6,
                        7,
                        8,
                        9,
                        10,
                    }, "die_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 6f;
                }
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                prefab.GetComponent <ObjectVisibilityManager>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;
                bs.OverrideBehaviors          = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors             = behaviorSpeculator.OtherBehaviors;
                shootpoint                    = new GameObject("fuck2");
                shootpoint.transform.parent   = companion.transform;
                shootpoint.transform.position = companion.sprite.WorldCenter;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("fuck2").gameObject;
                bs.TargetBehaviors = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = true,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.2f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.2f,
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>()
                {
                    new SeekTargetBehavior()
                    {
                        StopWhenInRange     = false,
                        CustomRange         = 6,
                        LineOfSight         = true,
                        ReturnToSpawn       = true,
                        SpawnTetherDistance = 0,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = -0.25f,
                        MaxActiveRange      = 0
                    }
                };
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cak:testenemy", companion.aiActor);
                if (companion.GetComponent <EncounterTrackable>() != null)
                {
                    UnityEngine.Object.Destroy(companion.GetComponent <EncounterTrackable>());
                }
                companion.encounterTrackable               = companion.gameObject.AddComponent <EncounterTrackable>();
                companion.encounterTrackable.journalData   = new JournalEntry();
                companion.encounterTrackable.EncounterGuid = "cak:waterbulon";

                companion.encounterTrackable.prerequisites = new DungeonPrerequisite[0];
            }
        }
Beispiel #14
0
        public static void BuildPrefab()
        {
            AIActor source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93");
            bool    flag   = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool    flag2  = flag;

            if (!flag2)
            {
                prefab = EnemyBuilder.BuildPrefab("AbyssShotgunner", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), true);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight         = 200;
                companion.aiActor.MovementSpeed                = 1.8f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0.05f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(55f);
                companion.aiActor.CollisionKnockbackStrength = 5f;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(55f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider

                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;

                prefab.AddAnimation("idle_right", "BunnyMod/Resources/AbyssEnemies/AbyssShotgunner/IdleRight/", fps: 1, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("idle_left", "BunnyMod/Resources/AbyssEnemies/AbyssShotgunner/IdleLeft/", fps: 1, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("move_right", "BunnyMod/Resources/AbyssEnemies/AbyssShotgunner/MoveRight/", fps: 7, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("move_left", "BunnyMod/Resources/AbyssEnemies/AbyssShotgunner/MoveLeft/", fps: 7, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("death_left", "BunnyMod/Resources/AbyssEnemies/AbyssShotgunner/DeathLeft/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("death_right", "BunnyMod/Resources/AbyssEnemies/AbyssShotgunner/DeathRight/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal);

                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("1bd8e49f93614e76b140077ff2e33f2b").behaviorSpeculator;
                BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("1bd8e49f93614e76b140077ff2e33f2b").behaviorSpeculator;
                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = false,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>()
                {
                    new SeekTargetBehavior()
                    {
                        StopWhenInRange     = true,
                        CustomRange         = 6,
                        LineOfSight         = true,
                        ReturnToSpawn       = true,
                        SpawnTetherDistance = 0,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 1,
                        MaxActiveRange      = 10
                    }
                };
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootGunBehavior()
                    {
                        GroupCooldownVariance        = 0.2f,
                        LineOfSight                  = false,
                        WeaponType                   = WeaponType.BulletScript,
                        OverrideBulletName           = null,
                        BulletScript                 = new CustomBulletScriptSelector(typeof(AbyssShottyAttack)),
                        FixTargetDuringAttack        = false,
                        StopDuringAttack             = false,
                        LeadAmount                   = 0,
                        LeadChance                   = 0.62f,
                        RespectReload                = true,
                        MagazineCapacity             = 1,
                        ReloadSpeed                  = 3,
                        EmptiesClip                  = true,
                        SuppressReloadAnim           = false,
                        TimeBetweenShots             = 0.5f,
                        PreventTargetSwitching       = false,
                        OverrideAnimation            = null,
                        OverrideDirectionalAnimation = null,
                        HideGun                      = false,
                        UseLaserSight                = false,
                        UseGreenLaser                = false,
                        PreFireLaserTime             = -1,
                        AimAtFacingDirectionWhenSafe = false,
                        Cooldown                     = 0.2f,
                        CooldownVariance             = 0,
                        AttackCooldown               = 0,
                        GlobalCooldown               = 0,
                        InitialCooldown              = 0,
                        InitialCooldownVariance      = 0,
                        GroupName                    = null,
                        GroupCooldown                = 0,
                        MinRange                     = 0,
                        Range                      = 16,
                        MinWallDistance            = 0,
                        MaxEnemiesInRoom           = 0,
                        MinHealthThreshold         = 0,
                        MaxHealthThreshold         = 1,
                        HealthThresholds           = new float[0],
                        AccumulateHealthThresholds = true,
                        targetAreaStyle            = null,
                        IsBlackPhantom             = false,
                        resetCooldownOnDamage      = null,
                        RequiresLineOfSight        = false,
                        MaxUsages                  = 0
                    }
                };
                //Tools.DebugInformation(load);
                AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("1bd8e49f93614e76b140077ff2e33f2b");
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject;
                EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent <AIBulletBank>(), 93, m_CachedGunAttachPoint.transform);
                Game.Enemies.Add("bny:abyss_shotgunner", companion.aiActor);
            }
        }
Beispiel #15
0
        public static void BuildPrefab()
        {
            //
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                //float AttackAnimationThingAMaWhatIts = 0.5f;
                prefab = EnemyBuilder.BuildPrefab("turret_cak", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                companion.aiActor.knockbackDoer.weight = 10000;

                companion.aiActor.MovementSpeed = 2.5f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage                  = 50f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = true;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = false;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(20f);
                companion.aiActor.CollisionKnockbackStrength = 1f;
                companion.aiActor.procedurallyOutlined       = false;
                companion.aiActor.CanTargetPlayers           = false;
                companion.aiActor.healthHaver.SetHealthMaximum(20f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true);
                companion.aiActor.healthHaver.PreventAllDamage = true;
                companion.aiActor.healthHaver.PreventCooldownGainFromDamage = true;
                companion.aiActor.CollisionDamage = 0f;
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider



                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 19,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 19,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.PlayerCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 19,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("2d4f8b5404614e7d8b235006acde427a").CorpseObject;
                companion.aiActor.PreventBlackPhantom = true;

                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "die",
                        anim = new DirectionalAnimation
                        {
                            Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                            Flipped   = new DirectionalAnimation.FlipType[2],
                            AnimNames = new string[]
                            {
                                "die_left",
                                "die_right"
                            }
                        }
                    }
                };
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle_left",
                        "idle_right"
                    }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "run_left",
                        "run_right"
                    }
                };
                bool flag3 = BatCollection == null;
                if (flag3)
                {
                    BatCollection = SpriteBuilder.ConstructCollection(prefab, "Bat_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(BatCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], BatCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int>
                    {
                        0,
                        0
                    }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int>
                    {
                        0
                    }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int>
                    {
                        0
                    }, "run_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int>
                    {
                        0
                    }, "run_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int>
                    {
                        1
                    }, "die_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int>
                    {
                        1
                    }, "die_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f;

                    //companion.aiActor.gameObject.AddComponent<ColliderComponent>();
                    var bs = prefab.GetComponent <BehaviorSpeculator>();
                    prefab.GetComponent <ObjectVisibilityManager>();
                    BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("9b4fb8a2a60a457f90dcf285d34143ac").behaviorSpeculator;
                    bs.OverrideBehaviors          = behaviorSpeculator.OverrideBehaviors;
                    bs.OtherBehaviors             = behaviorSpeculator.OtherBehaviors;
                    shootpoint                    = new GameObject("turretshoot");
                    shootpoint.transform.parent   = companion.transform;
                    shootpoint.transform.position = companion.sprite.WorldCenter;
                    GameObject m_CachedGunAttachPoint = companion.transform.Find("turretshoot").gameObject;
                    bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                    bs.TickInterval                    = behaviorSpeculator.TickInterval;
                    bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                    bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                    bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                    bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                    bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                    Game.Enemies.Add("cak:turret", companion.aiActor);
                    ItemsMod.Strings.Enemies.Set("#TURRET", "Turret");
                    companion.aiActor.OverrideDisplayName = "#TURRET";
                    companion.aiActor.ActorName           = "#TURRET";
                    companion.aiActor.name = "#TURRET";

                    bs.AttackBehaviors = new List <AttackBehaviorBase>()
                    {
                        new ShootBehavior()
                        {
                            ShootPoint          = m_CachedGunAttachPoint,
                            BulletScript        = new CustomBulletScriptSelector(typeof(SkellScript)),
                            LeadAmount          = 0f,
                            AttackCooldown      = 5f,
                            InitialCooldown     = 1f,
                            RequiresLineOfSight = true,
                            StopDuring          = ShootBehavior.StopType.Attack,
                            Uninterruptible     = true,
                        }
                    };
                }
            }
        }