Beispiel #1
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);
        }
        private IEnumerator ShowChargeLevel(GameActor gunOwner, int chargeLevel)
        {
            if (extantSprites.Count > 0)
            {
                for (int i = extantSprites.Count - 1; i >= 0; i--)
                {
                    UnityEngine.Object.Destroy(extantSprites[i].gameObject);
                }
                extantSprites.Clear();
            }
            GameObject newSprite = new GameObject("Level Popup", new Type[] { typeof(tk2dSprite) })
            {
                layer = 0
            };

            newSprite.transform.position = (gunOwner.transform.position + new Vector3(0.5f, 2));
            tk2dSprite m_ItemSprite = newSprite.AddComponent <tk2dSprite>();

            extantSprites.Add(newSprite);
            int spriteID = -1;

            switch (chargeLevel)
            {
            case 1:
                spriteID = Meter1ID;
                break;

            case 2:
                spriteID = Meter2ID;
                break;

            case 3:
                spriteID = Meter3ID;
                break;

            case 4:
                spriteID = Meter4ID;
                break;

            case 5:
                spriteID = Meter5ID;
                break;
            }
            m_ItemSprite.SetSprite(PumpChargeShotgun.GunVFXCollection, spriteID);
            m_ItemSprite.PlaceAtPositionByAnchor(newSprite.transform.position, tk2dBaseSprite.Anchor.LowerCenter);
            m_ItemSprite.transform.localPosition = m_ItemSprite.transform.localPosition.Quantize(0.0625f);
            newSprite.transform.parent           = gunOwner.transform;
            if (m_ItemSprite)
            {
                sprite.AttachRenderer(m_ItemSprite);
                m_ItemSprite.depthUsesTrimmedBounds = true;
                m_ItemSprite.UpdateZDepth();
            }
            sprite.UpdateZDepth();
            yield return(new WaitForSeconds(2));

            if (newSprite)
            {
                extantSprites.Remove(newSprite);
                Destroy(newSprite.gameObject);
            }
            yield break;
        }
        // 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, false);
                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);
                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);
        }
        public static void SetupHatSprites(List <string> spritePaths, GameObject hatObj, int fps, Vector2 hatSize)
        {
            Hat hatness = hatObj.GetComponent <Hat>();

            if (hatness)
            {
                string collectionName = hatness.hatName;
                collectionName = collectionName.Replace(" ", "_");
                tk2dSpriteCollectionData HatSpriteCollection = SpriteBuilder.ConstructCollection(hatObj, (collectionName + "_Collection"));

                int        spriteID      = SpriteBuilder.AddSpriteToCollection(spritePaths[0], HatSpriteCollection);
                tk2dSprite hatBaseSprite = hatObj.GetOrAddComponent <tk2dSprite>();
                hatBaseSprite.SetSprite(HatSpriteCollection, spriteID);
                tk2dSpriteDefinition def = hatBaseSprite.GetCurrentSpriteDef();
                def.colliderVertices = new Vector3[] {
                    new Vector3(0f, 0f, 0f),
                    new Vector3((hatSize.x / 16), (hatSize.y / 16), 0f)
                };
                hatBaseSprite.PlaceAtPositionByAnchor(hatObj.transform.position, tk2dBaseSprite.Anchor.LowerCenter);
                hatBaseSprite.depthUsesTrimmedBounds = true;
                hatBaseSprite.IsPerpendicular        = true;
                hatBaseSprite.UpdateZDepth();
                hatBaseSprite.HeightOffGround = 0.2f;

                List <string> SouthAnimation     = new List <string>();
                List <string> NorthAnimation     = new List <string>();
                List <string> EastAnimation      = new List <string>();
                List <string> WestAnimation      = new List <string>();
                List <string> NorthWestAnimation = new List <string>();
                List <string> NorthEastAnimation = new List <string>();
                List <string> SouthEastAnimation = new List <string>();
                List <string> SouthWestAnimation = new List <string>();

                switch (hatness.hatDirectionality)
                {
                case Hat.HatDirectionality.EIGHTWAY:
                    foreach (string path in spritePaths)
                    {
                        if (path.ToLower().Contains("_north_"))
                        {
                            NorthAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_south_"))
                        {
                            SouthAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_west_"))
                        {
                            WestAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_east_"))
                        {
                            EastAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_northwest_"))
                        {
                            NorthWestAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_northeast_"))
                        {
                            NorthEastAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_southwest_"))
                        {
                            SouthWestAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_southeast_"))
                        {
                            SouthEastAnimation.Add(path);
                        }
                    }
                    break;

                case Hat.HatDirectionality.SIXWAY:
                    foreach (string path in spritePaths)
                    {
                        if (path.ToLower().Contains("_north_"))
                        {
                            NorthAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_south_"))
                        {
                            SouthAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_west_"))
                        {
                            WestAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_east_"))
                        {
                            EastAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_northwest_"))
                        {
                            NorthWestAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_northeast_"))
                        {
                            NorthEastAnimation.Add(path);
                        }
                    }
                    break;

                case Hat.HatDirectionality.FOURWAY:
                    foreach (string path in spritePaths)
                    {
                        if (path.ToLower().Contains("_west_"))
                        {
                            WestAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_east_"))
                        {
                            EastAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_north_"))
                        {
                            NorthAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_south_"))
                        {
                            SouthAnimation.Add(path);
                        }
                    }
                    break;

                case Hat.HatDirectionality.TWOWAYHORIZONTAL:
                    foreach (string path in spritePaths)
                    {
                        if (path.ToLower().Contains("_west_"))
                        {
                            WestAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_east_"))
                        {
                            EastAnimation.Add(path);
                        }
                    }
                    break;

                case Hat.HatDirectionality.TWOWAYVERTICAL:
                    foreach (string path in spritePaths)
                    {
                        if (path.ToLower().Contains("_north_"))
                        {
                            NorthAnimation.Add(path);
                        }
                        if (path.ToLower().Contains("_south_"))
                        {
                            SouthAnimation.Add(path);
                        }
                    }
                    break;

                case Hat.HatDirectionality.NONE:
                    foreach (string path in spritePaths)
                    {
                        if (path.ToLower().Contains("_south_"))
                        {
                            SouthAnimation.Add(path);
                        }
                    }
                    break;
                }

                //SET UP THE ANIMATOR AND THE ANIMATION
                tk2dSpriteAnimator  animator  = hatObj.GetOrAddComponent <tk2dSpriteAnimator>();
                tk2dSpriteAnimation animation = hatObj.GetOrAddComponent <tk2dSpriteAnimation>();
                animation.clips  = new tk2dSpriteAnimationClip[0];
                animator.Library = animation;

                //SOUTH ANIMATION
                if (SouthAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_south", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in SouthAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
                //NORTH ANIMATIONS
                if (NorthAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_north", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in NorthAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
                //WEST ANIMATIONS
                if (WestAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_west", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in WestAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
                //EAST ANIMATIONS
                if (EastAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_east", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in EastAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
                //NORTHEAST
                if (NorthEastAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_northeast", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in NorthEastAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
                //NORTHWEST ANIMATION
                if (NorthWestAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_northwest", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in NorthWestAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
                //SOUTHWEST ANIMATION
                if (SouthWestAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_southwest", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in SouthWestAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
                //SOUTHEAST ANIMATION
                if (SouthEastAnimation != null)
                {
                    tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip()
                    {
                        name = "hat_southeast", frames = new tk2dSpriteAnimationFrame[0], fps = fps
                    };

                    List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>();
                    foreach (string path in SouthEastAnimation)
                    {
                        tk2dSpriteCollectionData collection = HatSpriteCollection;
                        int frameSpriteId             = SpriteBuilder.AddSpriteToCollection(path, collection);
                        tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId];
                        frameDef.colliderVertices = def.colliderVertices;
                        frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);
                        frames.Add(new tk2dSpriteAnimationFrame {
                            spriteId = frameSpriteId, spriteCollection = collection
                        });
                    }
                    clip.frames     = frames.ToArray();
                    animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
                }
            }
        }