// Token: 0x0600003C RID: 60 RVA: 0x00004560 File Offset: 0x00002760 public static RoomFactory.RoomData BuildFromFile(string roomPath) { Texture2D textureFromFile = ResourceExtractor.GetTextureFromFile(roomPath, ".room"); textureFromFile.name = Path.GetFileName(roomPath); RoomFactory.RoomData roomData = RoomFactory.ExtractRoomDataFromFile(roomPath); roomData.room = RoomFactory.Build(textureFromFile, roomData); return(roomData); }
public static void Init() { if (!initialized) { RoomFactory.LoadRoomsFromRoomDirectory(); DungeonHooks.OnPreDungeonGeneration += OnPreDungeonGen; initialized = true; } }
// Token: 0x06000047 RID: 71 RVA: 0x00004B70 File Offset: 0x00002D70 public static RoomFactory.RoomData CreateEmptyRoomData(int width = 12, int height = 12) { return(new RoomFactory.RoomData { room = RoomFactory.CreateEmptyRoom(width, height), category = "NORMAL", weight = DungeonHandler.GlobalRoomWeight }); }
// Token: 0x0600000E RID: 14 RVA: 0x00002890 File Offset: 0x00000A90 public static void Init() { bool flag = !DungeonHandler.initialized; if (flag) { RoomFactory.LoadRoomsFromRoomDirectory(); DungeonHooks.OnPreDungeonGeneration += DungeonHandler.OnPreDungeonGen; DungeonHandler.initialized = true; } }
// Token: 0x0600004C RID: 76 RVA: 0x00004EDC File Offset: 0x000030DC public static void AddEnemyToRoom(PrototypeDungeonRoom room, Vector2 location, string guid, int layer) { DungeonPrerequisite[] array = new DungeonPrerequisite[0]; DungeonPlaceable dungeonPlaceable = ScriptableObject.CreateInstance <DungeonPlaceable>(); dungeonPlaceable.width = 1; dungeonPlaceable.height = 1; dungeonPlaceable.respectsEncounterableDifferentiator = true; dungeonPlaceable.variantTiers = new List <DungeonPlaceableVariant> { new DungeonPlaceableVariant { percentChance = 1f, prerequisites = array, enemyPlaceableGuid = guid, materialRequirements = new DungeonPlaceableRoomMaterialRequirement[0] } }; PrototypePlacedObjectData prototypePlacedObjectData = new PrototypePlacedObjectData { contentsBasePosition = location, fieldData = new List <PrototypePlacedObjectFieldData>(), instancePrerequisites = array, linkedTriggerAreaIDs = new List <int>(), placeableContents = dungeonPlaceable }; bool flag = layer > 0; bool flag2 = flag; if (flag2) { RoomFactory.AddObjectDataToReinforcementLayer(room, prototypePlacedObjectData, layer - 1, location); } else { room.placedObjects.Add(prototypePlacedObjectData); room.placedObjectPositions.Add(location); } bool flag3 = !room.roomEvents.Contains(RoomFactory.sealOnEnterWithEnemies); bool flag4 = flag3; if (flag4) { room.roomEvents.Add(RoomFactory.sealOnEnterWithEnemies); } bool flag5 = !room.roomEvents.Contains(RoomFactory.unsealOnRoomClear); bool flag6 = flag5; if (flag6) { room.roomEvents.Add(RoomFactory.unsealOnRoomClear); } }
// Token: 0x0600003D RID: 61 RVA: 0x00003B08 File Offset: 0x00001D08 public static PrototypeDungeonRoom Build(Texture2D texture, RoomFactory.RoomData roomData) { try { PrototypeDungeonRoom prototypeDungeonRoom = RoomFactory.CreateRoomFromTexture(texture); RoomFactory.ApplyRoomData(prototypeDungeonRoom, roomData); prototypeDungeonRoom.UpdatePrecalculatedData(); return(prototypeDungeonRoom); } catch (Exception e) { Tools.PrintError <string>("Failed to build room!", "FF0000"); Tools.PrintException(e, "FF0000"); } return(RoomFactory.CreateEmptyRoom(12, 12)); }
// Token: 0x0600003A RID: 58 RVA: 0x00003A08 File Offset: 0x00001C08 public static void LoadRoomsFromRoomDirectory() { Directory.CreateDirectory(RoomFactory.roomDirectory); foreach (string text in Directory.GetFiles(RoomFactory.roomDirectory)) { bool flag = !text.EndsWith(".room"); if (!flag) { string fileName = Path.GetFileName(text); Tools.Log <string>("Found room: \"" + fileName + "\""); RoomFactory.RoomData roomData = RoomFactory.BuildFromFile(text); DungeonHandler.Register(roomData); RoomFactory.rooms.Add(fileName, roomData); } } }
// Token: 0x0600004A RID: 74 RVA: 0x00004D5C File Offset: 0x00002F5C public static void AddPlaceableToRoom(PrototypeDungeonRoom room, Vector2 location, string assetPath) { try { GameObject placeableFromBundles = RoomFactory.GetPlaceableFromBundles(assetPath); bool flag = placeableFromBundles; bool flag2 = flag; if (flag2) { DungeonPrerequisite[] array = new DungeonPrerequisite[0]; room.placedObjectPositions.Add(location); room.placedObjects.Add(new PrototypePlacedObjectData { contentsBasePosition = location, fieldData = new List <PrototypePlacedObjectFieldData>(), instancePrerequisites = array, linkedTriggerAreaIDs = new List <int>(), placeableContents = new DungeonPlaceable { width = 2, height = 2, respectsEncounterableDifferentiator = true, variantTiers = new List <DungeonPlaceableVariant> { new DungeonPlaceableVariant { percentChance = 1f, nonDatabasePlaceable = placeableFromBundles, prerequisites = array, materialRequirements = new DungeonPlaceableRoomMaterialRequirement[0] } } } }); } else { Tools.PrintError <string>("Unable to find asset in asset bundles: " + assetPath, "FF0000"); } } catch (Exception e) { Tools.PrintException(e, "FF0000"); } }
// Token: 0x06000042 RID: 66 RVA: 0x00003E80 File Offset: 0x00002080 public static PrototypeDungeonRoom CreateRoomFromTexture(Texture2D texture) { int width = texture.width; int height = texture.height; PrototypeDungeonRoom newPrototypeDungeonRoom = RoomFactory.GetNewPrototypeDungeonRoom(width, height); PrototypeDungeonRoomCellData[] array = RoomFactory.m_cellData.GetValue(newPrototypeDungeonRoom) as PrototypeDungeonRoomCellData[]; array = new PrototypeDungeonRoomCellData[width * height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { array[i + j * width] = RoomFactory.CellDataFromColor(texture.GetPixel(i, j)); } } RoomFactory.m_cellData.SetValue(newPrototypeDungeonRoom, array); newPrototypeDungeonRoom.name = texture.name; return(newPrototypeDungeonRoom); }
// Token: 0x06000056 RID: 86 RVA: 0x00005804 File Offset: 0x00003A04 public static DungeonFlow CreateMazeFlow(Dungeon dungeon) { DungeonFlow dungeonFlow = SampleFlow.CreateNewFlow(dungeon); dungeonFlow.name = "maze_flow"; DungeonFlowNode dungeonFlowNode = SampleFlow.NodeFromAssetName(dungeonFlow, "elevator entrance"); dungeonFlow.FirstNode = dungeonFlowNode; dungeonFlow.AddNodeToFlow(dungeonFlowNode, null); DungeonFlowNode dungeonFlowNode2 = new DungeonFlowNode(dungeonFlow) { overrideExactRoom = RoomFactory.BuildFromResource("resource/rooms/maze.room").room }; dungeonFlow.AddNodeToFlow(dungeonFlowNode2, dungeonFlowNode); dungeonFlow.AddNodeToFlow(SampleFlow.NodeFromAssetName(dungeonFlow, "exit_room_basic"), dungeonFlowNode2); dungeon = null; return(dungeonFlow); }
public static DungeonFlow CreateMazeFlow(Dungeon dungeon) { var flow = CreateNewFlow(dungeon); flow.name = "maze_flow"; var entrance = NodeFromAssetName(flow, "elevator entrance"); flow.FirstNode = entrance; flow.AddNodeToFlow(entrance, null); var maze = new DungeonFlowNode(flow) { overrideExactRoom = RoomFactory.BuildFromResource("resource/rooms/maze.room").room }; flow.AddNodeToFlow(maze, entrance); flow.AddNodeToFlow(NodeFromAssetName(flow, "exit_room_basic"), maze); dungeon = null; return(flow); }
// Token: 0x060001C2 RID: 450 RVA: 0x000128FC File Offset: 0x00010AFC public static void Add() { ShrineFactory shrineFactory = new ShrineFactory(); { shrineFactory.name = "MountainBny Shrine"; shrineFactory.modID = "bny"; shrineFactory.text = "A shrine to the Gungeon Master. Voices of the Jammed whisper promises of power."; shrineFactory.spritePath = "BunnyMod/Resources/shrines/shrineoftheleadlord.png"; shrineFactory.room = RoomFactory.BuildFromResource("BunnyMod/Resources/rooms/shrineofleadlordroom.room").room; shrineFactory.acceptText = "Accept their promises."; shrineFactory.declineText = "Leave them be."; shrineFactory.OnAccept = new Action <PlayerController, GameObject>(ShrineOfTheLeadLord.Accept); shrineFactory.OnDecline = null; shrineFactory.CanUse = new Func <PlayerController, GameObject, bool>(ShrineOfTheLeadLord.CanUse); shrineFactory.offset = new Vector3(-1f, -1f, 0f); shrineFactory.talkPointOffset = new Vector3(0f, 3f, 0f); shrineFactory.isToggle = false; shrineFactory.isBreachShrine = false; } GameObject gameObject = shrineFactory.Build(); }
// Token: 0x060001C2 RID: 450 RVA: 0x000128FC File Offset: 0x00010AFC public static void Add() { ShrineFactory shrineFactory = new ShrineFactory(); { shrineFactory.name = "why"; shrineFactory.modID = "bny"; shrineFactory.text = "...."; shrineFactory.spritePath = "BunnyMod/Resources/shrines/imsorryneighborino.png"; shrineFactory.room = RoomFactory.BuildFromResource("BunnyMod/Resources/rooms/StrangerBossRoom.room").room; shrineFactory.acceptText = "..."; shrineFactory.declineText = "Youre a monster Bunny."; shrineFactory.OnAccept = null; shrineFactory.OnDecline = null; shrineFactory.CanUse = new Func <PlayerController, GameObject, bool>(PleaseForgiveMe.CanUse); shrineFactory.offset = new Vector3(-19f, -19f, 0f); shrineFactory.talkPointOffset = new Vector3(0f, 3f, 0f); shrineFactory.isToggle = false; shrineFactory.isBreachShrine = false; } GameObject gameObject = shrineFactory.Build(); }
// Token: 0x060001C2 RID: 450 RVA: 0x000128FC File Offset: 0x00010AFC public static void Add() { ShrineFactory shrineFactorya = new ShrineFactory(); { shrineFactorya.name = "ChaosCorruptionShrine"; shrineFactorya.modID = "bny"; shrineFactorya.text = "Whatever this shrine may have been, it has been eaten away by chaotic corruption."; shrineFactorya.spritePath = "BunnyMod/Resources/shrines/chaoscorruptionshrine.png"; shrineFactorya.room = RoomFactory.BuildFromResource("BunnyMod/Resources/rooms/chaosshrine1.room").room; shrineFactorya.acceptText = "Poke at it like the curious idiot that you are."; shrineFactorya.declineText = "Leave it alone."; shrineFactorya.OnAccept = new Action <PlayerController, GameObject>(ChaosCorruptionShrine.Accept); shrineFactorya.OnDecline = null; shrineFactorya.CanUse = new Func <PlayerController, GameObject, bool>(ChaosCorruptionShrine.CanUse); shrineFactorya.offset = new Vector3(-1f, -1f, 0f); shrineFactorya.talkPointOffset = new Vector3(0f, 1f, 0f); shrineFactorya.isToggle = false; shrineFactorya.isBreachShrine = false; } GameObject gameObject = shrineFactorya.Build(); }
// Token: 0x06000047 RID: 71 RVA: 0x0000407C File Offset: 0x0000227C public static PrototypeDungeonRoom CreateEmptyRoom(int width = 12, int height = 12) { PrototypeDungeonRoom result; try { PrototypeDungeonRoom newPrototypeDungeonRoom = RoomFactory.GetNewPrototypeDungeonRoom(width, height); RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2((float)(width / 2), (float)height), DungeonData.Direction.NORTH); RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2((float)(width / 2), 0f), DungeonData.Direction.SOUTH); RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2((float)width, (float)(height / 2)), DungeonData.Direction.EAST); RoomFactory.AddExit(newPrototypeDungeonRoom, new Vector2(0f, (float)(height / 2)), DungeonData.Direction.WEST); PrototypeDungeonRoomCellData[] array = RoomFactory.m_cellData.GetValue(newPrototypeDungeonRoom) as PrototypeDungeonRoomCellData[]; array = new PrototypeDungeonRoomCellData[width * height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { array[i + j * width] = new PrototypeDungeonRoomCellData { state = CellType.FLOOR, appearance = new PrototypeDungeonRoomCellAppearance { OverrideFloorType = CellVisualData.CellFloorType.Stone } }; } } RoomFactory.m_cellData.SetValue(newPrototypeDungeonRoom, array); newPrototypeDungeonRoom.UpdatePrecalculatedData(); result = newPrototypeDungeonRoom; } catch (Exception e) { Tools.PrintException(e, "FF0000"); result = null; } return(result); }
// Token: 0x06000043 RID: 67 RVA: 0x00003F2C File Offset: 0x0000212C public static PrototypeDungeonRoomCellData CellDataFromColor(Color32 color) { bool flag = color.Equals(Color.magenta); PrototypeDungeonRoomCellData result; if (flag) { result = null; } else { result = new PrototypeDungeonRoomCellData { state = RoomFactory.TypeFromColor(color), diagonalWallType = RoomFactory.DiagonalWallTypeFromColor(color), appearance = new PrototypeDungeonRoomCellAppearance { OverrideFloorType = CellVisualData.CellFloorType.Stone } }; } return(result); }
public static void Add() { ShrineFactory sf = new ShrineFactory() { name = "Key Shrine", modID = "kts", text = "A shrine representing the key to happiness.", spritePath = "GungeonAPI/resource/shrine_heart_key.png", room = RoomFactory.BuildFromResource("GungeonAPI/resource/rooms/KeyShrine.room").room, acceptText = "Offer a heart to unlock your potential", declineText = "Walk away", OnAccept = Accept, OnDecline = null, CanUse = CanUse, offset = new Vector3(10, 0, 0), talkPointOffset = new Vector3(0, 3, 0), isToggle = false, isBreachShrine = false }; //register shrine sf.Build(); }
// 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); }
///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); } }
// Token: 0x06000040 RID: 64 RVA: 0x00003E08 File Offset: 0x00002008 public static RoomFactory.RoomData ExtractRoomDataFromResource(string path) { string data = ResourceExtractor.BytesToString(ResourceExtractor.ExtractEmbeddedResource(path)); return(RoomFactory.ExtractRoomData(data)); }
// Token: 0x0600003F RID: 63 RVA: 0x00003DE4 File Offset: 0x00001FE4 public static RoomFactory.RoomData ExtractRoomDataFromFile(string path) { string data = ResourceExtractor.BytesToString(File.ReadAllBytes(path)); return(RoomFactory.ExtractRoomData(data)); }
// 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); }
// Token: 0x0600003E RID: 62 RVA: 0x00003B70 File Offset: 0x00001D70 public static void ApplyRoomData(PrototypeDungeonRoom room, RoomFactory.RoomData roomData) { bool flag = roomData.exitPositions != null; if (flag) { for (int i = 0; i < roomData.exitPositions.Length; i++) { DungeonData.Direction direction = (DungeonData.Direction)Enum.Parse(typeof(DungeonData.Direction), roomData.exitDirections[i].ToUpper()); RoomFactory.AddExit(room, roomData.exitPositions[i], direction); } } else { RoomFactory.AddExit(room, new Vector2((float)(room.Width / 2), (float)room.Height), DungeonData.Direction.NORTH); RoomFactory.AddExit(room, new Vector2((float)(room.Width / 2), 0f), DungeonData.Direction.SOUTH); RoomFactory.AddExit(room, new Vector2((float)room.Width, (float)(room.Height / 2)), DungeonData.Direction.EAST); RoomFactory.AddExit(room, new Vector2(0f, (float)(room.Height / 2)), DungeonData.Direction.WEST); } bool flag2 = roomData.enemyPositions != null; if (flag2) { for (int j = 0; j < roomData.enemyPositions.Length; j++) { RoomFactory.AddEnemyToRoom(room, roomData.enemyPositions[j], roomData.enemyGUIDs[j], roomData.enemyReinforcementLayers[j]); } } bool flag3 = roomData.placeablePositions != null; if (flag3) { for (int k = 0; k < roomData.placeablePositions.Length; k++) { RoomFactory.AddPlaceableToRoom(room, roomData.placeablePositions[k], roomData.placeableGUIDs[k]); } } bool flag4 = roomData.floors != null; if (flag4) { foreach (string val in roomData.floors) { room.prerequisites.Add(new DungeonPrerequisite { prerequisiteType = DungeonPrerequisite.PrerequisiteType.TILESET, requiredTileset = Tools.GetEnumValue <GlobalDungeonData.ValidTilesets>(val) }); } } bool flag5 = !string.IsNullOrEmpty(roomData.category); if (flag5) { room.category = Tools.GetEnumValue <PrototypeDungeonRoom.RoomCategory>(roomData.category); } bool flag6 = !string.IsNullOrEmpty(roomData.normalSubCategory); if (flag6) { room.subCategoryNormal = Tools.GetEnumValue <PrototypeDungeonRoom.RoomNormalSubCategory>(roomData.normalSubCategory); } bool flag7 = !string.IsNullOrEmpty(roomData.bossSubCategory); if (flag7) { room.subCategoryBoss = Tools.GetEnumValue <PrototypeDungeonRoom.RoomBossSubCategory>(roomData.bossSubCategory); } bool flag8 = !string.IsNullOrEmpty(roomData.specialSubCatergory); if (flag8) { room.subCategorySpecial = Tools.GetEnumValue <PrototypeDungeonRoom.RoomSpecialSubCategory>(roomData.specialSubCatergory); } }
///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); } }