Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions .github/workflows/deploy-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
permissions:
contents: write
id-token: write

steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand All @@ -26,7 +26,7 @@ jobs:

- name: Restore .NET dependencies
run: dotnet restore

# Install Node.js and semantic-release
- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down Expand Up @@ -56,12 +56,11 @@ jobs:
sed -i "s/{VERSION_NUMBER}/${{ steps.semantic-release.outputs.new_release_version }}/" ./S1API/S1API.cs
sed -i "s/{VERSION_NUMBER}/${{ steps.semantic-release.outputs.new_release_version }}/" ./S1APILoader/S1APILoader.cs

# TODO (@MaxtorCoder): Temporarily disabling until BepInEx is building properly locally.
# - name: Run .NET build for MonoBepInEx
# run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1
#
# - name: Run .NET build for Il2CppBepInEx
# run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0
- name: Run .NET build for MonoBepInEx
run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1

- name: Run .NET build for Il2CppBepInEx
run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0

- name: Run .NET build for MonoMelon
run: dotnet build ./S1API.sln -c MonoMelon -f netstandard2.1
Expand All @@ -71,14 +70,13 @@ jobs:

- name: Build artifact zip for Thunderstore
run: |
mkdir -p ./artifacts/thunderstore/Plugins
mkdir -p ./artifacts/thunderstore/Mods
cp ./S1APILoader/bin/MonoMelon/netstandard2.1/S1APILoader.dll ./artifacts/thunderstore/Plugins/S1APILoader.dll
mkdir -p ./artifacts/thunderstore/Plugins/S1API
cp ./S1APILoader/bin/MonoMelon/netstandard2.1/S1APILoader.dll ./artifacts/thunderstore/Plugins/S1APILoader.MelonLoader.dll
cp ./S1APILoader/bin/MonoBepInEx/netstandard2.1/S1APILoader.dll ./artifacts/thunderstore/Plugins/S1APILoader.BepInEx.dll
cp ./S1API/bin/Il2CppMelon/net6.0/S1API.dll ./artifacts/thunderstore/Mods/S1API.Il2Cpp.MelonLoader.dll
cp ./S1API/bin/MonoMelon/netstandard2.1/S1API.dll ./artifacts/thunderstore/Mods/S1API.Mono.MelonLoader.dll
# cp ./S1APILoader/bin/MonoBepInEx/netstandard2.1/S1APILoader.dll ./artifacts/thunderstore/Plugins/S1APILoader.BepInEx.dll
# cp ./S1API/bin/Il2CppMelon/net6.0/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Il2Cpp.BepInEx.dll
# cp ./S1API/bin/MonoMelon/netstandard2.1/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Mono.BepInEx.dll
cp ./S1API/bin/Il2CppBepInEx/net6.0/S1API.dll ./artifacts/thunderstore/Mods/S1API.Il2Cpp.BepInEx.dll
cp ./S1API/bin/MonoBepInEx/netstandard2.1/S1API.dll ./artifacts/thunderstore/Mods/S1API.Mono.BepInEx.dll

- name: Publish artifact to Thunderstore
uses: GreenTF/upload-thunderstore-package@v4.3
Expand All @@ -98,9 +96,9 @@ jobs:
mono
il2cpp
libraries

- name: Pack NuGet package
run: dotnet pack ./S1API/S1API.csproj -c MonoMelon --output ./nupkg /p:PackageVersion=${{ steps.semantic-release.outputs.new_release_version }}

- name: Push to NuGet Gallery
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
23 changes: 11 additions & 12 deletions .github/workflows/verify-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,29 @@ jobs:
build:
name: Verify Successful Build
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Clone Game Assemblies
run: |
git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/KaBooMa/ScheduleOneAssemblies.git ./ScheduleOneAssemblies

- name: Setup .NET
uses: actions/setup-dotnet@v4

- name: Restore .NET Dependencies
run: dotnet restore

# TODO (@MaxtorCoder): Temporarily disabling until BepInEx is building properly locally.
# - name: Run .NET build for MonoBepInEx
# run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1
#
# - name: Run .NET build for Il2CppBepInEx
# run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0

- name: Run .NET build for MonoBepInEx
run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1

- name: Run .NET build for Il2CppBepInEx
run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0

- name: Run .NET build for MonoMelon
run: dotnet build ./S1API.sln -c MonoMelon -f netstandard2.1

