Ejemplo n.º 1
0
        ///maybe add some value proofing here (name != null, collider != IntVector2.Zero)
        public GameObject Build()
        {
            try
            {
                //Get texture and create sprite
                Texture2D tex    = ResourceExtractor.GetTextureFromResource(spritePath);
                var       shrine = GungeonAPI.SpriteBuilder.SpriteFromResource(spritePath, null, false);

                //Add (hopefully) unique ID to shrine for tracking
                string ID = $"{modID}:{name}".ToLower().Replace(" ", "_");
                shrine.name = ID;

                //Position sprite
                var shrineSprite = shrine.GetComponent <tk2dSprite>();
                shrineSprite.IsPerpendicular = true;
                shrineSprite.PlaceAtPositionByAnchor(offset, tk2dBaseSprite.Anchor.LowerCenter);

                //Add speech bubble origin
                var talkPoint = new GameObject("talkpoint").transform;
                talkPoint.position = shrine.transform.position + talkPointOffset;
                talkPoint.SetParent(shrine.transform);

                //Set up collider
                if (!usesCustomColliderOffsetAndSize)
                {
                    IntVector2 spriteDimensions = new IntVector2(tex.width, tex.height);
                    colliderOffset = new IntVector2(0, 0);
                    colliderSize   = new IntVector2(spriteDimensions.x, spriteDimensions.y / 2);
                }
                var body = ItemAPI.SpriteBuilder.SetUpSpeculativeRigidbody(shrineSprite, colliderOffset, colliderSize);

                //if (!string.IsNullOrEmpty(shadowSpritePath))
                //{
                //    var shadow = ((GameObject)UnityEngine.Object.Instantiate(ResourceCache.Acquire("DefaultShadowSprite"))).GetComponent<tk2dSprite>();
                //    var shadowSprite = ItemAPI.SpriteBuilder.SpriteFromResource(shadowSpritePath, null, false).GetComponent<tk2dSprite>();
                //    Tools.Print($"Shadow material: {shadow.renderer.material.name}");
                //    Tools.Print($"\tShadow color: {shadow.color}");
                //    Tools.Print($"\tShadow material: {shadowSprite.renderer.material.name}");
                //    Tools.Print($"\tShadow color: {shadowSprite.color}");
                //    Tools.ExportTexture(shadow.renderer.material.mainTexture.GetReadable());
                //    //Tools.ExportTexture(shadowSprite.renderer.material.mainTexture.GetReadable());

                //    shrineSprite.AttachRenderer(shadow);
                //    shadow.PlaceAtPositionByAnchor(shrineSprite.WorldBottomCenter, tk2dBaseSprite.Anchor.UpperCenter);
                //    //shadow.color = new Color(1, 1, 1, .5f);
                //    //shadow.HeightOffGround = -0.1f;
                //    //shadow.renderer.material = defaultSprite.renderer.material;
                //    DepthLookupManager.ProcessRenderer(shadow.GetComponent<Renderer>(), DepthLookupManager.GungeonSortingLayer.BACKGROUND);

                //    //Tools.LogPropertiesAndFields(defaultSprite);

                //}

                var data = shrine.AddComponent <CustomShrineController>();
                data.ID             = ID;
                data.roomStyles     = roomStyles;
                data.isBreachShrine = true;
                data.offset         = offset;
                data.pixelColliders = body.specRigidbody.PixelColliders;
                data.factory        = this;
                data.OnAccept       = OnAccept;
                data.OnDecline      = OnDecline;
                data.CanUse         = CanUse;
                data.text           = text;
                data.acceptText     = acceptText;
                data.declineText    = declineText;

                if (interactableComponent == null)
                {
                    var simpInt = shrine.AddComponent <SimpleShrine>();
                    simpInt.isToggle    = this.isToggle;
                    simpInt.OnAccept    = this.OnAccept;
                    simpInt.OnDecline   = this.OnDecline;
                    simpInt.CanUse      = CanUse;
                    simpInt.text        = this.text;
                    simpInt.acceptText  = this.acceptText;
                    simpInt.declineText = this.declineText;
                    simpInt.talkPoint   = talkPoint;
                }
                else
                {
                    shrine.AddComponent(interactableComponent);
                }


                shrine.name = ID;
                if (!isBreachShrine)
                {
                    if (!room)
                    {
                        room = RoomFactory.CreateEmptyRoom();
                    }
                    RegisterShrineRoom(shrine, room, ID, offset);
                }
                registeredShrines.Add(ID, shrine);
                FakePrefab.MarkAsFakePrefab(shrine);
                Tools.Print("Added shrine: " + ID);
                return(shrine);
            }
            catch (Exception e)
            {
                Tools.PrintException(e);
                return(null);
            }
        }
