Exemplo n.º 1
0
        public static AIActor SetupAIActorDummy(string name, IntVector2 colliderOffset, IntVector2 colliderDimensions)
        {
            GameObject obj = new GameObject(name);

            obj.SetActive(false);
            FakePrefab.MarkAsFakePrefab(obj);
            UnityEngine.Object.DontDestroyOnLoad(obj);
            tk2dSprite           sprite        = obj.AddComponent <tk2dSprite>();
            SpeculativeRigidbody body          = sprite.SetUpSpeculativeRigidbody(colliderOffset, colliderDimensions);
            PixelCollider        pixelCollider = new PixelCollider();

            pixelCollider.ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual;
            pixelCollider.CollisionLayer         = CollisionLayer.EnemyCollider;
            pixelCollider.ManualWidth            = colliderDimensions.x;
            pixelCollider.ManualHeight           = colliderDimensions.y;
            pixelCollider.ManualOffsetX          = colliderOffset.x;
            pixelCollider.ManualOffsetY          = colliderOffset.y;
            body.PixelColliders.Add(pixelCollider);
            body.PrimaryPixelCollider.CollisionLayer = CollisionLayer.EnemyCollider;
            AIActor     aiactor = obj.AddComponent <AIActor>();
            HealthHaver hh      = obj.AddComponent <HealthHaver>();

            hh.SetHealthMaximum(10f);
            hh.ForceSetCurrentHealth(10f);
            BehaviorSpeculator spec = obj.AddComponent <BehaviorSpeculator>();

            ((ISerializedObject)spec).SerializedObjectReferences = new List <UnityEngine.Object>(0);
            ((ISerializedObject)spec).SerializedStateKeys        = new List <string> {
                "OverrideBehaviors", "OtherBehaviors", "TargetBehaviors", "AttackBehaviors", "MovementBehaviors"
            };
            ((ISerializedObject)spec).SerializedStateValues = new List <string> {
                "", "", "", "", ""
            };
            return(aiactor);
        }
