public static void CreateRainbowchestMimicPrefab() { AIActor aiactor = UnityEngine.Object.Instantiate <AIActor>(EnemyDatabase.GetOrLoadByGuid("d8fd592b184b4ac9a3be217bc70912a2")); aiactor.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(aiactor.gameObject); UnityEngine.Object.DontDestroyOnLoad(aiactor); aiactor.healthHaver.bossHealthBar = HealthHaver.BossBarType.MainBar; MeshRenderer component = aiactor.GetComponent <MeshRenderer>(); Material[] sharedMaterials = component.sharedMaterials; Array.Resize <Material>(ref sharedMaterials, sharedMaterials.Length + 1); Material material = UnityEngine.Object.Instantiate <Material>(new Material(ShaderCache.Acquire("Brave/Internal/RainbowChestShader"))); material.SetTexture("_MainTex", sharedMaterials[0].GetTexture("_MainTex")); sharedMaterials[sharedMaterials.Length - 1] = material; component.sharedMaterials = sharedMaterials; aiactor.gameObject.AddComponent <RainbowmimicAwakenBehaviour>(); foreach (AttackBehaviorBase attackBehav in aiactor.behaviorSpeculator.AttackBehaviors) { if (attackBehav is AttackBehaviorGroup) { foreach (AttackBehaviorGroup.AttackGroupItem item in (attackBehav as AttackBehaviorGroup).AttackBehaviors) { if (item != null && item.Behavior != null) { if (item.Behavior is ShootBehavior) { (item.Behavior as ShootBehavior).BulletScript = new Toolbox.CustomBulletScriptSelector(typeof(MimicRainbowMiniguns1)); } } } } } if (aiactor.healthHaver != null) { aiactor.healthHaver.SetHealthMaximum(1000, null, true); } if (aiactor.bulletBank != null) { foreach (AIBulletBank.Entry entry in aiactor.bulletBank.Bullets) { if (entry.Name == "default") { entry.BulletObject = EnemyDatabase.GetOrLoadByGuid("044a9f39712f456597b9762893fbc19c").bulletBank.bulletBank.GetBullet("gross").BulletObject; entry.Name = "gross"; } if (entry.Name == "bigBullet") { entry.BulletObject = EnemyDatabase.GetOrLoadByGuid("044a9f39712f456597b9762893fbc19c").bulletBank.bulletBank.GetBullet("gross").BulletObject; entry.Name = "bigGross"; } } aiactor.bulletBank.Bullets.Add(EnemyDatabase.GetOrLoadByGuid("044a9f39712f456597b9762893fbc19c").bulletBank.bulletBank.GetBullet("default")); } aiactor.ActorName = "Rainbow Chest Mimic"; aiactor.EnemyGuid = "boss_rainbowchest_mimic"; customEnemies.Add(aiactor); SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/BossRainbowmimicIcon", SpriteBuilder.ammonomiconCollection); if (aiactor.GetComponent <EncounterTrackable>() != null) { UnityEngine.Object.Destroy(aiactor.GetComponent <EncounterTrackable>()); } aiactor.encounterTrackable = aiactor.gameObject.AddComponent <EncounterTrackable>(); aiactor.encounterTrackable.journalData = new JournalEntry(); aiactor.encounterTrackable.EncounterGuid = aiactor.EnemyGuid; aiactor.encounterTrackable.prerequisites = new DungeonPrerequisite[0]; aiactor.encounterTrackable.journalData.SuppressKnownState = false; aiactor.encounterTrackable.journalData.IsEnemy = true; aiactor.encounterTrackable.journalData.SuppressInAmmonomicon = false; aiactor.encounterTrackable.ProxyEncounterGuid = ""; aiactor.encounterTrackable.journalData.AmmonomiconSprite = "BossRainbowmimicIcon"; aiactor.encounterTrackable.journalData.enemyPortraitSprite = ResourceExtractor.GetTextureFromResource("SpecialItemPack/Resources/AmmonomiconPortraitRainbowmimic.png"); aiactor.OverrideDisplayName = "#SPECIAL_RAINBOWCHEST_MIMIC"; SpecialItemModule.Strings.Enemies.Set("#SPECIAL_RAINBOWCHEST_MIMIC", "Rainbow Chest Mimic"); SpecialItemModule.Strings.Enemies.Set("#SPECIAL_RAINBOWCHEST_MIMIC_SHORTDESC", "Deadly Surprise"); SpecialItemModule.Strings.Enemies.Set("#SPECIAL_RAINBOWCHEST_MIMIC_LONGDESC", "Evolution gave this mimic ability to change colors. With that ability, it can mimic valuable rainbow chests, that attract foolish gungeoneers so much. " + "Their miniguns are filled with flak shells and they are tougher than other mimics. Truly a terrifying foe to face."); aiactor.encounterTrackable.journalData.PrimaryDisplayName = "#SPECIAL_RAINBOWCHEST_MIMIC"; aiactor.encounterTrackable.journalData.NotificationPanelDescription = "#SPECIAL_RAINBOWCHEST_MIMIC_SHORTDESC"; aiactor.encounterTrackable.journalData.AmmonomiconFullEntry = "#SPECIAL_RAINBOWCHEST_MIMIC_LONGDESC"; AddEnemyToDatabase(aiactor.gameObject, "boss_rainbowchest_mimic", true, true, true); EnemyDatabase.GetEntry("boss_rainbowchest_mimic").ForcedPositionInAmmonomicon = 24; EnemyDatabase.GetEntry("boss_rainbowchest_mimic").isInBossTab = true; }
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; } }
public static void BuildPrefab() { if (!(prefab != null || AdvEnemyBuilder.Dictionary.ContainsKey(guid))) { prefab = AdvEnemyBuilder.BuildPrefab("Test Enemy", guid, spritePaths[0], new IntVector2(14, 5), new IntVector2(5, 5), false); var companion = prefab.AddComponent <EnemyBehavior>(); //Actor Variables companion.aiActor.MovementSpeed = 7f; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = true; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.CanTargetPlayers = true; companion.aiActor.CanTargetEnemies = false; companion.aiActor.PreventFallingInPitsEver = false; companion.aiActor.CollisionKnockbackStrength = 10f; companion.aiActor.procedurallyOutlined = true; companion.aiActor.PreventBlackPhantom = false; //Body Variables companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; //Health Variables companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.healthHaver.SetHealthMaximum(15f, null, false); companion.aiActor.healthHaver.ForceSetCurrentHealth(15f); //Other Variables companion.aiActor.knockbackDoer.weight = 10f; //AnimatorVariables companion.aiAnimator.HitReactChance = 1f; companion.aiAnimator.faceSouthWhenStopped = false; companion.aiAnimator.faceTargetWhenStopped = true; companion.aiActor.SetIsFlying(true, "Flying Entity"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_NAME_SMALL", "Test Enemy"); companion.aiActor.OverrideDisplayName = "#TEST_ENEMY_NAME_SMALL"; companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.gameObject.AddComponent <tk2dSpriteAttachPoint>(); companion.aiActor.gameObject.AddComponent <ObjectVisibilityManager>(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 14, ManualOffsetY = 5, ManualWidth = 5, ManualHeight = 5, 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 = 14, ManualOffsetY = 5, ManualWidth = 5, ManualHeight = 5, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "idle_right", "idle_left", } }; aiAnimator.MoveAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "move_right", "move_left", } }; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { new AIAnimator.NamedDirectionalAnimation { name = "sex", anim = new DirectionalAnimation { Prefix = "sex", Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "sex_right", "sex_left", } } }, }; if (TestEnemyCollection == null) { TestEnemyCollection = SpriteBuilder.ConstructCollection(prefab, "TestEnemyCollection"); 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, }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15 ; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 4, 5, 6, 7, }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15 ; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 8, 9, 10, 11, }, "move_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 12, 13, 14, 15, }, "move_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 16, 17, 18, }, "sex_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 20; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 19, 20, 21, }, "sex_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 20; } var bs = prefab.GetComponent <BehaviorSpeculator>(); prefab.GetComponent <ObjectVisibilityManager>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; //ATTACK BEHAVIOUR SETUP (Must be done BY HAND) shootpoint = new GameObject("f**k"); shootpoint.transform.parent = companion.transform; shootpoint.transform.position = (companion.sprite.WorldCenter + new Vector2(0, 0)); GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject; bs.TargetBehaviors = new List <TargetBehaviorBase> { //Add your target behaviours here! new TargetPlayerBehavior { Radius = 1000, LineOfSight = false, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f, }, }; bs.MovementBehaviors = new List <MovementBehaviorBase>() //Add your movement behaviours here! { new SeekTargetBehavior() { StopWhenInRange = true, CustomRange = 5, LineOfSight = false, ReturnToSpawn = true, SpawnTetherDistance = -1, PathInterval = 0.25f, SpecifyRange = false, MinActiveRange = 0, MaxActiveRange = 0 }, }; bs.AttackBehaviors = new List <AttackBehaviorBase>() { //Attack behaviours must be added here MANUALLY }; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; if (companion.GetComponent <EncounterTrackable>() != null) { UnityEngine.Object.Destroy(companion.GetComponent <EncounterTrackable>()); } Game.Enemies.Add("nn:Test_Enemy".ToLower(), companion.aiActor); SpriteBuilder.AddSpriteToCollection("AmmonomiconSprite", AdvEnemyBuilder.ammonomiconCollection); companion.encounterTrackable = companion.gameObject.AddComponent <EncounterTrackable>(); companion.encounterTrackable.journalData = new JournalEntry(); companion.encounterTrackable.EncounterGuid = "nn:Test Enemy".ToLower(); 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 = "Bingly Bungly Boo"; companion.encounterTrackable.journalData.enemyPortraitSprite = ItemAPI.ResourceExtractor.GetTextureFromResource("Bungle Bish bash bosh"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY", "Test Enemy"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_SHORTDESC", "Quote"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_LONGDESC", "Description"); companion.encounterTrackable.journalData.PrimaryDisplayName = "#TEST_ENEMY"; companion.encounterTrackable.journalData.NotificationPanelDescription = "#TEST_ENEMY_SHORTDESC"; companion.encounterTrackable.journalData.AmmonomiconFullEntry = "#TEST_ENEMY_LONGDESC"; AdvEnemyBuilder.AddEnemyToDatabase(companion.gameObject, "nn:Test_Enemy".ToLower()); EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).ForcedPositionInAmmonomicon = 15; EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).isInBossTab = false; EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).isNormalEnemy = true; } }