Ejemplo n.º 2
0
        // Token: 0x06000101 RID: 257 RVA: 0x00009BD9 File Offset: 0x00007DD9
        private IEnumerator HandleConversation(PlayerController interactor)
        {
            SpriteOutlineManager.AddOutlineToSprite(base.sprite, Color.black);
            base.spriteAnimator.PlayForDuration("talk_start", 1f, "talk", false);
            interactor.SetInputOverride("npcConversation");
            Pixelator.Instance.LerpToLetterbox(0.35f, 0.25f);
            yield return(null);

            int num;

            for (int conversationIndex = this.m_allowMeToIntroduceMyself ? 0 : (this.conversation.Count - 1); conversationIndex < this.conversation.Count - 1; conversationIndex = num + 1)
            {
                Tools.Print <string>(string.Format("Index: {0}", conversationIndex), "FFFFFF", false);
                TextBoxManager.ClearTextBox(this.talkPoint);
                TextBoxManager.ShowTextBox(this.talkPoint.position, this.talkPoint, -1f, this.conversation[conversationIndex], interactor.characterAudioSpeechTag, false, TextBoxManager.BoxSlideOrientation.NO_ADJUSTMENT, true, false);
                float timer = 0f;
                while (!BraveInput.GetInstanceForPlayer(interactor.PlayerIDX).ActiveActions.GetActionFromType(GungeonActions.GungeonActionType.Interact).WasPressed || timer < 0.4f)
                {
                    timer += BraveTime.DeltaTime;
                    yield return(null);
                }
                num = conversationIndex;
            }
            this.m_allowMeToIntroduceMyself = false;
            TextBoxManager.ShowTextBox(this.talkPoint.position, this.talkPoint, -1f, this.conversation[this.conversation.Count - 1], interactor.characterAudioSpeechTag, false, TextBoxManager.BoxSlideOrientation.NO_ADJUSTMENT, true, false);
            GameUIRoot.Instance.DisplayPlayerConversationOptions(interactor, null, this.acceptText, this.declineText);
            int selectedResponse = -1;

            while (!GameUIRoot.Instance.GetPlayerConversationResponse(out selectedResponse))
            {
                yield return(null);
            }
            bool flag  = selectedResponse == 0;
            bool flag2 = flag;

            if (flag2)
            {
                TextBoxManager.ClearTextBox(this.talkPoint);
                base.spriteAnimator.PlayForDuration("do_effect", -1f, "talk", false);
                Action <PlayerController, GameObject> onAccept = this.OnAccept;
                bool flag3 = onAccept != null;
                if (flag3)
                {
                    onAccept(interactor, base.gameObject);
                }
                base.spriteAnimator.Play("talk");
                TextBoxManager.ShowTextBox(this.talkPoint.position, this.talkPoint, 1f, "The deal is on, kid!", interactor.characterAudioSpeechTag, false, TextBoxManager.BoxSlideOrientation.NO_ADJUSTMENT, false, false);
                yield return(new WaitForSeconds(1f));

                onAccept = null;
            }
            else
            {
                Action <PlayerController, GameObject> onDecline = this.OnDecline;
                if (onDecline != null)
                {
                    onDecline(interactor, base.gameObject);
                }
                TextBoxManager.ClearTextBox(this.talkPoint);
            }
            interactor.ClearInputOverride("npcConversation");
            Pixelator.Instance.LerpToLetterbox(1f, 0.25f);
            base.spriteAnimator.Play("idle");
            yield break;
        }
Ejemplo n.º 3
0
        // Token: 0x06000059 RID: 89 RVA: 0x00004DEC File Offset: 0x00002FEC
        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(" ", "_");
                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;
                if (flag)
                {
                    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 flag2 = this.interactableComponent == null;
                if (flag2)
                {
                    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 flag3 = !this.isBreachShrine;
                if (flag3)
                {
                    bool flag4 = !this.room;
                    if (flag4)
                    {
                        this.room = RoomFactory.CreateEmptyRoom(12, 12);
                    }
                    ShrineFactory.RegisterShrineRoom(gameObject, this.room, text, this.offset);
                }
                ShrineFactory.registeredShrines.Add(text, gameObject);
                FakePrefab.MarkAsFakePrefab(gameObject);
                Tools.Print <string>("Added shrine: " + text, "FFFFFF", false);
                result = gameObject;
            }
            catch (Exception e)
            {
                Tools.PrintException(e, "FF0000");
                result = null;
            }
            return(result);
        }
