Beispiel #1
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;
            }
        }