- name: Run .NET build for Il2CppMelon
run: dotnet build ./S1API.sln -c Il2CppMelon -f net6.0
run: dotnet build ./S1API.sln -c Il2CppMelon -f net6.0
137 changes: 137 additions & 0 deletions S1API/Conditionals/SystemTriggerEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#if (IL2CPPMELON)
using S1Quests = Il2CppScheduleOne.Quests;
using S1Variables = Il2CppScheduleOne.Variables;
using static Il2CppScheduleOne.Quests.QuestManager;
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
using S1Quests = ScheduleOne.Quests;
using S1Variables = ScheduleOne.Variables;
using static ScheduleOne.Quests.QuestManager;
#endif

using System;
using S1API.Internal.Abstraction;
using S1API.Internal.Utils;
using S1API.PhoneCalls.Constants;
using S1API.Quests;
using S1API.Quests.Constants;

namespace S1API.Conditions
{
/// <summary>
/// @TODO: DOCS
/// </summary>
public class SystemTriggerEntry
{
/// <summary>
/// INTERNAL: The stored reference to the system trigger in-game.
/// </summary>
internal readonly S1Quests.SystemTrigger S1SystemTrigger;

/// <summary>
/// An action called when the <see cref="S1Quests.SystemTrigger.Conditions"/> is true
/// </summary>
public event Action OnEvaluateTrue
{
add => EventHelper.AddListener(value, S1SystemTrigger.onEvaluateTrue);
remove => EventHelper.RemoveListener(value, S1SystemTrigger.onEvaluateTrue);
}

/// <summary>
/// An action called when the <see cref="S1Quests.SystemTrigger.Conditions"/> is false
/// </summary>
public event Action OnEvaluateFalse
{
add => EventHelper.AddListener(value, S1SystemTrigger.onEvaluateFalse);
remove => EventHelper.RemoveListener(value, S1SystemTrigger.onEvaluateFalse);
}

/// <summary>
/// INTERNAL: Creates a system trigger from an in-game system trigger instance.
/// </summary>
/// <param name="systemTrigger"></param>
internal SystemTriggerEntry(S1Quests.SystemTrigger systemTrigger)
{
S1SystemTrigger = systemTrigger;

// Set any null values, blame runtime coding setting all of these items to null :/
S1SystemTrigger.Conditions = new S1Variables.Conditions();
S1SystemTrigger.Conditions.ConditionList ??= Array.Empty<S1Variables.Condition>();
S1SystemTrigger.Conditions.QuestConditionList ??= Array.Empty<S1Variables.QuestCondition>();

S1SystemTrigger.onEvaluateTrueVariableSetters ??= Array.Empty<S1Variables.VariableSetter>();
S1SystemTrigger.onEvaluateFalseVariableSetters ??= Array.Empty<S1Variables.VariableSetter>();

S1SystemTrigger.onEvaluateTrueQuestSetters ??= Array.Empty<S1Quests.QuestStateSetter>();
S1SystemTrigger.onEvaluateFalseQuestSetters ??= Array.Empty<S1Quests.QuestStateSetter>();
}

/// <summary>
/// Creates a <see cref="S1Variables.VariableSetter"/> instance
/// </summary>
/// <param name="evaluation">The condition to use</param>
/// <param name="variableName">The variable to use</param>
/// <param name="newValue">The new value for this variable</param>
public void AddVariableSetter(EvaluationType evaluation, string variableName, string newValue)
{
S1Variables.VariableSetter variableSetter = new S1Variables.VariableSetter
{
VariableName = variableName,
NewValue = newValue
};

switch (evaluation)
{
case EvaluationType.PassOnTrue:
S1SystemTrigger.onEvaluateTrueVariableSetters = S1SystemTrigger.onEvaluateTrueVariableSetters.AddItemToArray(variableSetter);
break;
case EvaluationType.PassOnFalse:
S1SystemTrigger.onEvaluateFalseVariableSetters = S1SystemTrigger.onEvaluateFalseVariableSetters.AddItemToArray(variableSetter);
break;
}
}

/// <summary>
/// Creates a <see cref="S1Quests.QuestStateSetter"/> instance
/// </summary>
/// <param name="evaluation">The condition to use</param>
/// <param name="questData">The <see cref="Quest"/> instance to use for this condition</param>
/// <param name="questAction">(Optional) The state of the quest</param>
/// <param name="questEntryState">(Optional) The state of the quest entry</param>
public void AddQuestSetter(EvaluationType evaluation, Quest questData,
QuestAction? questAction = null, Tuple<int, QuestState>? questEntryState = null)
{
S1Quests.QuestStateSetter questStateSetter = new S1Quests.QuestStateSetter
{
QuestName = questData.S1Quest.Title,
};

if (questAction.HasValue)
{
questStateSetter.SetQuestState = true;
questStateSetter.QuestState = (EQuestAction)questAction.Value;
}

if (questEntryState != null)
{
questStateSetter.SetQuestEntryState = true;
questStateSetter.QuestEntryIndex = questEntryState.Item1;
questStateSetter.QuestEntryState = (S1Quests.EQuestState)questEntryState.Item2;
}

switch (evaluation)
{
case EvaluationType.PassOnTrue:
S1SystemTrigger.onEvaluateTrueQuestSetters = S1SystemTrigger.onEvaluateTrueQuestSetters.AddItemToArray(questStateSetter);
break;
case EvaluationType.PassOnFalse:
S1SystemTrigger.onEvaluateFalseQuestSetters = S1SystemTrigger.onEvaluateFalseQuestSetters.AddItemToArray(questStateSetter);
break;
}
}

/// <summary>
/// Trigger the conditions for evaluation
/// </summary>
public void Trigger() => S1SystemTrigger.Trigger();
}
}
4 changes: 2 additions & 2 deletions S1API/Console/ConsoleHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if (IL2CPPMELON || IL2CPPBEPINEX)
#if (IL2CPPMELON)
using Il2CppSystem.Collections.Generic;
using static Il2CppScheduleOne.Console;
#else
Expand Down Expand Up @@ -31,4 +31,4 @@ public static void RunCashCommand(int amount)
command.Execute(args);
}
}
}
}
22 changes: 11 additions & 11 deletions S1API/DeadDrops/DeadDropInstance.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPPMELON || IL2CPPBEPINEX)
#if (IL2CPPMELON)
using S1Economy = Il2CppScheduleOne.Economy;
#elif (MONOMELON || MONOBEPINEX)
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
using S1Economy = ScheduleOne.Economy;
#endif