Ejemplo n.º 4
0
 public static void OnLevelLoad()
 {
     Tools.Print("-Post Gen Called-", "5599FF");
     OnPostDungeonGeneration?.Invoke();
 }
Ejemplo n.º 5
0
 private static void LogHitboxInfo(PixelCollider collider)
 {
     Tools.Print($"Dimensions: ({collider.Dimensions.x},{collider.Dimensions.y})");
     Tools.Print($"Offset: ({collider.Offset.x},{collider.Offset.y})");
 }
Ejemplo n.º 6
0
 // Token: 0x0600001B RID: 27 RVA: 0x00003740 File Offset: 0x00001940
 private static void LogHitboxInfo(PixelCollider collider)
 {
     Tools.Print <string>(string.Format("Dimensions: ({0},{1})", collider.Dimensions.x, collider.Dimensions.y), "FFFFFF", false);
     Tools.Print <string>(string.Format("Offset: ({0},{1})", collider.Offset.x, collider.Offset.y), "FFFFFF", false);
 }
Ejemplo n.º 7
0
        ///maybe add some value proofing here (name != null, collider != IntVector2.Zero)
        public GameObject Build()
        {
            try
            {
                //Get texture and create sprite
                Texture2D tex    = ResourceExtractor.GetTextureFromResource(spritePath);
                var       shrine = SpecialItemPack.ItemAPI.SpriteBuilder.SpriteFromResource(spritePath, null, false);

                //Add (hopefully) unique ID to shrine for tracking
                string ID = $"{modID}:{name}".ToLower().Replace(" ", "_");
                shrine.name = ID;

                //Position sprite
                var sprite = shrine.GetComponent <tk2dSprite>();
                sprite.IsPerpendicular = true;
                sprite.PlaceAtPositionByAnchor(offset, tk2dBaseSprite.Anchor.LowerCenter);

                //Add speech bubble origin
                var talkPoint = new GameObject("talkpoint").transform;
                talkPoint.position = shrine.transform.position + talkPointOffset;
                talkPoint.SetParent(shrine.transform);

                //Set up collider
                if (!usesCustomColliderOffsetAndSize)
                {
                    IntVector2 spriteDimensions = new IntVector2(tex.width, tex.height);
                    colliderOffset = new IntVector2(0, 0);
                    colliderSize   = new IntVector2(spriteDimensions.x, spriteDimensions.y / 2);
                }
                var body = ItemAPI.SpriteBuilder.SetUpSpeculativeRigidbody(sprite, colliderOffset, colliderSize);

                var data = shrine.AddComponent <CustomShrineController>();
                data.ID             = ID;
                data.roomStyles     = roomStyles;
                data.isBreachShrine = true;
                data.offset         = offset;
                data.pixelColliders = body.specRigidbody.PixelColliders;
                data.factory        = this;
                data.OnAccept       = OnAccept;
                data.OnDecline      = OnDecline;
                data.CanUse         = CanUse;

                IPlayerInteractable interactable;
                //Register as interactable
                if (interactableComponent != null)
                {
                    interactable = shrine.AddComponent(interactableComponent) as IPlayerInteractable;
                }
                else
                {
                    var simpInt = shrine.AddComponent <SimpleInteractable>();
                    simpInt.isToggle    = this.isToggle;
                    simpInt.OnAccept    = this.OnAccept;
                    simpInt.OnDecline   = this.OnDecline;
                    simpInt.CanUse      = CanUse;
                    simpInt.text        = this.text;
                    simpInt.acceptText  = this.acceptText;
                    simpInt.declineText = this.declineText;
                    simpInt.talkPoint   = talkPoint;
                    interactable        = simpInt as IPlayerInteractable;
                }


                var prefab = FakePrefab.Clone(shrine);
                prefab.GetComponent <CustomShrineController>().Copy(data);
                prefab.name = ID;
                if (isBreachShrine)
                {
                    if (!RoomHandler.unassignedInteractableObjects.Contains(interactable))
                    {
                        RoomHandler.unassignedInteractableObjects.Add(interactable);
                    }
                }
                else
                {
                    if (!room)
                    {
                        room = RoomFactory.CreateEmptyRoom();
                    }
                    RegisterShrineRoom(prefab, room, ID, offset);
                }


                builtShrines.Add(ID, prefab);
                Tools.Print("Added shrine: " + ID);
                return(shrine);
            }
            catch (Exception e)
            {
                Tools.PrintException(e);
                return(null);
            }
        }
