Setup
Firstly you will need two important files. ModPrefabs and ModRoomPrefabs.
Lets start by creating ModPrefabs, this will be the first thing inited in your module.
once it is created paste in:
public static AssetBundle shared_auto_002;
public static AssetBundle shared_auto_001;
public static AssetBundle ModAssets;
public static AssetBundle braveResources;
private static Dungeon TutorialDungeonPrefab;
private static Dungeon SewerDungeonPrefab;
private static Dungeon MinesDungeonPrefab;
private static Dungeon ratDungeon;
private static Dungeon CathedralDungeonPrefab;
private static Dungeon BulletHellDungeonPrefab;
private static Dungeon ForgeDungeonPrefab;
private static Dungeon CatacombsDungeonPrefab;
private static Dungeon NakatomiDungeonPrefab;
public static PrototypeDungeonRoom reward_room;
public static PrototypeDungeonRoom gungeon_rewardroom_1;
public static PrototypeDungeonRoom shop02;
public static PrototypeDungeonRoom doublebeholsterroom01;
public static GenericRoomTable shop_room_table;
public static GenericRoomTable boss_foyertable;
public static GenericRoomTable FloorNameRoomTable;
public static GenericRoomTable SecretRoomTable;
public static GenericRoomTable CastleRoomTable;
public static GenericRoomTable Gungeon_RoomTable;
public static GenericRoomTable SewersRoomTable;
public static GenericRoomTable AbbeyRoomTable;
public static GenericRoomTable MinesRoomTable;
public static GenericRoomTable CatacombsRoomTable;
public static GenericRoomTable ForgeRoomTable;
public static GenericRoomTable BulletHellRoomTable;
Now we need to make our init method that defines all of these. If you dont have AssetBundleLoader.LoadAssetBundleFromLiterallyAnywhere then check out Making Asset bundles
Add this file as well:
public static void InitCustomPrefabs()
{
ModAssets = AssetBundleLoader.LoadAssetBundleFromLiterallyAnywhere("modassets");
AssetBundle assetBundle = ResourceManager.LoadAssetBundle("shared_auto_001");
AssetBundle assetBundle2 = ResourceManager.LoadAssetBundle("shared_auto_002");
shared_auto_001 = assetBundle;
shared_auto_002 = assetBundle2;
braveResources = ResourceManager.LoadAssetBundle("brave_resources_001");
if (ModAssets is null)
{
ETGModConsole.Log("ModAssets is null!");
}
TutorialDungeonPrefab = DungeonDatabase.GetOrLoadByName("Base_Tutorial");
SewerDungeonPrefab = DungeonDatabase.GetOrLoadByName("Base_Sewer");
MinesDungeonPrefab = DungeonDatabase.GetOrLoadByName("Base_Mines");
ratDungeon = DungeonDatabase.GetOrLoadByName("base_resourcefulrat");
CathedralDungeonPrefab = DungeonDatabase.GetOrLoadByName("Base_Cathedral");
BulletHellDungeonPrefab = DungeonDatabase.GetOrLoadByName("Base_BulletHell");
ForgeDungeonPrefab = DungeonDatabase.GetOrLoadByName("Base_Forge");
CatacombsDungeonPrefab = DungeonDatabase.GetOrLoadByName("Base_Catacombs");
NakatomiDungeonPrefab = DungeonDatabase.GetOrLoadByName("base_nakatomi");
reward_room = shared_auto_002.LoadAsset<PrototypeDungeonRoom>("reward room");
gungeon_rewardroom_1 = shared_auto_002.LoadAsset<PrototypeDungeonRoom>("gungeon_rewardroom_1");
shop_room_table = shared_auto_002.LoadAsset<GenericRoomTable>("Shop Room Table");
shop02 = shared_auto_002.LoadAsset<PrototypeDungeonRoom>("shop02");
boss_foyertable = shared_auto_002.LoadAsset<GenericRoomTable>("Boss Foyers");
FloorNameRoomTable= ScriptableObject.CreateInstance<GenericRoomTable>();
FloorNameRoomTable.includedRooms = new WeightedRoomCollection();
FloorNameRoomTable.includedRooms.elements = new List<WeightedRoom>();
FloorNameRoomTable.includedRoomTables = new List<GenericRoomTable>(0);
SecretRoomTable = shared_auto_002.LoadAsset<GenericRoomTable>("secret_room_table_01");
CastleRoomTable = shared_auto_002.LoadAsset<GenericRoomTable>("Castle_RoomTable");
Gungeon_RoomTable = shared_auto_002.LoadAsset<GenericRoomTable>("Gungeon_RoomTable");
SewersRoomTable = SewerDungeonPrefab.PatternSettings.flows[0].fallbackRoomTable;
AbbeyRoomTable = CathedralDungeonPrefab.PatternSettings.flows[0].fallbackRoomTable;
MinesRoomTable = MinesDungeonPrefab.PatternSettings.flows[0].fallbackRoomTable;
CatacombsRoomTable = CatacombsDungeonPrefab.PatternSettings.flows[0].fallbackRoomTable;
ForgeRoomTable = ForgeDungeonPrefab.PatternSettings.flows[0].fallbackRoomTable;
BulletHellRoomTable = BulletHellDungeonPrefab.PatternSettings.flows[0].fallbackRoomTable;
doublebeholsterroom01 = FloorNameDungeonFlows.LoadOfficialFlow("Secret_DoubleBeholster_Flow").AllNodes[2].overrideExactRoom;
}
}
This defines asset bundles, some important rooms, and dungeons so that we can access them anywhere by using "ModPrefabs.Variable". We will come back to this script a few times whenever we add objects to our assatbundle.
Now, onto making ModRoomPrefabs
drop this into your toolbox:
public static DungeonPlaceable GenerateDungeonPlacable(GameObject ObjectPrefab = null, bool spawnsEnemy = false, bool useExternalPrefab = false, bool spawnsItem = false, string EnemyGUID = "479556d05c7c44f3b6abb3b2067fc778", int itemID = 307, Vector2? CustomOffset = null, bool itemHasDebrisObject = true, float spawnChance = 1f)
{
AssetBundle m_assetBundle = ResourceManager.LoadAssetBundle("shared_auto_001");
AssetBundle m_assetBundle2 = ResourceManager.LoadAssetBundle("shared_auto_002");
AssetBundle m_resourceBundle = ResourceManager.LoadAssetBundle("brave_resources_001");
// Used with custom DungeonPlacable
GameObject ChestBrownTwoItems = m_assetBundle.LoadAsset<GameObject>("Chest_Wood_Two_Items");
GameObject Chest_Silver = m_assetBundle.LoadAsset<GameObject>("chest_silver");
GameObject Chest_Green = m_assetBundle.LoadAsset<GameObject>("chest_green");
GameObject Chest_Synergy = m_assetBundle.LoadAsset<GameObject>("chest_synergy");
GameObject Chest_Red = m_assetBundle.LoadAsset<GameObject>("chest_red");
GameObject Chest_Black = m_assetBundle.LoadAsset<GameObject>("Chest_Black");
GameObject Chest_Rainbow = m_assetBundle.LoadAsset<GameObject>("Chest_Rainbow");
// GameObject Chest_Rat = m_assetBundle.LoadAsset<GameObject>("Chest_Rat");
m_assetBundle = null;
m_assetBundle2 = null;
m_resourceBundle = null;
DungeonPlaceableVariant BlueChestVariant = new DungeonPlaceableVariant();
BlueChestVariant.percentChance = 0.35f;
BlueChestVariant.unitOffset = new Vector2(1, 0.8f);
BlueChestVariant.enemyPlaceableGuid = string.Empty;
BlueChestVariant.pickupObjectPlaceableId = -1;
BlueChestVariant.forceBlackPhantom = false;
BlueChestVariant.addDebrisObject = false;
BlueChestVariant.prerequisites = null;
BlueChestVariant.materialRequirements = null;
BlueChestVariant.nonDatabasePlaceable = Chest_Silver;
DungeonPlaceableVariant BrownChestVariant = new DungeonPlaceableVariant();
BrownChestVariant.percentChance = 0.28f;
BrownChestVariant.unitOffset = new Vector2(1, 0.8f);
BrownChestVariant.enemyPlaceableGuid = string.Empty;
BrownChestVariant.pickupObjectPlaceableId = -1;
BrownChestVariant.forceBlackPhantom = false;
BrownChestVariant.addDebrisObject = false;
BrownChestVariant.prerequisites = null;
BrownChestVariant.materialRequirements = null;
BrownChestVariant.nonDatabasePlaceable = ChestBrownTwoItems;
DungeonPlaceableVariant GreenChestVariant = new DungeonPlaceableVariant();
GreenChestVariant.percentChance = 0.25f;
GreenChestVariant.unitOffset = new Vector2(1, 0.8f);
GreenChestVariant.enemyPlaceableGuid = string.Empty;
GreenChestVariant.pickupObjectPlaceableId = -1;
GreenChestVariant.forceBlackPhantom = false;
GreenChestVariant.addDebrisObject = false;
GreenChestVariant.prerequisites = null;
GreenChestVariant.materialRequirements = null;
GreenChestVariant.nonDatabasePlaceable = Chest_Green;
DungeonPlaceableVariant SynergyChestVariant = new DungeonPlaceableVariant();
SynergyChestVariant.percentChance = 0.2f;
SynergyChestVariant.unitOffset = new Vector2(1, 0.8f);
SynergyChestVariant.enemyPlaceableGuid = string.Empty;
SynergyChestVariant.pickupObjectPlaceableId = -1;
SynergyChestVariant.forceBlackPhantom = false;
SynergyChestVariant.addDebrisObject = false;
SynergyChestVariant.prerequisites = null;
SynergyChestVariant.materialRequirements = null;
SynergyChestVariant.nonDatabasePlaceable = Chest_Synergy;
DungeonPlaceableVariant RedChestVariant = new DungeonPlaceableVariant();
RedChestVariant.percentChance = 0.15f;
RedChestVariant.unitOffset = new Vector2(0.5f, 0.5f);
RedChestVariant.enemyPlaceableGuid = string.Empty;
RedChestVariant.pickupObjectPlaceableId = -1;
RedChestVariant.forceBlackPhantom = false;
RedChestVariant.addDebrisObject = false;
RedChestVariant.prerequisites = null;
RedChestVariant.materialRequirements = null;
RedChestVariant.nonDatabasePlaceable = Chest_Red;
DungeonPlaceableVariant BlackChestVariant = new DungeonPlaceableVariant();
BlackChestVariant.percentChance = 0.1f;
BlackChestVariant.unitOffset = new Vector2(0.5f, 0.5f);
BlackChestVariant.enemyPlaceableGuid = string.Empty;
BlackChestVariant.pickupObjectPlaceableId = -1;
BlackChestVariant.forceBlackPhantom = false;
BlackChestVariant.addDebrisObject = false;
BlackChestVariant.prerequisites = null;
BlackChestVariant.materialRequirements = null;
BlackChestVariant.nonDatabasePlaceable = Chest_Black;
DungeonPlaceableVariant RainbowChestVariant = new DungeonPlaceableVariant();
RainbowChestVariant.percentChance = 0.005f;
RainbowChestVariant.unitOffset = new Vector2(0.5f, 0.5f);
RainbowChestVariant.enemyPlaceableGuid = string.Empty;
RainbowChestVariant.pickupObjectPlaceableId = -1;
RainbowChestVariant.forceBlackPhantom = false;
RainbowChestVariant.addDebrisObject = false;
RainbowChestVariant.prerequisites = null;
RainbowChestVariant.materialRequirements = null;
RainbowChestVariant.nonDatabasePlaceable = Chest_Rainbow;
DungeonPlaceableVariant ItemVariant = new DungeonPlaceableVariant();
ItemVariant.percentChance = spawnChance;
if (CustomOffset.HasValue)
{
ItemVariant.unitOffset = CustomOffset.Value;
}
else
{
ItemVariant.unitOffset = Vector2.zero;
}
// ItemVariant.unitOffset = new Vector2(0.5f, 0.8f);
ItemVariant.enemyPlaceableGuid = string.Empty;
ItemVariant.pickupObjectPlaceableId = itemID;
ItemVariant.forceBlackPhantom = false;
if (itemHasDebrisObject)
{
ItemVariant.addDebrisObject = true;
}
else
{
ItemVariant.addDebrisObject = false;
}
RainbowChestVariant.prerequisites = null;
RainbowChestVariant.materialRequirements = null;
List<DungeonPlaceableVariant> ChestTiers = new List<DungeonPlaceableVariant>();
ChestTiers.Add(BrownChestVariant);
ChestTiers.Add(BlueChestVariant);
ChestTiers.Add(GreenChestVariant);
ChestTiers.Add(SynergyChestVariant);
ChestTiers.Add(RedChestVariant);
ChestTiers.Add(BlackChestVariant);
ChestTiers.Add(RainbowChestVariant);
DungeonPlaceableVariant EnemyVariant = new DungeonPlaceableVariant();
EnemyVariant.percentChance = spawnChance;
EnemyVariant.unitOffset = Vector2.zero;
EnemyVariant.enemyPlaceableGuid = EnemyGUID;
EnemyVariant.pickupObjectPlaceableId = -1;
EnemyVariant.forceBlackPhantom = false;
EnemyVariant.addDebrisObject = false;
EnemyVariant.prerequisites = null;
EnemyVariant.materialRequirements = null;
List<DungeonPlaceableVariant> EnemyTiers = new List<DungeonPlaceableVariant>();
EnemyTiers.Add(EnemyVariant);
List<DungeonPlaceableVariant> ItemTiers = new List<DungeonPlaceableVariant>();
ItemTiers.Add(ItemVariant);
DungeonPlaceable m_cachedCustomPlacable = ScriptableObject.CreateInstance<DungeonPlaceable>();
m_cachedCustomPlacable.name = "CustomChestPlacable";
if (spawnsEnemy | useExternalPrefab)
{
m_cachedCustomPlacable.width = 2;
m_cachedCustomPlacable.height = 2;
}
else if (spawnsItem)
{
m_cachedCustomPlacable.width = 1;
m_cachedCustomPlacable.height = 1;
}
else
{
m_cachedCustomPlacable.width = 4;
m_cachedCustomPlacable.height = 1;
}
m_cachedCustomPlacable.roomSequential = false;
m_cachedCustomPlacable.respectsEncounterableDifferentiator = true;
m_cachedCustomPlacable.UsePrefabTransformOffset = false;
m_cachedCustomPlacable.isPassable = true;
if (spawnsItem)
{
m_cachedCustomPlacable.MarkSpawnedItemsAsRatIgnored = true;
}
else
{
m_cachedCustomPlacable.MarkSpawnedItemsAsRatIgnored = false;
}
m_cachedCustomPlacable.DebugThisPlaceable = false;
if (useExternalPrefab && ObjectPrefab != null)
{
DungeonPlaceableVariant ExternalObjectVariant = new DungeonPlaceableVariant();
ExternalObjectVariant.percentChance = spawnChance;
if (CustomOffset.HasValue)
{
ExternalObjectVariant.unitOffset = CustomOffset.Value;
}
else
{
ExternalObjectVariant.unitOffset = Vector2.zero;
}
ExternalObjectVariant.enemyPlaceableGuid = string.Empty;
ExternalObjectVariant.pickupObjectPlaceableId = -1;
ExternalObjectVariant.forceBlackPhantom = false;
ExternalObjectVariant.addDebrisObject = false;
ExternalObjectVariant.nonDatabasePlaceable = ObjectPrefab;
List<DungeonPlaceableVariant> ExternalObjectTiers = new List<DungeonPlaceableVariant>();
ExternalObjectTiers.Add(ExternalObjectVariant);
m_cachedCustomPlacable.variantTiers = ExternalObjectTiers;
}
else if (spawnsEnemy)
{
m_cachedCustomPlacable.variantTiers = EnemyTiers;
}
else if (spawnsItem)
{
m_cachedCustomPlacable.variantTiers = ItemTiers;
}
else
{
m_cachedCustomPlacable.variantTiers = ChestTiers;
}
return m_cachedCustomPlacable;
}
(make sure you have this GungeonAPI)
and add this file:
change namespace appropriately.
Put this in your toolbox:
public static class ReflectionHelpers
{
public static IList CreateDynamicList(Type type)
{
bool flag = type == null;
if (flag) { throw new ArgumentNullException("type", "Argument cannot be null."); }
ConstructorInfo[] constructors = typeof(List<>).MakeGenericType(new Type[] { type }).GetConstructors();
foreach (ConstructorInfo constructorInfo in constructors)
{
ParameterInfo[] parameters = constructorInfo.GetParameters();
bool flag2 = parameters.Length != 0;
if (!flag2) { return (IList)constructorInfo.Invoke(null, null); }
}
throw new ApplicationException("Could not create a new list with type <" + type.ToString() + ">.");
}
public static IDictionary CreateDynamicDictionary(Type typeKey, Type typeValue)
{
bool flag = typeKey == null;
if (flag)
{
throw new ArgumentNullException("type_key", "Argument cannot be null.");
}
bool flag2 = typeValue == null;
if (flag2) { throw new ArgumentNullException("type_value", "Argument cannot be null."); }
ConstructorInfo[] constructors = typeof(Dictionary<,>).MakeGenericType(new Type[] { typeKey, typeValue }).GetConstructors();
foreach (ConstructorInfo constructorInfo in constructors)
{
ParameterInfo[] parameters = constructorInfo.GetParameters();
bool flag3 = parameters.Length != 0;
if (!flag3) { return (IDictionary)constructorInfo.Invoke(null, null); }
}
throw new ApplicationException(string.Concat(new string[] {
"Could not create a new dictionary with types <",
typeKey.ToString(),
",",
typeValue.ToString(),
">."
}));
}
public static T ReflectGetField<T>(Type classType, string fieldName, object o = null)
{
FieldInfo field = classType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
return (T)field.GetValue(o);
}
public static void ReflectSetField<T>(Type classType, string fieldName, T value, object o = null)
{
FieldInfo field = classType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
field.SetValue(o, value);
}
public static T ReflectGetProperty<T>(Type classType, string propName, object o = null, object[] indexes = null)
{
PropertyInfo property = classType.GetProperty(propName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
return (T)property.GetValue(o, indexes);
}
public static void ReflectSetProperty<T>(Type classType, string propName, T value, object o = null, object[] indexes = null)
{
PropertyInfo property = classType.GetProperty(propName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
property.SetValue(o, value, indexes);
}
public static MethodInfo ReflectGetMethod(Type classType, string methodName, Type[] methodArgumentTypes = null, Type[] genericMethodTypes = null, bool? isStatic = null)
{
MethodInfo[] array = ReflectTryGetMethods(classType, methodName, methodArgumentTypes, genericMethodTypes, isStatic);
bool flag = array.Count() == 0;
if (flag) { throw new MissingMethodException("Cannot reflect method, not found based on input parameters."); }
bool flag2 = array.Count() > 1;
if (flag2) { throw new InvalidOperationException("Cannot reflect method, more than one method matched based on input parameters."); }
return array[0];
}
public static MethodInfo ReflectTryGetMethod(Type classType, string methodName, Type[] methodArgumentTypes = null, Type[] genericMethodTypes = null, bool? isStatic = null)
{
MethodInfo[] array = ReflectTryGetMethods(classType, methodName, methodArgumentTypes, genericMethodTypes, isStatic);
bool flag = array.Count() == 0;
MethodInfo result;
if (flag)
{
result = null;
}
else
{
bool flag2 = array.Count() > 1;
if (flag2) { result = null; } else { result = array[0]; }
}
return result;
}
public static MethodInfo[] ReflectTryGetMethods(Type classType, string methodName, Type[] methodArgumentTypes = null, Type[] genericMethodTypes = null, bool? isStatic = null)
{
BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic;
bool flag = isStatic == null || isStatic.Value;
if (flag) { bindingFlags |= BindingFlags.Static; }
bool flag2 = isStatic == null || !isStatic.Value;
if (flag2) { bindingFlags |= BindingFlags.Instance; }
MethodInfo[] methods = classType.GetMethods(bindingFlags);
List<MethodInfo> list = new List<MethodInfo>();
for (int i = 0; i < methods.Length; i++)
{
// foreach (MethodInfo methodInfo in methods) {
bool flag3 = methods[i].Name != methodName;
if (!flag3)
{
bool isGenericMethodDefinition = methods[i].IsGenericMethodDefinition;
if (isGenericMethodDefinition)
{
bool flag4 = genericMethodTypes == null || genericMethodTypes.Length == 0;
if (flag4) { goto IL_14D; }
Type[] genericArguments = methods[i].GetGenericArguments();
bool flag5 = genericArguments.Length != genericMethodTypes.Length;
if (flag5) { goto IL_14D; }
methods[i] = methods[i].MakeGenericMethod(genericMethodTypes);
}
else
{
bool flag6 = genericMethodTypes != null && genericMethodTypes.Length != 0;
if (flag6) { goto IL_14D; }
}
ParameterInfo[] parameters = methods[i].GetParameters();
bool flag7 = methodArgumentTypes != null;
if (!flag7) { goto IL_141; }
bool flag8 = parameters.Length != methodArgumentTypes.Length;
if (!flag8)
{
for (int j = 0; j < parameters.Length; j++)
{
ParameterInfo parameterInfo = parameters[j];
bool flag9 = parameterInfo.ParameterType != methodArgumentTypes[j];
if (flag9) { goto IL_14A; }
}
goto IL_141;
}
IL_14A:
goto IL_14D;
IL_141:
list.Add(methods[i]);
}
IL_14D:;
}
return list.ToArray();
}
public static object InvokeRefs<T0>(MethodInfo methodInfo, object o, T0 p0)
{
object[] parameters = new object[] { p0 };
return methodInfo.Invoke(o, parameters);
}
public static object InvokeRefs<T0>(MethodInfo methodInfo, object o, ref T0 p0)
{
object[] array = new object[] { p0 };
object result = methodInfo.Invoke(o, array);
p0 = (T0)array[0];
return result;
}
public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, T0 p0, T1 p1)
{
object[] parameters = new object[] { p0, p1 };
return methodInfo.Invoke(o, parameters);
}
public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, ref T0 p0, T1 p1)
{
object[] array = new object[] { p0, p1 };
object result = methodInfo.Invoke(o, array);
p0 = (T0)array[0];
return result;
}
public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, T0 p0, ref T1 p1)
{
object[] array = new object[] { p0, p1 };
object result = methodInfo.Invoke(o, array);
p1 = (T1)array[1];
return result;
}
public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, ref T0 p0, ref T1 p1)
{
object[] array = new object[] { p0, p1 };
object result = methodInfo.Invoke(o, array);
p0 = (T0)array[0];
p1 = (T1)array[1];
return result;
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, T1 p1, T2 p2)
{
object[] parameters = new object[] { p0, p1, p2 };
return methodInfo.Invoke(o, parameters);
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, T1 p1, T2 p2)
{
object[] array = new object[] { p0, p1, p2 };
object result = methodInfo.Invoke(o, array);
p0 = (T0)array[0];
return result;
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, ref T1 p1, T2 p2)
{
object[] array = new object[] { p0, p1, p2 };
object result = methodInfo.Invoke(o, array);
p1 = (T1)array[1];
return result;
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, T1 p1, ref T2 p2)
{
object[] array = new object[] { p0, p1, p2 };
object result = methodInfo.Invoke(o, array);
p2 = (T2)array[2];
return result;
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, ref T1 p1, T2 p2)
{
object[] array = new object[] { p0, p1, p2 };
object result = methodInfo.Invoke(o, array);
p0 = (T0)array[0];
p1 = (T1)array[1];
return result;
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, T1 p1, ref T2 p2)
{
object[] array = new object[] { p0, p1, p2 };
object result = methodInfo.Invoke(o, array);
p0 = (T0)array[0];
p2 = (T2)array[2];
return result;
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, ref T1 p1, ref T2 p2)
{
object[] array = new object[] { p0, p1, p2 };
object result = methodInfo.Invoke(o, array);
p1 = (T1)array[1];
p2 = (T2)array[2];
return result;
}
public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, ref T1 p1, ref T2 p2)
{
object[] array = new object[] { p0, p1, p2 };
object result = methodInfo.Invoke(o, array);
p0 = (T0)array[0];
p1 = (T1)array[1];
p2 = (T2)array[2];
return result;
}
}
Now we create ModRoomPrefabs paste in:
public static PrototypeDungeonRoom Mod_Entrance_Room;
public static PrototypeDungeonRoom Mod_Exit_Room;
public static PrototypeDungeonRoom[] Mod_Rooms;
public static PrototypeDungeonRoom Mod_Boss;
public static List<string> Mod_RoomList; // this will contain all of our mods rooms.
this is basically a list of all of our mods rooms, with some special ones being seperate.
now we make an init method:
public static void InitCustomRooms()
{
Mod_RoomList = new List<string>() {
//the names of all of our rooms once we make them.
};
// Mod_Entrance_Room = RoomFactory.BuildFromResource("Mod/Resources/ModRooms/floorEntrance.room");
// Mod_Exit_Room = RoomFactory.BuildFromResource("Mod/Resources/ModRooms/floorExit.room");
List<PrototypeDungeonRoom> m_floorNameRooms = new List<PrototypeDungeonRoom>();
foreach (string name in Mod_RoomList)
{
PrototypeDungeonRoom m_room = RoomFactory.BuildFromResource("mod/Resources/ModRooms/" + name);
m_floorNameRooms.Add(m_room);
}
Mod_Rooms = m_floorNameRooms.ToArray();
foreach (PrototypeDungeonRoom room in Mod_Rooms)
{
ModPrefabs.FloorNameRoomTable.includedRooms.elements.Add(GenerateWeightedRoom(room, 1));
}
Mod_Boss = RoomFactory.BuildFromResource("mod/Resources/ModRooms/BossRoom.room");
Mod_Boss.category = PrototypeDungeonRoom.RoomCategory.BOSS;
Mod_Boss.subCategoryBoss = PrototypeDungeonRoom.RoomBossSubCategory.FLOOR_BOSS;
Mod_Boss.subCategoryNormal = PrototypeDungeonRoom.RoomNormalSubCategory.COMBAT;
Mod_Boss.subCategorySpecial = PrototypeDungeonRoom.RoomSpecialSubCategory.STANDARD_SHOP;
Mod_Boss.subCategorySecret = PrototypeDungeonRoom.RoomSecretSubCategory.UNSPECIFIED_SECRET;
Mod_Boss.roomEvents = new List<RoomEventDefinition>() {
new RoomEventDefinition(RoomEventTriggerCondition.ON_ENTER_WITH_ENEMIES, RoomEventTriggerAction.SEAL_ROOM),
new RoomEventDefinition(RoomEventTriggerCondition.ON_ENEMIES_CLEARED, RoomEventTriggerAction.UNSEAL_ROOM),
};
Mod_Boss.associatedMinimapIcon = ModPrefabs.doublebeholsterroom01.associatedMinimapIcon;
Mod_Boss.usesProceduralLighting = false;
Mod_Boss.usesProceduralDecoration = false;
Mod_Boss.rewardChestSpawnPosition = new IntVector2(25, 20); //Where the reward pedestal spawns, should be changed based on room size
Mod_Boss.overriddenTilesets = GlobalDungeonData.ValidTilesets.JUNGLEGEON;
//foreach (PrototypeRoomExit exit in Mod_Boss.exitData.exits) { exit.exitType = PrototypeRoomExit.ExitType.ENTRANCE_ONLY; }
// RoomBuilder.AddExitToRoom(Mod_Boss, new Vector2(26, 37), DungeonData.Direction.NORTH, PrototypeRoomExit.ExitType.EXIT_ONLY, PrototypeRoomExit.ExitGroup.B);
}
public static WeightedRoom GenerateWeightedRoom(PrototypeDungeonRoom Room, float Weight = 1, bool LimitedCopies = true, int MaxCopies = 1, DungeonPrerequisite[] AdditionalPrerequisites = null)
{
if (Room == null) { return null; }
if (AdditionalPrerequisites == null) { AdditionalPrerequisites = new DungeonPrerequisite[0]; }
return new WeightedRoom() { room = Room, weight = Weight, limitedCopies = LimitedCopies, maxCopies = MaxCopies, additionalPrerequisites = AdditionalPrerequisites };
}
most of the commented-out things will be uncommented when we get to making rooms.
Last updated