diff --git a/S1API/Console/ConsoleHelper.cs b/S1API/Console/ConsoleHelper.cs index 0544df16..d00c8915 100644 --- a/S1API/Console/ConsoleHelper.cs +++ b/S1API/Console/ConsoleHelper.cs @@ -1,10 +1,21 @@ #if (IL2CPPMELON) -using Il2CppSystem.Collections.Generic; using static Il2CppScheduleOne.Console; -#else +using Il2CppScheduleOne.Employees; +using Il2CppScheduleOne.ItemFramework; +using Il2CppSystem.Collections.Generic; +#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX) using static ScheduleOne.Console; using System.Collections.Generic; +using ScheduleOne.Employees; +using ScheduleOne.ItemFramework; #endif +using S1API.Entities; +using S1API.Internal.Utils; +using S1API.Products.Packaging; +using S1API.Property; +using S1API.Quests.Constants; +using S1API.Vehicles; +using System.Globalization; namespace S1API.Console { @@ -13,6 +24,480 @@ namespace S1API.Console /// public static class ConsoleHelper { + /// + /// Adds an employee to a property. + /// This method works across both IL2CPP and Mono builds. + /// + /// The type of employee. + /// The property to add the employee to. You must own the property. + public static void AddEmployeeToProperty(EEmployeeType employeeType, PropertyType propertyName) + { + var command = new AddEmployeeCommand(); + var args = new List(); + + args.Add(employeeType.ToString()); + args.Add(propertyName.ToString()); + + command.Execute(args); + } + + /// + /// Adds an item, with optional quantity, to the player's inventory. + /// This method works across both IL2CPP and Mono builds. + /// + /// The name of the item. + /// The amount to add to inventory. Optional. + public static void AddItemToInventory(string itemName, int? amount = null) + { + var command = new AddItemToInventoryCommand(); + var args = new List(); + + args.Add(itemName); + if (amount.HasValue) + { + args.Add(amount.ToString()!); + } + + command.Execute(args); + } + + /// + /// Sets the player's bank balance to the given amount. + /// This method works across both IL2CPP and Mono builds. + /// + /// The amount to set the player's bank balance to. + public static void SetOnlineBalance(int amount) + { + var command = new ChangeOnlineBalanceCommand(); + var args = new List(); + + args.Add(amount.ToString()); + + command.Execute(args); + } + + /// + /// Clears the player's inventory. + /// This method works across both IL2CPP and Mono builds. + /// + public static void ClearInventory() + { + var command = new ClearInventoryCommand(); + var args = new List(); + + command.Execute(args); + } + + /// + /// Clears all trash from the world. + /// This method works across both IL2CPP and Mono builds. + /// + public static void ClearTrash() + { + var command = new ClearTrash(); + var args = new List(); + + command.Execute(args); + } + + /// + /// Clears the player's wanted level. + /// This method works across both IL2CPP and Mono builds. + /// + public static void ClearWanted() + { + var command = new ClearWanted(); + var args = new List(); + + command.Execute(args); + } + + /// + /// Adds the given amount of XP to the player. + /// This method works across both IL2CPP and Mono builds. + /// + /// The amount of XP to give. Must be a non-negative amount. + public static void GiveXp(int amount) + { + var command = new GiveXP(); + var args = new List(); + + args.Add(amount.ToString()); + + command.Execute(args); + } + + /// + /// Instantly sets all plants in the world to fully grown. + /// This method works across both IL2CPP and Mono builds. + /// + public static void GrowPlants() + { + var command = new GrowPlants(); + var args = new List(); + + command.Execute(args); + } + + /// + /// Lower the player's wanted level. + /// This method works across both IL2CPP and Mono builds. + /// + public static void LowerWanted() + { + var command = new LowerWanted(); + var args = new List(); + + command.Execute(args); + } + + /// + /// Packages the currently equipped item into the specified package type. + /// This method works across both IL2CPP and Mono builds. + /// + /// This method can convert between package types. It can change baggies to jars, baggies to bricks, bricks to baggies, etc. + /// The type of packaging to package the product as. + public static void PackageSelectedProduct(PackageType packageType) + { + var command = new PackageProduct(); + var args = new List(); + + args.Add(packageType.ToString()); + + command.Execute(args); + } + + /// + /// Raise the player's wanted level. + /// This method works across both IL2CPP and Mono builds. + /// + public static void RaiseWanted() + { + var command = new RaisedWanted(); + var args = new List(); + + command.Execute(args); + } + + /// + /// Saves the player's game. + /// This method works across both IL2CPP and Mono builds. + /// + public static void SaveGame() + { + var command = new Save(); + var args = new List(); + + command.Execute(args); + } + + /// + /// Sets a product as discovered. + /// This method works across both IL2CPP and Mono builds. + /// + public static void DiscoverProduct(string productName) + { + var command = new SetDiscovered(); + var args = new List(); + + args.Add(productName); + + command.Execute(args); + } + + /// + /// Sets the player's energy level. + /// This method works across both IL2CPP and Mono builds. + /// + /// The level of energy to set to. Range is 0 to 100. + public static void SetPlayerEnergyLevel(float amount) + { + var command = new SetEnergy(); + var args = new List(); + + args.Add(amount.ToString(CultureInfo.InvariantCulture)); + + command.Execute(args); + } + + /// + /// Sets the player's health. + /// This method works across both IL2CPP and Mono builds. + /// + /// The health value to set to. + public static void SetPlayerHealth(float amount) + { + var command = new SetHealth(); + var args = new List(); + + args.Add(amount.ToString(CultureInfo.InvariantCulture)); + + command.Execute(args); + } + + /// + /// Sets the player's jump multiplier. + /// This method works across both IL2CPP and Mono builds. + /// + /// The multiplier to set to. Must be non-negative. + public static void SetPlayerJumpMultiplier(float amount) + { + var command = new SetJumpMultiplier(); + var args = new List(); + + args.Add(amount.ToString(CultureInfo.InvariantCulture)); + + command.Execute(args); + } + + /// + /// Sets the intensity of law enforcement activity. + /// This method works across both IL2CPP and Mono builds. + /// + /// The level of activity. Ranges from 0 to 10. + public static void SetLawIntensity(float amount) + { + var command = new SetLawIntensity(); + var args = new List(); + + args.Add(amount.ToString(CultureInfo.InvariantCulture)); + + command.Execute(args); + } + + /// + /// Sets the player's move speed multiplier. + /// This method works across both IL2CPP and Mono builds. + /// + /// The multiplier to set to. Must be non-negative. + public static void SetPlayerMoveSpeedMultiplier(float amount) + { + var command = new SetMoveSpeedCommand(); + var args = new List(); + + args.Add(amount.ToString(CultureInfo.InvariantCulture)); + + command.Execute(args); + } + + /// + /// Sets a business as owned. + /// This method works across both IL2CPP and Mono builds. + /// + /// The business to set as owned. + public static void SetBusinessAsOwned(BusinessType business) + { + var command = new SetPropertyOwned(); + var args = new List(); + + args.Add(business.ToString()); + + command.Execute(args); + } + + /// + /// Sets a property as owned. + /// This method works across both IL2CPP and Mono builds. + /// + /// The property to set as owned. + public static void SetPropertyAsOwned(PropertyType property) + { + var command = new SetPropertyOwned(); + var args = new List(); + + args.Add(property.ToString()); + + command.Execute(args); + } + + /// + /// Sets the equipped product's quality. + /// This method works across both IL2CPP and Mono builds. + /// + /// The quality to set the current equipped item to. + public static void SetQuality(EQuality quality) + { + var command = new SetQuality(); + var args = new List(); + + args.Add(quality.ToString()); + + command.Execute(args); + } + + /// + /// Sets the state for a given quest. + /// This method works across both IL2CPP and Mono builds. + /// + /// The quest to set the state for. + /// The state to set for the quest. + public static void SetQuestState(string quest, QuestState state) + { + var command = new SetQuestState(); + var args = new List(); + + args.Add(quest); + args.Add(state.ToString()); + + command.Execute(args); + } + + /// + /// Sets the state for a given quest. + /// This method works across both IL2CPP and Mono builds. + /// + /// The quest to set the state for. + /// The state to set for the quest. + public static void SetQuestState(VanillaQuest quest, QuestState state) + { + var command = new SetQuestState(); + var args = new List(); + + args.Add(quest.GetDescriptionValue()); + args.Add(state.ToString()); + + command.Execute(args); + } + + /// + /// Sets the relationship for a given NPC. + /// This method works across both IL2CPP and Mono builds. + /// + /// The ID of the NPC to set the relationship for. + /// The relationship value to set. Must be between 0 and 5 inclusive. + public static void SetNpcRelationship(string npcId, float level) + { + var command = new SetRelationship(); + var args = new List(); + + args.Add(npcId); + args.Add(level.ToString(CultureInfo.InvariantCulture)); + + command.Execute(args); + } + + /// + /// Sets the relationship for a given NPC. + /// This method works across both IL2CPP and Mono builds. + /// + /// The NPC to set the relationship for. + /// The relationship value to set. Must be between 0 and 5 inclusive. + public static void SetNpcRelationship(NPC npc, float level) + { + var command = new SetRelationship(); + var args = new List(); + + args.Add(npc.ID); + args.Add(level.ToString(CultureInfo.InvariantCulture)); + + command.Execute(args); + } + + /// + /// Sets the time. + /// This method works across both IL2CPP and Mono builds. + /// + /// The time to set. Requires a valid value with Regex ^([01]?[0-9]|2[0-3])[0-5][0-9]$ (e.g. 1530 for 15:30 / 3:30 PM) + public static void SetTime(string time) + { + var command = new SetTimeCommand(); + var args = new List(); + + args.Add(time); + + command.Execute(args); + } + + /// + /// Spawns a vehicle at the player's location. + /// This method works across both IL2CPP and Mono builds. + /// + /// The vehicle to spawn. + public static void SpawnVehicle(string vehicle) + { + var command = new SpawnVehicleCommand(); + var args = new List(); + + args.Add(vehicle); + + command.Execute(args); + } + + /// + /// Spawns a vehicle at the player's location. + /// This method works across both IL2CPP and Mono builds. + /// + /// The vehicle to spawn. + public static void SpawnVehicle(VanillaVehicleList vehicle) + { + var command = new SpawnVehicleCommand(); + var args = new List(); + + args.Add(vehicle.ToString()); + + command.Execute(args); + } + + /// + /// Unlocks the connection for the given NPC. + /// This method works across both IL2CPP and Mono builds. + /// + /// The ID of the NPC to set the relationship for. + public static void UnlockNpc(string npcId) + { + var command = new SetUnlocked(); + var args = new List(); + + args.Add(npcId); + + command.Execute(args); + } + + /// + /// Unlocks the connection for the given NPC. + /// This method works across both IL2CPP and Mono builds. + /// + /// The NPC to set the relationship for. + public static void UnlockNpc(NPC npc) + { + var command = new SetUnlocked(); + var args = new List(); + + args.Add(npc.ID); + + command.Execute(args); + } + + /// + /// Teleport to a business. + /// This method works across both IL2CPP and Mono builds. + /// + /// The business to teleport to. + public static void TeleportToBusiness(BusinessType business) + { + var command = new Teleport(); + var args = new List(); + + args.Add(business.ToString()); + + command.Execute(args); + } + + /// + /// Teleport to a property. + /// This method works across both IL2CPP and Mono builds. + /// + /// The property to teleport to. + public static void TeleportToProperty(PropertyType property) + { + var command = new Teleport(); + var args = new List(); + + args.Add(property.ToString()); + + command.Execute(args); + } + /// /// Executes the ChangeCashCommand with the given amount. /// This method works across both IL2CPP and Mono builds. @@ -20,13 +505,9 @@ public static class ConsoleHelper /// The cash amount to add or remove. public static void RunCashCommand(int amount) { -#if (IL2CPPMELON || IL2CPPBEPINEX) - var command = new ChangeCashCommand(); - var args = new Il2CppSystem.Collections.Generic.List(); -#else var command = new ChangeCashCommand(); var args = new List(); -#endif + args.Add(amount.ToString()); command.Execute(args); } diff --git a/S1API/Internal/Utils/EnumUtils.cs b/S1API/Internal/Utils/EnumUtils.cs new file mode 100644 index 00000000..505e0815 --- /dev/null +++ b/S1API/Internal/Utils/EnumUtils.cs @@ -0,0 +1,24 @@ +using System; +using System.ComponentModel; +using System.Reflection; + +namespace S1API.Internal.Utils +{ + /// + /// A set of utility methods when working with enums. + /// + internal static class EnumUtils + { + /// + /// Gets the value of the Description attribute for an enum value. + /// + /// The enum value + /// The description string or the enum value's name if no description is found + internal static string GetDescriptionValue(this Enum value) + { + var fieldInfo = value.GetType().GetField(value.ToString()); + var attribute = fieldInfo?.GetCustomAttribute(); + return attribute?.Description ?? value.ToString(); + } + } +} diff --git a/S1API/Products/Packaging/PackageType.cs b/S1API/Products/Packaging/PackageType.cs new file mode 100644 index 00000000..8f91b38b --- /dev/null +++ b/S1API/Products/Packaging/PackageType.cs @@ -0,0 +1,21 @@ +namespace S1API.Products.Packaging +{ + /// + /// The types of packages + /// + public enum PackageType + { + /// + /// The baggie package type. + /// + Baggie, + /// + /// The brick package type. + /// + Brick, + /// + /// The jar package type. + /// + Jar + } +} diff --git a/S1API/Property/PropertyType.cs b/S1API/Property/PropertyType.cs new file mode 100644 index 00000000..c59e4ef0 --- /dev/null +++ b/S1API/Property/PropertyType.cs @@ -0,0 +1,64 @@ +namespace S1API.Property +{ + /// + /// The types of properties in the game. + /// + public enum PropertyType + { + /// + /// The Barn property. + /// + Barn, + /// + /// The Bungalow property. + /// + Bungalow, + /// + /// The Docks property. + /// + DocksWarehouse, + /// + /// The Manor property. + /// + Manor, + /// + /// The Motel Room property. + /// + MotelRoom, + /// + /// The RV property. + /// + Rv, + /// + /// The Storage Unit property. + /// + StorageUnit, + /// + /// The Sweatshop property + /// + Sweatshop + } + + /// + /// The types of businesses in the game. + /// + public enum BusinessType + { + /// + /// The Car Wash business. + /// + CarWash, + /// + /// The Laundromat business. + /// + Laundromat, + /// + /// The Post Office business. + /// + PostOffice, + /// + /// The Taco Ticklers business. + /// + TacoTicklers, + } +} diff --git a/S1API/Quests/Constants/VanillaQuest.cs b/S1API/Quests/Constants/VanillaQuest.cs new file mode 100644 index 00000000..d7b2c560 --- /dev/null +++ b/S1API/Quests/Constants/VanillaQuest.cs @@ -0,0 +1,106 @@ +using System.ComponentModel; + +namespace S1API.Quests.Constants +{ + /// + /// The list of quests in vanilla. + /// + public enum VanillaQuest + { + /// + /// The Botanists quest + /// + [Description("Botanists")] + Botanists, + /// + /// The Chemists quest + /// + [Description("Chemists")] + Chemists, + /// + /// The Clean Cash quest + /// + [Description("Clean Cash")] + Clean_Cash, + /// + /// The Cleaners quest + /// + [Description("Cleaners")] + Cleaners, + /// + /// The Dodgy Dealing quest + /// + [Description("Dodgy Dealing")] + Dodgy_Dealing, + /// + /// The Gearing Up quest + /// + [Description("Gearing Up")] + Gearing_Up, + /// + /// The Getting Started quest + /// + [Description("Getting Started")] + Getting_Started, + /// + /// The Keeping it Fresh quest + /// + [Description("Keeping it Fresh")] + Keeping_it_Fresh, + /// + /// The Making the Rounds quest + /// + [Description("Making the Rounds")] + Making_the_Rounds, + /// + /// The Mixing Mania quest + /// + [Description("Mixing Mania")] + Mixing_Mania, + /// + /// The Money Management quest + /// + [Description("Money Management")] + Money_Management, + /// + /// The Moving Up quest + /// + [Description("Moving Up")] + Moving_Up, + /// + /// The Needin' the Green quest + /// + [Description("Needin' the Green")] + NeedinTheGreen, + /// + /// The On the Grind quest + /// + [Description("On the Grind")] + On_the_Grind, + /// + /// The Packagers quest + /// + [Description("Packagers")] + Packagers, + /// + /// The Packin' quest + /// + [Description("Packin'")] + Packin, + /// + /// The We Need To Cook quest + /// + [Description("We Need To Cook")] + We_Need_To_Cook, + /// + /// The Welcome to Hyland Point quest + /// + [Description("Welcome to Hyland Point")] + Welcome_to_Hyland_Point, + /// + /// The Wretched Hive of Scum and Villainy quest + /// + [Description("Wretched Hive of Scum and Villainy")] + Wretched_Hive_of_Scum_and_Villainy, + } +} diff --git a/S1API/S1API.csproj b/S1API/S1API.csproj index 85a23c63..dd27e717 100644 --- a/S1API/S1API.csproj +++ b/S1API/S1API.csproj @@ -2,7 +2,11 @@ - + + + + diff --git a/S1API/Vehicles/VanillaVehicleList.cs b/S1API/Vehicles/VanillaVehicleList.cs new file mode 100644 index 00000000..991afcbf --- /dev/null +++ b/S1API/Vehicles/VanillaVehicleList.cs @@ -0,0 +1,33 @@ +namespace S1API.Vehicles +{ + /// + /// The vehicles available in vanilla. + /// + public enum VanillaVehicleList + { + /// + /// The Bruiser vehicle. + /// + Bruiser, + /// + /// The Cheetah vehicle. + /// + Cheetah, + /// + /// The Dinkler vehicle. + /// + Dinkler, + /// + /// The Hounddog vehicle. + /// + Hounddog, + /// + /// The Shitbox vehicle. + /// + Shitbox, + /// + /// The Veeper vehicle. + /// + Veeper, + } +} diff --git a/S1APILoader/S1APILoader.csproj b/S1APILoader/S1APILoader.csproj index b664e6a4..0d3ad75a 100644 --- a/S1APILoader/S1APILoader.csproj +++ b/S1APILoader/S1APILoader.csproj @@ -2,7 +2,11 @@ - + + + + @@ -12,7 +16,7 @@ AnyCPU S1APILoader - + $(MelonLoaderAssembliesPath)\0Harmony.dll diff --git a/thunderstore.build.props b/thunderstore.build.props new file mode 100644 index 00000000..8fca05f0 --- /dev/null +++ b/thunderstore.build.props @@ -0,0 +1,35 @@ + + + + + + + + + + true + + + $(AppData)\Thunderstore Mod Manager\DataFolder\ScheduleI\profiles\Default\MelonLoader\net6 + TBD + + + + + $(AppData)\Thunderstore Mod Manager\DataFolder\ScheduleI\profiles\Default + + + C:\Program Files (x86)\Steam\steamapps\common\Schedule I\Schedule I_Data\Managed + + + + + $(AppData)\Thunderstore Mod Manager\DataFolder\ScheduleI\profiles\Default + + + $(AppData)\Thunderstore Mod Manager\DataFolder\ScheduleI\profiles\Default\MelonLoader\Il2CppAssemblies + + + TBD + +