Ejemplo n.º 8
0
        public static void Init()
        {
            AssetBundles = new Dictionary <string, AssetBundle>();
            foreach (var name in assetBundleNames)
            {
                try
                {
                    var bundle = ResourceManager.LoadAssetBundle(name);
                    if (bundle == null)
                    {
                        Tools.PrintError($"Failed to load asset bundle: {name}");
                        continue;
                    }
                    AssetBundles.Add(name, ResourceManager.LoadAssetBundle(name));
                }
                catch (Exception e)
                {
                    Tools.PrintError($"Failed to load asset bundle: {name}");
                    Tools.PrintException(e);
                }
            }

            RoomTables = new Dictionary <string, GenericRoomTable>();
            foreach (var entry in roomTableMap)
            {
                try
                {
                    var table = DungeonDatabase.GetOrLoadByName($"base_{entry.Key}").PatternSettings.flows[0].fallbackRoomTable;
                    RoomTables.Add(entry.Key, table);
                }
                catch (Exception e)
                {
                    Tools.PrintError($"Failed to load room table: {entry.Key}:{entry.Value}");
                    Tools.PrintException(e);
                }
            }

            foreach (var entry in specialRoomTableMap)
            {
                try
                {
                    var table = GetAsset <GenericRoomTable>(entry.Value);
                    RoomTables.Add(entry.Key, table);
                }
                catch (Exception e)
                {
                    Tools.PrintError($"Failed to load special room table: {entry.Key}:{entry.Value}");
                    Tools.PrintException(e);
                }
            }

            //================================ Adss Boss Rooms into RoomTables
            foreach (var entry in BossRoomGrabage)
            {
                try
                {
                    var table = GetAsset <GenericRoomTable>(entry.Value);
                    RoomTables.Add(entry.Key, table);
                }
                catch (Exception e)
                {
                    Tools.PrintError($"Failed to load special room table: {entry.Key}:{entry.Value}");
                    Tools.PrintException(e);
                }
            }
            //================================ Adss Mini Boss Rooms into RoomTables
            foreach (var entry in MiniBossRoomPools)
            {
                try
                {
                    var table = GetAsset <GenericRoomTable>(entry.Value);
                    RoomTables.Add(entry.Key, table);
                }
                catch (Exception e)
                {
                    Tools.PrintError($"Failed to load special room table: {entry.Key}:{entry.Value}");
                    Tools.PrintException(e);
                }
            }

            subShopTable = AssetBundles["shared_auto_001"].LoadAsset <SharedInjectionData>("_global injected subshop table");
            //foreach(var data in subShopTable.InjectionData)
            //{
            //    Tools.LogPropertiesAndFields(data, data.annotation);
            //}

            Tools.Print("Static references initialized.");
        }
Ejemplo n.º 9
0
        public static void Register(RoomData roomData)
        {
            var room  = roomData.room;
            var wRoom = new WeightedRoom()
            {
                room = room,
                additionalPrerequisites = new DungeonPrerequisite[0],
                weight = roomData.weight == 0 ? GlobalRoomWeight : roomData.weight
            };

            bool success = false;

            switch (room.category)
            {
            case RoomCategory.SPECIAL:
                switch (room.subCategorySpecial)
                {
                case RoomSpecialSubCategory.STANDARD_SHOP:          //shops
                    StaticReferences.RoomTables["shop"].includedRooms.Add(wRoom);
                    Tools.Print($"Registering {roomData.room.name} with weight {wRoom.weight} as {roomData.category}:{roomData.specialSubCategory}");
                    success = true;
                    break;

                case RoomSpecialSubCategory.WEIRD_SHOP:            //subshops
                    StaticReferences.subShopTable.InjectionData.AddRange(GetFlowModifier(roomData));
                    Tools.Print($"Registering {roomData.room.name} with weight {wRoom.weight} as {roomData.category}:{roomData.specialSubCategory}");
                    success = true;
                    break;

                default:
                    StaticReferences.RoomTables["special"].includedRooms.Add(wRoom);
                    Tools.Print($"Registering {roomData.room.name} with weight {wRoom.weight} as {roomData.category}:{roomData.specialSubCategory}");
                    success = true;
                    break;
                }
                break;

            case RoomCategory.SECRET:
                StaticReferences.RoomTables["secret"].includedRooms.Add(wRoom);
                success = true;
                break;

            case RoomCategory.BOSS:
                // TODO
                break;

            default:
                foreach (var p in room.prerequisites)
                {
                    if (p.requireTileset)
                    {
                        StaticReferences.GetRoomTable(p.requiredTileset).includedRooms.Add(wRoom);
                    }
                }
                success = true;
                break;
            }

            RemoveTilesetPrereqs(room);

            if (success)
            {
                Tools.Print($"Registering {roomData.room.name} with weight {wRoom.weight} as {roomData.category}");
            }
        }