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); } } 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."); }
// Token: 0x0600007D RID: 125 RVA: 0x00006BE0 File Offset: 0x00004DE0 public static Rect AddFaceCardToAtlas(Texture2D tex, Texture2D atlas, int index, Rect bounds) { int num = (int)(bounds.width / 34f); int num2 = (int)(bounds.height / 34f); int num3 = index % num; int num4 = index / num; bool flag = num3 >= num || num4 >= num2; Rect result; if (flag) { Tools.PrintError <string>("Not enough room left on the Facecard Atlas for this facecard!", "FF0000"); result = Rect.zero; } else { int num5 = (int)bounds.x + num3 * 34; int num6 = (int)bounds.y + num4 * 34; for (int i = 0; i < tex.width; i++) { for (int j = 0; j < tex.height; j++) { atlas.SetPixel(i + num5, j + num6, tex.GetPixel(i, j)); } } atlas.Apply(false, false); result = new Rect((float)num5 / (float)atlas.width, (float)num6 / (float)atlas.height, 34f / (float)atlas.width, 34f / (float)atlas.height); } return(result); }
public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps) { tk2dSpriteCollectionData collection = aiAnimator.GetComponent <tk2dSpriteCollectionData>(); if (!collection) { collection = SpriteBuilder.ConstructCollection(aiAnimator.gameObject, $"{aiAnimator.name}_collection"); } string[] resources = ResourceExtractor.GetResourceNames(); List <int> indices = new List <int>(); for (int i = 0; i < resources.Length; i++) { if (resources[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase)) { indices.Add(SpriteBuilder.AddSpriteToCollection(resources[i], collection)); } } if (indices.Count == 0) { Tools.PrintError($"No sprites found for animation {name}"); } tk2dSpriteAnimationClip clip = SpriteBuilder.AddAnimation(aiAnimator.spriteAnimator, collection, indices, name, tk2dSpriteAnimationClip.WrapMode.Loop); clip.fps = fps; return(clip); }
// Token: 0x06000055 RID: 85 RVA: 0x00004BB0 File Offset: 0x00002DB0 public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps) { tk2dSpriteCollectionData tk2dSpriteCollectionData = aiAnimator.GetComponent <tk2dSpriteCollectionData>(); bool flag = !tk2dSpriteCollectionData; if (flag) { tk2dSpriteCollectionData = SpriteBuilder.ConstructCollection(aiAnimator.gameObject, aiAnimator.name + "_collection"); } string[] resourceNames = ResourceExtractor.GetResourceNames(); List <int> list = new List <int>(); for (int i = 0; i < resourceNames.Length; i++) { bool flag2 = resourceNames[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase); if (flag2) { list.Add(SpriteBuilder.AddSpriteToCollection(resourceNames[i], tk2dSpriteCollectionData)); } } bool flag3 = list.Count == 0; if (flag3) { Tools.PrintError <string>("No sprites found for animation " + name, "FF0000"); } tk2dSpriteAnimationClip tk2dSpriteAnimationClip = SpriteBuilder.AddAnimation(aiAnimator.spriteAnimator, tk2dSpriteCollectionData, list, name, tk2dSpriteAnimationClip.WrapMode.Loop); tk2dSpriteAnimationClip.fps = (float)fps; return(tk2dSpriteAnimationClip); }
public static Rect AddFaceCardToAtlas(Texture2D tex, Texture2D atlas, int index, Rect bounds) { int xCapacity = (int)(bounds.width / 34); //floor of width/spritesize int yCapacity = (int)(bounds.height / 34); int xIndex = index % xCapacity; int yIndex = index / xCapacity; if (xIndex >= xCapacity || yIndex >= yCapacity) { Tools.PrintError("Not enough room left on the Facecard Atlas for this facecard!"); return(Rect.zero); } int xOffset = (int)bounds.x + (xIndex * 34); int yOffset = (int)bounds.y + (yIndex * 34); for (int x = 0; x < tex.width; x++) { for (int y = 0; y < tex.height; y++) { atlas.SetPixel(x + xOffset, y + yOffset, tex.GetPixel(x, y)); } } atlas.Apply(false, false); return(new Rect((float)xOffset / atlas.width, (float)yOffset / atlas.height, 34f / atlas.width, 34f / atlas.height)); }
// Token: 0x06000037 RID: 55 RVA: 0x00003918 File Offset: 0x00001B18 public static Texture2D GetTextureFromResource(string resourceName) { byte[] array = ResourceExtractor.ExtractEmbeddedResource(resourceName); bool flag = array == null; Texture2D result; if (flag) { Tools.PrintError <string>("No bytes found in " + resourceName, "FF0000"); result = null; } else { Texture2D texture2D = new Texture2D(1, 1, TextureFormat.RGBAFloat, false); texture2D.LoadImage(array); texture2D.filterMode = FilterMode.Point; string text = resourceName.Substring(0, resourceName.LastIndexOf('.')); bool flag2 = text.LastIndexOf('.') >= 0; if (flag2) { text = text.Substring(text.LastIndexOf('.') + 1); } texture2D.name = text; result = texture2D; } return(result); }
void Start() { string id = this.name.Replace("(Clone)", ""); if (ShrineFactory.registeredShrines.ContainsKey(id)) { Copy(ShrineFactory.registeredShrines[id].GetComponent <CustomShrineController>()); } else { Tools.PrintError($"Was this shrine registered correctly?: {id}"); } var si = GetComponent <SimpleInteractable>(); if (!si) { return; } si.OnAccept = OnAccept; si.OnDecline = OnDecline; si.CanUse = CanUse; si.text = text; si.acceptText = acceptText; si.declineText = declineText; Tools.Print($"Started shrine: {id}"); }
// Token: 0x0600002E RID: 46 RVA: 0x000035EC File Offset: 0x000017EC public static List <Texture2D> GetTexturesFromDirectory(string directoryPath) { bool flag = !Directory.Exists(directoryPath); List <Texture2D> result; if (flag) { Tools.PrintError <string>(directoryPath + " not found.", "FF0000"); result = null; } else { List <Texture2D> list = new List <Texture2D>(); foreach (string text in Directory.GetFiles(directoryPath)) { bool flag2 = !text.EndsWith(".png"); if (!flag2) { Texture2D item = ResourceExtractor.BytesToTexture(File.ReadAllBytes(text), Path.GetFileName(text).Replace(".png", "")); list.Add(item); } } result = list; } return(result); }
// Token: 0x0600031F RID: 799 RVA: 0x000227B0 File Offset: 0x000209B0 private void Start() { string text = base.name.Replace("(Clone)", ""); bool flag = ShrineFactory.registeredShrines.ContainsKey(text); bool flag2 = flag; bool flag3 = flag2; if (flag3) { this.Copy(ShrineFactory.registeredShrines[text].GetComponent <ShrineFactory.CustomShrineController>()); } else { Tools.PrintError <string>("Was this shrine registered correctly?: " + text, "FF0000"); } SimpleInteractable component = base.GetComponent <SimpleInteractable>(); bool flag4 = !component; bool flag5 = !flag4; bool flag6 = flag5; if (flag6) { component.OnAccept = this.OnAccept; component.OnDecline = this.OnDecline; component.CanUse = this.CanUse; component.text = this.text; component.acceptText = this.acceptText; component.declineText = this.declineText; } }
/// <summary> /// Converts an embedded resource to a Texture2D object /// </summary> public static Texture2D GetTextureFromResource(string resourceName) { string file = resourceName; byte[] bytes = ExtractEmbeddedResource(file); if (bytes == null) { Tools.PrintError("No bytes found in " + file); return(null); } Texture2D texture = new Texture2D(1, 1, TextureFormat.RGBAFloat, false); ImageConversion.LoadImage(texture, bytes); texture.filterMode = FilterMode.Point; string name = file.Substring(0, file.LastIndexOf('.')); if (name.LastIndexOf('.') >= 0) { name = name.Substring(name.LastIndexOf('.') + 1); } texture.name = name; return(texture); }
public static void AddPlaceableToRoom(PrototypeDungeonRoom room, Vector2 location, string assetPath) { try { GameObject asset = GetGameObjectFromBundles(assetPath); if (asset) { DungeonPrerequisite[] emptyReqs = new DungeonPrerequisite[0]; room.placedObjectPositions.Add(location); var placeableContents = ScriptableObject.CreateInstance <DungeonPlaceable>(); placeableContents.width = 2; placeableContents.height = 2; placeableContents.respectsEncounterableDifferentiator = true; placeableContents.variantTiers = new List <DungeonPlaceableVariant>() { new DungeonPlaceableVariant() { percentChance = 1, nonDatabasePlaceable = asset, prerequisites = emptyReqs, materialRequirements = new DungeonPlaceableRoomMaterialRequirement[0] } }; room.placedObjects.Add(new PrototypePlacedObjectData() { contentsBasePosition = location, fieldData = new List <PrototypePlacedObjectFieldData>(), instancePrerequisites = emptyReqs, linkedTriggerAreaIDs = new List <int>(), placeableContents = placeableContents }); //Tools.Print($"Added {asset.name} to room."); return; } DungeonPlaceable placeable = GetPlaceableFromBundles(assetPath); if (placeable) { DungeonPrerequisite[] emptyReqs = new DungeonPrerequisite[0]; room.placedObjectPositions.Add(location); room.placedObjects.Add(new PrototypePlacedObjectData() { contentsBasePosition = location, fieldData = new List <PrototypePlacedObjectFieldData>(), instancePrerequisites = emptyReqs, linkedTriggerAreaIDs = new List <int>(), placeableContents = placeable }); return; } Tools.PrintError($"Unable to find asset in asset bundles: {assetPath}"); } catch (Exception e) { Tools.PrintException(e); } }
public static void AddPlaceableToRoom(PrototypeDungeonRoom room, Vector2 location, string assetPath) { try { if (GetGameObjectFromBundles(assetPath) != null) { DungeonPrerequisite[] array = new DungeonPrerequisite[0]; room.placedObjectPositions.Add(location); DungeonPlaceable dungeonPlaceable = ScriptableObject.CreateInstance <DungeonPlaceable>(); dungeonPlaceable.width = 2; dungeonPlaceable.height = 2; dungeonPlaceable.respectsEncounterableDifferentiator = true; dungeonPlaceable.variantTiers = new List <DungeonPlaceableVariant> { new DungeonPlaceableVariant { percentChance = 1f, nonDatabasePlaceable = GetGameObjectFromBundles(assetPath), prerequisites = array, materialRequirements = new DungeonPlaceableRoomMaterialRequirement[0] } }; room.placedObjects.Add(new PrototypePlacedObjectData { contentsBasePosition = location, fieldData = new List <PrototypePlacedObjectFieldData>(), instancePrerequisites = array, linkedTriggerAreaIDs = new List <int>(), placeableContents = dungeonPlaceable }); return; } else if (GetPlaceableFromBundles(assetPath) != null) { DungeonPrerequisite[] instancePrerequisites = new DungeonPrerequisite[0]; room.placedObjectPositions.Add(location); room.placedObjects.Add(new PrototypePlacedObjectData { contentsBasePosition = location, fieldData = new List <PrototypePlacedObjectFieldData>(), instancePrerequisites = instancePrerequisites, linkedTriggerAreaIDs = new List <int>(), placeableContents = GetPlaceableFromBundles(assetPath) }); return; } else { Tools.PrintError("Unable to find asset in asset bundles: " + assetPath, "FF0000"); } } catch (Exception e) { Tools.PrintException(e); } }
public static void StopTimerAndReport(string name) { string key = name.ToLower(); if (!timers.ContainsKey(key)) { Tools.PrintError($"Could not stop timer {name}, no such timer exists"); return; } float timerStart = timers[key]; int elapsed = (int)((Time.realtimeSinceStartup - timerStart) * 1000); timers.Remove(key); Tools.Print($"{name} finished in " + elapsed + "ms"); }
/// <summary> /// Creates a Texture2D from a file in the sprites directory /// </summary> public static Texture2D GetTextureFromFile(string fileName, string extension = ".png") { fileName = fileName.Replace(extension, ""); string filePath = Path.Combine(spritesDirectory, fileName + extension); if (!File.Exists(filePath)) { Tools.PrintError(filePath + " not found."); return(null); } Texture2D texture = BytesToTexture(File.ReadAllBytes(filePath), fileName); return(texture); }
// Token: 0x06000083 RID: 131 RVA: 0x000062BC File Offset: 0x000044BC public static void StartTimer(string name) { string key = name.ToLower(); bool flag = Tools.timers.ContainsKey(key); if (flag) { Tools.PrintError <string>("Timer " + name + " already exists.", "FF0000"); } else { Tools.timers.Add(key, Time.realtimeSinceStartup); } }
// 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)); }
void Start() { string id = this.name.Replace("(Clone)", ""); if (ShrineFactory.builtShrines.ContainsKey(id)) { Copy(ShrineFactory.builtShrines[id].GetComponent <CustomShrineController>()); } else { Tools.PrintError($"Was this shrine registered correctly?: {id}"); } this.GetComponent <SimpleInteractable>().OnAccept = OnAccept; this.GetComponent <SimpleInteractable>().OnDecline = OnDecline; this.GetComponent <SimpleInteractable>().CanUse = CanUse; }
public static PrototypeDungeonRoom Build(Texture2D texture, RoomData roomData) { try { var room = CreateRoomFromTexture(texture); ApplyRoomData(room, roomData); room.UpdatePrecalculatedData(); return(room); } catch (Exception e) { Tools.PrintError("Failed to build room!"); Tools.PrintException(e); } return(CreateEmptyRoom(12, 12)); }
// Token: 0x06000084 RID: 132 RVA: 0x00006310 File Offset: 0x00004510 public static void StopTimerAndReport(string name) { string key = name.ToLower(); bool flag = !Tools.timers.ContainsKey(key); if (flag) { Tools.PrintError <string>("Could not stop timer " + name + ", no such timer exists", "FF0000"); } else { float num = Tools.timers[key]; int num2 = (int)((Time.realtimeSinceStartup - num) * 1000f); Tools.timers.Remove(key); Tools.Print <string>(name + " finished in " + num2.ToString() + "ms", "FFFFFF", false); } }
// 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"); } }
public static PrototypeDungeonRoom Build(Texture2D texture, RoomData roomData, bool SetRoomCategory, bool AutoAssignToFloor, bool AssignDecorationProperties, float?Weight) { try { PrototypeDungeonRoom room = CreateRoomFromTexture(texture); ApplyRoomData(room, roomData, SetRoomCategory, AutoAssignToFloor, AssignDecorationProperties, Weight); room.OnBeforeSerialize(); room.OnAfterDeserialize(); room.UpdatePrecalculatedData(); return(room); } catch (Exception e) { Tools.PrintError("Failed to build room!"); Tools.PrintException(e); } return(CreateEmptyRoom(12, 12)); }
// Token: 0x06000303 RID: 771 RVA: 0x00021FE0 File Offset: 0x000201E0 private void Start() { string text = base.name.Replace("(Clone)", ""); bool flag = OldShrineFactory.builtShrines.ContainsKey(text); bool flag2 = flag; if (flag2) { this.Copy(OldShrineFactory.builtShrines[text].GetComponent <OldShrineFactory.CustomShrineController>()); } else { Tools.PrintError <string>("Was this shrine registered correctly?: " + text, "FF0000"); } base.GetComponent <SimpleInteractable>().OnAccept = this.OnAccept; base.GetComponent <SimpleInteractable>().OnDecline = this.OnDecline; base.GetComponent <SimpleInteractable>().CanUse = this.CanUse; }
// Token: 0x0600002F RID: 47 RVA: 0x00003694 File Offset: 0x00001894 public static Texture2D GetTextureFromFile(string fileName, string extension = ".png") { fileName = fileName.Replace(extension, ""); string text = Path.Combine(ResourceExtractor.spritesDirectory, fileName + extension); bool flag = !File.Exists(text); Texture2D result; if (flag) { Tools.PrintError <string>(text + " not found.", "FF0000"); result = null; } else { Texture2D texture2D = ResourceExtractor.BytesToTexture(File.ReadAllBytes(text), fileName); result = texture2D; } return(result); }
public static void Init() { AssetBundles = new Dictionary <string, AssetBundle>(); foreach (var name in assetBundleNames) { try { var bundle = ResourceManager.LoadAssetBundle(name); 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 = GetAsset <GenericRoomTable>(entry.Value); if (table == null) { table = DungeonDatabase.GetOrLoadByName($"base_{entry.Key}").PatternSettings.flows[0].fallbackRoomTable; } RoomTables.Add(entry.Key, table); //Tools.Log(table.name); } catch (Exception e) { Tools.PrintError($"Failed to load room table: {entry.Key}:{entry.Value}"); Tools.PrintException(e); } } Tools.Print("Static references initialized."); }
/// <summary> /// Converts all png's in a folder to a list of Texture2D objects /// </summary> public static List <Texture2D> GetTexturesFromDirectory(string directoryPath) { if (!Directory.Exists(directoryPath)) { Tools.PrintError(directoryPath + " not found."); return(null); } List <Texture2D> textures = new List <Texture2D>(); foreach (string filePath in Directory.GetFiles(directoryPath)) { if (!filePath.EndsWith(".png")) { continue; } Texture2D texture = BytesToTexture(File.ReadAllBytes(filePath), Path.GetFileName(filePath).Replace(".png", "")); textures.Add(texture); } return(textures); }
// Token: 0x06000079 RID: 121 RVA: 0x00006768 File Offset: 0x00004968 public static void Init() { StaticReferences.AssetBundles = new Dictionary <string, AssetBundle>(); foreach (string text in StaticReferences.assetBundleNames) { try { AssetBundle assetBundle = ResourceManager.LoadAssetBundle(text); StaticReferences.AssetBundles.Add(text, ResourceManager.LoadAssetBundle(text)); } catch (Exception e) { Tools.PrintError <string>("Failed to load asset bundle: " + text, "FF0000"); Tools.PrintException(e, "FF0000"); } } StaticReferences.RoomTables = new Dictionary <string, GenericRoomTable>(); foreach (KeyValuePair <string, string> keyValuePair in StaticReferences.roomTableMap) { try { GenericRoomTable genericRoomTable = StaticReferences.GetAsset <GenericRoomTable>(keyValuePair.Value); bool flag = genericRoomTable == null; bool flag2 = flag; if (flag2) { genericRoomTable = DungeonDatabase.GetOrLoadByName("base_" + keyValuePair.Key).PatternSettings.flows[0].fallbackRoomTable; } StaticReferences.RoomTables.Add(keyValuePair.Key, genericRoomTable); } catch (Exception e2) { Tools.PrintError <string>("Failed to load room table: " + keyValuePair.Key + ":" + keyValuePair.Value, "FF0000"); Tools.PrintException(e2, "FF0000"); } } Tools.Print <string>("Static references initialized.", "FFFFFF", false); }