예제 #1
0
        public static GameObject GetClosestCustomShrineObject()
        {
            Tools.Log("a");
            var player = GameManager.Instance.PrimaryPlayer;

            Tools.Log("b");

            var shrines = GameObject.FindObjectsOfType <ShrineFactory.CustomShrineController>();

            Tools.Log("c");
            float dist = float.MaxValue, d;

            ShrineFactory.CustomShrineController closest = null;
            foreach (var shrine in shrines)
            {
                Tools.Log("d");
                try
                {
                    d = Vector2.Distance(shrine.sprite.WorldCenter, player.sprite.WorldCenter);
                    if (shrine && d < dist)
                    {
                        closest = shrine;
                        dist    = d;
                    }
                }
                catch { }
            }
            Tools.Log("e");
            Tools.Log(closest);
            return(closest.gameObject);
        }
예제 #2
0
 // Token: 0x06000320 RID: 800 RVA: 0x00022888 File Offset: 0x00020A88
 public void Copy(ShrineFactory.CustomShrineController other)
 {
     this.ID             = other.ID;
     this.roomStyles     = other.roomStyles;
     this.isBreachShrine = other.isBreachShrine;
     this.offset         = other.offset;
     this.pixelColliders = other.pixelColliders;
     this.factory        = other.factory;
     this.OnAccept       = other.OnAccept;
     this.OnDecline      = other.OnDecline;
     this.CanUse         = other.CanUse;
     this.text           = other.text;
     this.acceptText     = other.acceptText;
     this.declineText    = other.declineText;
 }
예제 #3
0
        // Token: 0x06000048 RID: 72 RVA: 0x0000418C File Offset: 0x0000238C
        public static int GetStyleValue(string dungeonName, string shrineID)
        {
            bool flag = ShrineFactory.registeredShrines != null && ShrineFactory.registeredShrines.ContainsKey(shrineID);

            if (flag)
            {
                GameObject gameObject = ShrineFactory.registeredShrines[shrineID];
                ShrineFactory.CustomShrineController customShrineController = (gameObject != null) ? gameObject.GetComponent <ShrineFactory.CustomShrineController>() : null;
                bool flag2 = customShrineController != null && customShrineController.roomStyles != null && customShrineController.roomStyles.ContainsKey(dungeonName);
                if (flag2)
                {
                    return(customShrineController.roomStyles[dungeonName]);
                }
            }
            return(-1);
        }
예제 #4
0
 // Token: 0x0600009C RID: 156 RVA: 0x000084D0 File Offset: 0x000066D0
 public static void PlaceBreachShrines()
 {
     ShrineFactory.CleanupBreachShrines();
     foreach (GameObject gameObject in ShrineFactory.registeredShrines.Values)
     {
         try
         {
             ShrineFactory.CustomShrineController component = gameObject.GetComponent <ShrineFactory.CustomShrineController>();
             bool flag  = !component.isBreachShrine;
             bool flag2 = !flag;
             bool flag3 = flag2;
             if (flag3)
             {
                 ShrineFactory.CustomShrineController component2 = UnityEngine.Object.Instantiate <GameObject>(gameObject).GetComponent <ShrineFactory.CustomShrineController>();
                 component2.Copy(component);
                 component2.gameObject.SetActive(true);
                 component2.sprite.PlaceAtPositionByAnchor(component2.offset, tk2dBaseSprite.Anchor.LowerCenter);
                 SpriteOutlineManager.AddOutlineToSprite(component2.sprite, Color.black);
                 IPlayerInteractable component3 = component2.GetComponent <IPlayerInteractable>();
                 bool flag4 = component3 is SimpleInteractable;
                 bool flag5 = flag4;
                 bool flag6 = flag5;
                 if (flag6)
                 {
                     ((SimpleInteractable)component3).OnAccept  = component2.OnAccept;
                     ((SimpleInteractable)component3).OnDecline = component2.OnDecline;
                     ((SimpleInteractable)component3).CanUse    = component2.CanUse;
                 }
                 bool flag7 = !RoomHandler.unassignedInteractableObjects.Contains(component3);
                 bool flag8 = flag7;
                 bool flag9 = flag8;
                 if (flag9)
                 {
                     RoomHandler.unassignedInteractableObjects.Add(component3);
                 }
             }
         }
         catch (Exception e)
         {
             Tools.PrintException(e, "FF0000");
         }
     }
 }
예제 #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);
        }