Expand All @@ -20,43 +20,43 @@ public class DeadDropInstance : IGUIDReference
/// INTERNAL: Stores a reference to the game dead drop instance.
/// </summary>
internal readonly S1Economy.DeadDrop S1DeadDrop;

/// <summary>
/// The cached storage instance.
/// </summary>
private StorageInstance? _cachedStorage;

/// <summary>
/// INTERNAL: Instances a new dead drop from the game dead drop instance.
/// </summary>
/// <param name="deadDrop">The game dead drop instance.</param>
internal DeadDropInstance(S1Economy.DeadDrop deadDrop) =>
internal DeadDropInstance(S1Economy.DeadDrop deadDrop) =>
S1DeadDrop = deadDrop;

/// <summary>
/// INTERNAL: Gets a dead drop from a GUID value.
/// </summary>
/// <param name="guid"></param>
/// <returns></returns>
internal static DeadDropInstance? GetFromGUID(string guid) =>
DeadDropManager.All.FirstOrDefault(deadDrop => deadDrop.GUID == guid);

/// <summary>
/// The unique identifier assigned for this dead drop.
/// </summary>
public string GUID =>
public string GUID =>
S1DeadDrop.GUID.ToString();

/// <summary>
/// The storage container associated with this dead drop.
/// </summary>
public StorageInstance Storage =>
public StorageInstance Storage =>
_cachedStorage ??= new StorageInstance(S1DeadDrop.Storage);

/// <summary>
/// The world position of the dead drop.
/// </summary>
public Vector3 Position =>
public Vector3 Position =>
S1DeadDrop.transform.position;
}
}
6 changes: 3 additions & 3 deletions S1API/DeadDrops/DeadDropManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPPMELON || IL2CPPBEPINEX)
#if (IL2CPPMELON)
using S1Economy = Il2CppScheduleOne.Economy;
#elif (MONOMELON || MONOBEPINEX)
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
using S1Economy = ScheduleOne.Economy;
#endif

Expand All @@ -16,7 +16,7 @@ public class DeadDropManager
/// <summary>
/// Gets all dead drops in the scene.
/// </summary>
public static DeadDropInstance[] All =>
public static DeadDropInstance[] All =>
S1Economy.DeadDrop.DeadDrops.ToArray()
.Select(deadDrop => new DeadDropInstance(deadDrop)).ToArray(); }
}
Loading
Loading