Exemplo n.º 2
0
        // Token: 0x060000BF RID: 191 RVA: 0x000087B8 File Offset: 0x000069B8
        public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize)
        {
            bool       flag = CompanionBuilder.companionDictionary.ContainsKey(guid);
            GameObject result;

            if (flag)
            {
                ETGModConsole.Log("CompanionBuilder: Tried to create two companion prefabs with the same GUID!", false);
                result = null;
            }
            else
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(CompanionBuilder.behaviorSpeculatorPrefab);
                gameObject.name = name;
                tk2dSprite component = SpriteBuilder.SpriteFromResource(defaultSpritePath, gameObject, false).GetComponent <tk2dSprite>();
                component.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = false;
                gameObject.AddComponent <tk2dSpriteAnimator>();
                gameObject.AddComponent <AIAnimator>();
                HealthHaver healthHaver = gameObject.AddComponent <HealthHaver>();
                healthHaver.RegisterBodySprite(component, false, 0);
                healthHaver.PreventAllDamage = true;
                healthHaver.SetHealthMaximum(15000f, null, false);
                healthHaver.FullHeal();
                AIActor aiactor = gameObject.AddComponent <AIActor>();
                aiactor.State     = AIActor.ActorState.Normal;
                aiactor.EnemyGuid = guid;
                BehaviorSpeculator component2 = gameObject.GetComponent <BehaviorSpeculator>();
                component2.MovementBehaviors = new List <MovementBehaviorBase>();
                component2.AttackBehaviors   = new List <AttackBehaviorBase>();
                component2.TargetBehaviors   = new List <TargetBehaviorBase>();
                component2.OverrideBehaviors = new List <OverrideBehaviorBase>();
                component2.OtherBehaviors    = new List <BehaviorBase>();
                EnemyDatabaseEntry item = new EnemyDatabaseEntry
                {
                    myGuid          = guid,
                    placeableWidth  = 2,
                    placeableHeight = 2,
                    isNormalEnemy   = false
                };
                EnemyDatabase.Instance.Entries.Add(item);
                CompanionBuilder.companionDictionary.Add(guid, gameObject);
                UnityEngine.Object.DontDestroyOnLoad(gameObject);
                FakePrefab.MarkAsFakePrefab(gameObject);
                gameObject.SetActive(false);
                result = gameObject;
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a custom chest.
        /// </summary>
        /// <param name="idleSprite">The pathway to the idle sprite. Setup like how you would do an item. Do not put an idle inside of the spritePaths list!</param>
        /// <param name="gameObjectName">The name of the chest's game object</param>
        /// <param name="hitboxOffset">The offset of the hitbox. Idk what this does but you can tinker with it if you need to.</param>
        /// <param name="hitboxDimensions">Start at the size of the chest's idle dimensions and tinker with the values until they feel right</param>
        /// <param name="spritePaths">A list of the chest's sprite paths.</param>
        /// <param name="lootTableIdsAndWeights">Uses a custom class I made called ItemAndWeight that allows me to have a list with mutliple types per item in it. Just make a list of ItemAndWeights like this: new ItemAndWeight {itemID = "the gun/passive/active's id", itemWeight = "x" (Best left at 1), itemCanHaveDupes = false/true (idk what this really means but I would add it.)}; </param>
        /// <param name="sTierChance">The chance to get an S tier item from the chest's loot pool.</param>
        /// <param name="aTierChance">The chance to get an A tier item from the chest's loot pool.</param>
        /// <param name="bTierChance">The chance to get a B tier item from the chest's loot pool.</param>
        /// <param name="cTierChance">The chance to get a C tier item from the chest's loot pool.</param>
        /// <param name="dTierChance">The chance to get a D tier item from the chest's loot pool.</param>
        /// <param name="isLocked">If the chest is locked.</param>
        /// <param name="type">If the chest is a Passive/Active chest, a Gun chest, or unspecified.</param>
        /// <param name="potentialPrefab">If you are using a RealPrefab, put it here. If you don't know what this means or aren't using one, leave this null.</param>
        public static Chest CreateChest(string idleSprite, string gameObjectName, IntVector2 hitboxOffset, IntVector2 hitboxDimensions, List <string> spritePaths, List <ItemAndWeight> lootTableIdsAndWeights, float sTierChance, float aTierChance, float bTierChance, float cTierChance, float dTierChance, ChestType type = ChestType.Unspecified, bool isLocked = true, GameObject potentialPrefab = null)
        {
            try
            {
                GameObject obj = SpriteBuilder.SpriteFromResource(idleSprite, potentialPrefab == null ? new GameObject(gameObjectName) : potentialPrefab);
                obj.SetActive(false);
                FakePrefab.MarkAsFakePrefab(obj);
                UnityEngine.Object.DontDestroyOnLoad(obj);
                tk2dSprite           sprite = obj.GetComponent <tk2dSprite>();
                SpeculativeRigidbody body   = sprite.SetUpSpeculativeRigidbody(hitboxOffset, hitboxDimensions);
                body.PrimaryPixelCollider.CollisionLayer = CollisionLayer.HighObstacle;
                tk2dSpriteAnimator animator = obj.AddComponent <tk2dSpriteAnimator>();
                animator.Library         = animator.gameObject.AddComponent <tk2dSpriteAnimation>();
                animator.Library.clips   = new tk2dSpriteAnimationClip[0];
                animator.Library.enabled = true;
                List <int> appearIds  = new List <int>();
                List <int> breakIds   = new List <int>();
                List <int> openIds    = new List <int>();
                string     zeroHpName = "";
                foreach (string text in spritePaths)
                {
                    if (text.Contains("appear"))
                    {
                        appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                    else if (text.Contains("break"))
                    {
                        if (text.EndsWith("001"))
                        {
                            int id = SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection);
                            zeroHpName = obj.GetComponent <tk2dBaseSprite>().Collection.inst.spriteDefinitions[id].name;
                        }
                        else
                        {
                            breakIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                        }
                    }
                    else if (text.Contains("open"))
                    {
                        openIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                    else
                    {
                        appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                }
                appearIds.Add(sprite.spriteId);
                tk2dSpriteAnimationClip openClip = new tk2dSpriteAnimationClip {
                    name = "open", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in openIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    openClip.frames = openClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                openClip.wrapMode      = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { openClip }).ToArray();
                tk2dSpriteAnimationClip appearClip = new tk2dSpriteAnimationClip {
                    name = "appear", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in appearIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    appearClip.frames = appearClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                appearClip.wrapMode    = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { appearClip }).ToArray();
                tk2dSpriteAnimationClip breakClip = new tk2dSpriteAnimationClip {
                    name = "break", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in breakIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    breakClip.frames = breakClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                breakClip.wrapMode     = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { breakClip }).ToArray();
                Chest chestController = obj.AddComponent <Chest>();
                chestController.spawnCurve = new AnimationCurve
                {
                    keys = new Keyframe[] { new Keyframe {
                                                time = 0f, value = 0f, inTangent = 3.562501f, outTangent = 3.562501f
                                            }, new Keyframe {
                                                time       = 1f, value = 1.0125f, inTangent = 0.09380959f,
                                                outTangent = 0.09380959f
                                            } }
                };

                GenericLootTable Table;
                Table = UnityEngine.Object.Instantiate <GenericLootTable>(GameManager.Instance.RewardManager.ItemsLootTable);
                Table.defaultItemDrops          = new WeightedGameObjectCollection();
                Table.defaultItemDrops.elements = new List <WeightedGameObject>();
                foreach (ItemAndWeight itemAndWeight in lootTableIdsAndWeights)
                {
                    Table.defaultItemDrops.elements.Add(new WeightedGameObject()
                    {
                        pickupId = itemAndWeight.itemID,
                        weight   = itemAndWeight.itemWeight,
                        forceDuplicatesPossible = itemAndWeight.itemCanHaveDupes,
                        additionalPrerequisites = new DungeonPrerequisite[0]
                    });
                }
                chestController.openAnimName   = "open";
                chestController.spawnAnimName  = "appear";
                chestController.majorBreakable = obj.AddComponent <MajorBreakable>();
                chestController.majorBreakable.spriteNameToUseAtZeroHP         = zeroHpName;
                chestController.majorBreakable.usesTemporaryZeroHitPointsState = true;
                chestController.breakAnimName = "break";
                chestController.VFX_GroundHit = new GameObject("example thingy");
                chestController.VFX_GroundHit.transform.parent = chestController.transform;
                chestController.VFX_GroundHit.SetActive(false);
                chestController.groundHitDelay      = 5f;
                chestController.overrideMimicChance = 0f;
                chestController.lootTable           = new LootData();
                chestController.lootTable.lootTable = Table;
                chestController.lootTable.S_Chance  = sTierChance;
                chestController.lootTable.A_Chance  = aTierChance;
                chestController.lootTable.B_Chance  = bTierChance;
                chestController.lootTable.C_Chance  = cTierChance;
                chestController.lootTable.D_Chance  = dTierChance;
                switch (type)
                {
                case ChestType.Unspecified:
                    chestController.ChestType = Chest.GeneralChestType.UNSPECIFIED;
                    break;

                case ChestType.PassiveActive:
                    chestController.ChestType = Chest.GeneralChestType.ITEM;
                    break;

                case ChestType.Gun:
                    chestController.ChestType = Chest.GeneralChestType.WEAPON;
                    break;
                }
                chestController.IsLocked = isLocked;
                return(chestController);
            }
            catch (Exception e)
            {
                ETGModConsole.Log("Something BROKE when making a chestController! Error is: " + e.ToString());
                return(null);
            }
        }
        // Token: 0x06000017 RID: 23 RVA: 0x00003680 File Offset: 0x00001880
        public GameObject Build()
        {
            GameObject result;

            try
            {
                Texture2D  textureFromResource = ResourceExtractor.GetTextureFromResource(this.spritePath);
                GameObject gameObject          = SpriteBuilder.SpriteFromResource(this.spritePath, null);
                string     text = (this.modID + ":" + this.name).ToLower().Replace(" ", "_");
                //string roomPath = this.roomPath;
                gameObject.name = text;
                tk2dSprite component = gameObject.GetComponent <tk2dSprite>();
                component.IsPerpendicular = true;
                component.PlaceAtPositionByAnchor(this.offset, tk2dBaseSprite.Anchor.LowerCenter);
                Transform transform = new GameObject("talkpoint").transform;
                transform.position = gameObject.transform.position + this.talkPointOffset;
                transform.SetParent(gameObject.transform);
                bool flag  = !this.usesCustomColliderOffsetAndSize;
                bool flag2 = flag;
                if (flag2)
                {
                    IntVector2 intVector = new IntVector2(textureFromResource.width, textureFromResource.height);
                    this.colliderOffset = new IntVector2(0, 0);
                    this.colliderSize   = new IntVector2(intVector.x, intVector.y / 2);
                }
                SpeculativeRigidbody speculativeRigidbody = component.SetUpSpeculativeRigidbody(this.colliderOffset, this.colliderSize);

                speculativeRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.PlayerBlocker,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = this.colliderOffset.x,
                    ManualOffsetY          = this.colliderOffset.y,
                    ManualWidth            = this.colliderSize.x,
                    ManualHeight           = this.colliderSize.y,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                speculativeRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyBlocker,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = this.colliderOffset.x,
                    ManualOffsetY          = this.colliderOffset.y,
                    ManualWidth            = this.colliderSize.x,
                    ManualHeight           = this.colliderSize.y,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                speculativeRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.BulletBlocker,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = this.colliderOffset.x,
                    ManualOffsetY          = this.colliderOffset.y,
                    ManualWidth            = this.colliderSize.x,
                    ManualHeight           = this.colliderSize.y,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                speculativeRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyBulletBlocker,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = this.colliderOffset.x,
                    ManualOffsetY          = this.colliderOffset.y,
                    ManualWidth            = this.colliderSize.x,
                    ManualHeight           = this.colliderSize.y,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                speculativeRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.BeamBlocker,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = this.colliderOffset.x,
                    ManualOffsetY          = this.colliderOffset.y,
                    ManualWidth            = this.colliderSize.x,
                    ManualHeight           = this.colliderSize.y,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });

                OldShrineFactory.CustomShrineController customShrineController = gameObject.AddComponent <OldShrineFactory.CustomShrineController>();
                customShrineController.ID             = text;
                customShrineController.roomStyles     = this.roomStyles;
                customShrineController.isBreachShrine = true;
                customShrineController.offset         = this.offset;
                customShrineController.pixelColliders = speculativeRigidbody.specRigidbody.PixelColliders;
                customShrineController.factory        = this;
                customShrineController.OnAccept       = this.OnAccept;
                customShrineController.OnDecline      = this.OnDecline;
                customShrineController.CanUse         = this.CanUse;
                bool flag3 = this.interactableComponent != null;
                bool flag4 = flag3;
                IPlayerInteractable item;
                if (flag4)
                {
                    item = (gameObject.AddComponent(this.interactableComponent) as IPlayerInteractable);
                }
                else
                {
                    SimpleShrine simpleShrine = gameObject.AddComponent <SimpleShrine>();
                    simpleShrine.isToggle    = this.isToggle;
                    simpleShrine.OnAccept    = this.OnAccept;
                    simpleShrine.OnDecline   = this.OnDecline;
                    simpleShrine.CanUse      = this.CanUse;
                    simpleShrine.text        = this.text;
                    simpleShrine.acceptText  = this.acceptText;
                    simpleShrine.declineText = this.declineText;
                    simpleShrine.talkPoint   = transform;
                    item = simpleShrine;
                }
                GameObject gameObject2 = ShrineFakePrefab.Clone(gameObject);
                gameObject2.GetComponent <OldShrineFactory.CustomShrineController>().Copy(customShrineController);
                gameObject2.name = text;
                bool flag5 = this.isBreachShrine;
                bool flag6 = flag5;
                if (flag6)
                {
                    bool flag7 = !RoomHandler.unassignedInteractableObjects.Contains(item);
                    bool flag8 = flag7;
                    if (flag8)
                    {
                        RoomHandler.unassignedInteractableObjects.Add(item);
                    }
                }
                else
                {
                    bool flag9  = !this.room;
                    bool flag10 = flag9;
                    if (flag10)
                    {
                        this.room = RoomFactory.CreateEmptyRoom(12, 12);
                    }
                    OldShrineFactory.RegisterShrineRoom(gameObject2, this.room, text, this.offset, this.RoomWeight);
                }
                OldShrineFactory.builtShrines.Add(text, gameObject2);
                result = gameObject;
            }
            catch (Exception e)
            {
                Tools.PrintException(e, "FF0000");
                result = null;
            }
            return(result);
        }
Exemplo n.º 5
0
        // Token: 0x0600009A RID: 154 RVA: 0x00008084 File Offset: 0x00006284
        public GameObject Build()
        {
            GameObject result;

            try
            {
                Texture2D  textureFromResource = ResourceExtractor.GetTextureFromResource(this.spritePath);
                GameObject gameObject          = SpriteBuilder.SpriteFromResource(this.spritePath, null);
                string     text = (this.modID + ":" + this.name).ToLower().Replace(" ", "_");
                gameObject.name = text;
                tk2dSprite component = gameObject.GetComponent <tk2dSprite>();
                component.IsPerpendicular = true;
                component.PlaceAtPositionByAnchor(this.offset, tk2dBaseSprite.Anchor.LowerCenter);
                Transform transform = new GameObject("talkpoint").transform;
                transform.position = gameObject.transform.position + this.talkPointOffset;
                transform.SetParent(gameObject.transform);
                bool flag  = !this.usesCustomColliderOffsetAndSize;
                bool flag2 = flag;
                bool flag3 = flag2;
                if (flag3)
                {
                    IntVector2 intVector = new IntVector2(textureFromResource.width, textureFromResource.height);
                    this.colliderOffset = new IntVector2(0, 0);
                    this.colliderSize   = new IntVector2(intVector.x, intVector.y / 2);
                }
                SpeculativeRigidbody speculativeRigidbody = component.SetUpSpeculativeRigidbody(this.colliderOffset, this.colliderSize);
                ShrineFactory.CustomShrineController customShrineController = gameObject.AddComponent <ShrineFactory.CustomShrineController>();
                customShrineController.ID             = text;
                customShrineController.roomStyles     = this.roomStyles;
                customShrineController.isBreachShrine = true;
                customShrineController.offset         = this.offset;
                customShrineController.pixelColliders = speculativeRigidbody.specRigidbody.PixelColliders;
                customShrineController.factory        = this;
                customShrineController.OnAccept       = this.OnAccept;
                customShrineController.OnDecline      = this.OnDecline;
                customShrineController.CanUse         = this.CanUse;
                customShrineController.text           = this.text;
                customShrineController.acceptText     = this.acceptText;
                customShrineController.declineText    = this.declineText;
                bool flag4 = this.interactableComponent == null;
                bool flag5 = flag4;
                bool flag6 = flag5;
                if (flag6)
                {
                    SimpleShrine simpleShrine = gameObject.AddComponent <SimpleShrine>();
                    simpleShrine.isToggle    = this.isToggle;
                    simpleShrine.OnAccept    = this.OnAccept;
                    simpleShrine.OnDecline   = this.OnDecline;
                    simpleShrine.CanUse      = this.CanUse;
                    simpleShrine.text        = this.text;
                    simpleShrine.acceptText  = this.acceptText;
                    simpleShrine.declineText = this.declineText;
                    simpleShrine.talkPoint   = transform;
                }
                else
                {
                    gameObject.AddComponent(this.interactableComponent);
                }
                gameObject.name = text;
                bool flag7 = !this.isBreachShrine;
                bool flag8 = flag7;
                bool flag9 = flag8;
                if (flag9)
                {
                    bool flag10 = !this.room;
                    bool flag11 = flag10;
                    bool flag12 = flag11;
                    if (flag12)
                    {
                        this.room = RoomFactory.CreateEmptyRoom(12, 12);
                    }
                    ShrineFactory.RegisterShrineRoom(gameObject, this.room, text, this.offset, this.RoomWeight);
                }
                ShrineFactory.registeredShrines.Add(text, gameObject);
                FakePrefab.MarkAsFakePrefab(gameObject);
                result = gameObject;
            }
            catch (Exception e)
            {
                Tools.PrintException(e, "FF0000");
                result = null;
            }
            return(result);
        }
Exemplo n.º 6
0
        public static void Init()
        {
            try
            {
                GameObject obj = SpriteBuilder.SpriteFromResource("Items/Resources/MunitionsChest/munitions_chest_idle_001", new GameObject("MunitionsChest"));
                obj.SetActive(false);
                FakePrefab.MarkAsFakePrefab(obj);
                UnityEngine.Object.DontDestroyOnLoad(obj);
                tk2dSprite           sprite = obj.GetComponent <tk2dSprite>();
                SpeculativeRigidbody body   = sprite.SetUpSpeculativeRigidbody(new IntVector2(0, -8), new IntVector2(25, 25));
                body.PrimaryPixelCollider.CollisionLayer = CollisionLayer.HighObstacle;
                tk2dSpriteAnimator animator = obj.AddComponent <tk2dSpriteAnimator>();
                animator.Library         = animator.gameObject.AddComponent <tk2dSpriteAnimation>();
                animator.Library.clips   = new tk2dSpriteAnimationClip[0];
                animator.Library.enabled = true;
                List <int> appearIds  = new List <int>();
                List <int> breakIds   = new List <int>();
                List <int> openIds    = new List <int>();
                string     zeroHpName = "";
                foreach (string text in MunitionsChestController.spritePaths)
                {
                    if (text.Contains("appear"))
                    {
                        appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                    else if (text.Contains("break"))
                    {
                        if (text.EndsWith("001"))
                        {
                            int id = SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection);
                            zeroHpName = obj.GetComponent <tk2dBaseSprite>().Collection.inst.spriteDefinitions[id].name;
                        }
                        else
                        {
                            breakIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                        }
                    }
                    else if (text.Contains("open"))
                    {
                        openIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                    else
                    {
                        appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                }
                appearIds.Add(sprite.spriteId);
                tk2dSpriteAnimationClip openClip = new tk2dSpriteAnimationClip {
                    name = "open", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in openIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    openClip.frames = openClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                openClip.wrapMode      = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { openClip }).ToArray();
                tk2dSpriteAnimationClip appearClip = new tk2dSpriteAnimationClip {
                    name = "appear", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in appearIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    appearClip.frames = appearClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                appearClip.wrapMode    = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { appearClip }).ToArray();
                tk2dSpriteAnimationClip breakClip = new tk2dSpriteAnimationClip {
                    name = "break", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in breakIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    breakClip.frames = breakClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                breakClip.wrapMode     = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { breakClip }).ToArray();
                Chest chest = obj.AddComponent <Chest>();
                chest.spawnCurve = new AnimationCurve
                {
                    keys = new Keyframe[] { new Keyframe {
                                                time = 0f, value = 0f, inTangent = 3.562501f, outTangent = 3.562501f
                                            }, new Keyframe {
                                                time       = 1f, value = 1.0125f, inTangent = 0.09380959f,
                                                outTangent = 0.09380959f
                                            } }
                };
                List <int> MuniStock = new List <int>
                {
                    //Base Game
                    //----------
                    //Items with "Bullet" in the name
                    579,
                    627,
                    298,
                    640,
                    111,
                    113,
                    172,
                    277,
                    278,
                    284,
                    286,
                    288,
                    323,
                    352,
                    373,
                    374,
                    375,
                    410,
                    521,
                    523,
                    528,
                    530,
                    531,
                    532,
                    533,
                    538,
                    568,
                    569,
                    630,
                    655,
                    661,
                    822,
                    //Items with "Rounds" in the name
                    298,
                    304,
                    527,
                    638,
                    //Misc Item names
                    636,
                    241,
                    204,
                    295,
                    241,
                    524,
                    287,
                    //My Mod
                    //------
                    //Items with "Bullet" in the name
                    ETGMod.Databases.Items["Funky Bullets"].PickupObjectId,
                    ETGMod.Databases.Items["Needle Bullets"].PickupObjectId,
                    ETGMod.Databases.Items["Snare Bullets"].PickupObjectId,
                    ETGMod.Databases.Items["[_____] Bullets"].PickupObjectId,
                    ETGMod.Databases.Items["Floop Bullets"].PickupObjectId,
                    ETGMod.Databases.Items["Elite Bullets"].PickupObjectId,
                    //Items with "Rounds" in the name
                    ETGMod.Databases.Items["Venom Rounds"].PickupObjectId,
                    ETGMod.Databases.Items["Ballistic Rounds"].PickupObjectId,
                    //Misc Item names
                    ETGMod.Databases.Items["Imp's Horn"].PickupObjectId,
                    ETGMod.Databases.Items["Sawblade"].PickupObjectId,
                    ETGMod.Databases.Items["Mininomocon"].PickupObjectId,
                    ETGMod.Databases.Items["Gunlust"].PickupObjectId,
                    ETGMod.Databases.Items["Dragun Skull"].PickupObjectId,
                    ETGMod.Databases.Items["Gravity Well Module"].PickupObjectId,
                    ETGMod.Databases.Items["Primal Nitric Acid"].PickupObjectId,
                };

                GenericLootTable Table;
                Table = UnityEngine.Object.Instantiate <GenericLootTable>(GameManager.Instance.RewardManager.ItemsLootTable);

                Table.defaultItemDrops          = new WeightedGameObjectCollection();
                Table.defaultItemDrops.elements = new List <WeightedGameObject>();
                foreach (int id in MuniStock)
                {
                    Table.defaultItemDrops.elements.Add(new WeightedGameObject()
                    {
                        pickupId = id,
                        weight   = 1,
                        forceDuplicatesPossible = false,
                        additionalPrerequisites = new DungeonPrerequisite[0]
                    });
                }

                //MLoot.Add(Table);

                chest.openAnimName   = "open";
                chest.spawnAnimName  = "appear";
                chest.majorBreakable = obj.AddComponent <MajorBreakable>();
                chest.majorBreakable.spriteNameToUseAtZeroHP         = zeroHpName;
                chest.majorBreakable.usesTemporaryZeroHitPointsState = true;
                chest.breakAnimName = "break";
                chest.VFX_GroundHit = new GameObject("example thingy");
                chest.VFX_GroundHit.transform.parent = chest.transform;
                chest.VFX_GroundHit.SetActive(false);
                chest.groundHitDelay      = 5f;
                chest.ChestType           = GeneralChestType.ITEM;
                chest.overrideMimicChance = 0f;
                chest.lootTable           = new LootData();
                chest.lootTable.lootTable = Table;
                chest.lootTable.S_Chance  = 0.2f;
                chest.lootTable.A_Chance  = 0.2f;
                chest.lootTable.B_Chance  = 0.2f;
                chest.lootTable.C_Chance  = 0.2f;
                chest.lootTable.D_Chance  = 0.2f;
                chest.IsLocked            = true;

                MunitionsChestController.MChest = chest;
            }
            catch (Exception e)
            {
                ETGModConsole.Log("Error in MChest");
                ETGModConsole.Log(e.Message);
                ETGModConsole.Log(e.StackTrace);
            }
        }
Exemplo n.º 7
0
        public static void Init()
        {
            GameObject obj = SpriteBuilder.SpriteFromResource("SpecialItemPack/Resources/UglyChest/chest_ugly_idle_001", new GameObject("UglyRedChest"));

            obj.SetActive(false);
            FakePrefab.MarkAsFakePrefab(obj);
            UnityEngine.Object.DontDestroyOnLoad(obj);
            tk2dSprite           sprite = obj.GetComponent <tk2dSprite>();
            SpeculativeRigidbody body   = sprite.SetUpSpeculativeRigidbody(new IntVector2(0, 0), new IntVector2(12, 12));

            body.PrimaryPixelCollider.CollisionLayer = CollisionLayer.HighObstacle;
            tk2dSpriteAnimator animator = obj.AddComponent <tk2dSpriteAnimator>();

            animator.Library         = animator.gameObject.AddComponent <tk2dSpriteAnimation>();
            animator.Library.clips   = new tk2dSpriteAnimationClip[0];
            animator.Library.enabled = true;
            List <int> appearIds  = new List <int>();
            List <int> breakIds   = new List <int>();
            List <int> openIds    = new List <int>();
            string     zeroHpName = "";

            foreach (string text in UglyChest.spritePaths)
            {
                if (text.Contains("appear"))
                {
                    appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                }
                else if (text.Contains("break"))
                {
                    if (text.EndsWith("001"))
                    {
                        int id = SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection);
                        zeroHpName = obj.GetComponent <tk2dBaseSprite>().Collection.inst.spriteDefinitions[id].name;
                    }
                    else
                    {
                        breakIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                }
                else if (text.Contains("open"))
                {
                    openIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                }
                else
                {
                    appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                }
            }
            appearIds.Add(sprite.spriteId);
            tk2dSpriteAnimationClip openClip = new tk2dSpriteAnimationClip {
                name = "open", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
            };

            foreach (int id in openIds)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                {
                    spriteId         = id,
                    spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                };
                openClip.frames = openClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            openClip.wrapMode      = tk2dSpriteAnimationClip.WrapMode.Once;
            animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { openClip }).ToArray();
            tk2dSpriteAnimationClip appearClip = new tk2dSpriteAnimationClip {
                name = "appear", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
            };

            foreach (int id in appearIds)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                {
                    spriteId         = id,
                    spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                };
                appearClip.frames = appearClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            appearClip.wrapMode    = tk2dSpriteAnimationClip.WrapMode.Once;
            animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { appearClip }).ToArray();
            tk2dSpriteAnimationClip breakClip = new tk2dSpriteAnimationClip {
                name = "break", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
            };

            foreach (int id in breakIds)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                {
                    spriteId         = id,
                    spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                };
                breakClip.frames = breakClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            breakClip.wrapMode     = tk2dSpriteAnimationClip.WrapMode.Once;
            animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { breakClip }).ToArray();
            Chest chest = obj.AddComponent <Chest>();

            chest.spawnCurve = new AnimationCurve {
                keys = new Keyframe[] { new Keyframe {
                                            time = 0f, value = 0f, inTangent = 3.562501f, outTangent = 3.562501f
                                        }, new Keyframe {
                                            time       = 1f, value = 1.0125f, inTangent = 0.09380959f,
                                            outTangent = 0.09380959f
                                        } }
            };
            UglyChest.UglyRedChest = chest;
            chest.openAnimName     = "open";
            chest.spawnAnimName    = "appear";
            chest.majorBreakable   = obj.AddComponent <MajorBreakable>();
            chest.majorBreakable.spriteNameToUseAtZeroHP         = zeroHpName;
            chest.majorBreakable.usesTemporaryZeroHitPointsState = true;
            chest.breakAnimName = "break";
            chest.VFX_GroundHit = new GameObject("example thingy");
            chest.VFX_GroundHit.transform.parent = chest.transform;
            chest.VFX_GroundHit.SetActive(false);
            chest.groundHitDelay = 2f / 10f;
        }