Skip to content

Commit

Permalink
Creating workflow. Uploading dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
derekShaheen committed Apr 4, 2024
1 parent 49492dc commit 4e67bb0
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 180 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Stable Build

#on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main
# workflow_run:
# workflows: ["Build Release Project"]
# types: [requested]
# branches:
# - 'release'

env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .

# Configuration type to build.
# You can convert this to a build matrix if you need coverage of multiple configuration types.
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
BUILD_CONFIGURATION: Release

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Add MSBuild to PATH
uses: microsoft/[email protected]

- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}

- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}

# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}

- name: Extract Version
id: extract_version
shell: pwsh
run: |
$assemblyInfoPath = '${{env.SOLUTION_FILE_PATH}}\YourProjectPath\Properties\AssemblyInfo.cs'
$assemblyInfo = Get-Content $assemblyInfoPath
$versionLine = $assemblyInfo | Select-String -Pattern '\[assembly: MelonInfo\(typeof\(.*\), ".*", "(.*)", ".*"\)\]'
$version = $versionLine.Matches.Groups[1].Value
echo "##[set-output name=version;]$version"
- name: Zip release
uses: vimtor/action-zip@v1
with:
files: ${{env.SOLUTION_FILE_PATH}}\bin\Release\net6.0\WickerREST.dll README.md
recursive: true
dest: WickerREST.zip

- name: Publish Release
uses: "marvinpinto/action-automatic-releases@latest"
if: ${{ github.ref == 'refs/heads/main' }}
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ steps.extract_version.outputs.version }}"
prerelease: false
files: |
README.md
WickerREST.zip
287 changes: 142 additions & 145 deletions Commands.cs
Original file line number Diff line number Diff line change
@@ -1,145 +1,142 @@
using HarmonyLib;
using Il2Cpp;
using MelonLoader;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace SkInterface
{
public static class ActiveConfig
{
public static bool isRevealed = false;
public static bool isPlaying = false;
}

public static class CommandActions
{
[CommandHandler("revealMap", "Test")]
public static void RevealMapHttp(HttpListenerResponse response)
{
RevealMap(response);
}

[CommandHandler("ping", "Main")]
public static void PingHttp(HttpListenerResponse response)
{
WickerServer.Instance.LogResponse(response, "Pong!");
}

[CommandHandler("pingg")]
public static void PingHttp2(HttpListenerResponse response)
{
WickerServer.Instance.LogResponse(response, "Pong!");
}

[CommandHandler("inputTest", "Main")]
public static void InputTestHTTP(HttpListenerResponse response, string TestCase, string input = "test", string input2 = "testlols")
{
// Write output of each var
StringBuilder responseContent = new StringBuilder();
// Append output of each var to the response content
responseContent.AppendLine("TestCase: '" + TestCase + "'");
responseContent.AppendLine("input: '" + input + "'");
responseContent.AppendLine("input2: '" + input2 + "'");

// Now send the accumulated response content as one response
WickerServer.Instance.LogResponse(response, responseContent.ToString());
}

[CommandHandler("secondInputTest", "Main")]
public static void InputTest2HTTP(HttpListenerResponse response, string input)
{
WickerServer.Instance.LogResponse(response, "Received:" + " '" + input + "'");
}

[GameVariable("GameReadyToPlay")]
public static string GetGameReadyToPlay()
{
return GameManager.gameReadyToPlay.ToString();
}

[GameVariable("IsGameLoaded")]
public static string GetGameIsLoaded()
{
if (GameManager.Instance != null)
return GameManager.Instance.isLoadedGame.ToString();

return "False";
}
[GameVariable("GameFullyInitialized")]
public static string GetGmeFullyInitialized()
{
return GameManager.gameFullyInitialized.ToString();
}

private static int relicCount = 0;

[GameVariable("FoodProduced")]
public static string GetRelicCount()
{
if (GameManager.Instance == null)
{
return "-1";
}

//if (GameManager.Instance != null && relicCount <= 0)
//{
// var relicResources = UnityEngine.Object.FindObjectsOfType<Villager>();
// relicCount = relicResources.Length;
//}

return GameManager.Instance.villageStats.GetCurrentTrackedFoodProduced().Count.ToString();
}


public static bool IsPlaying { get => ActiveConfig.isPlaying; set => ActiveConfig.isPlaying = value; }
public static bool IsRevealed { get => ActiveConfig.isRevealed; set => ActiveConfig.isRevealed = value; }

private static void RevealMap(HttpListenerResponse response)
{
if (WickerServer.Instance == null)
{
return;
}

if (GameManager.Instance == null || !GameManager.gameFullyInitialized)
{

WickerServer.Instance.LogResponse(response, "Must be in-game to reveal map!");
return;
}

if (GameManager.Instance != null && GameManager.gameFullyInitialized)
{
WickerServer.Instance.LogResponse(response, "Revealing map...");
GameManager.Instance.cameraManager.fogOfWarEffect.mFog.enabled = false;
ActiveConfig.isRevealed = true;

var relicResources = UnityEngine.Object.FindObjectsOfType<RelicExtractionResource>();
foreach (var relic in relicResources)
{
relic.availableForExtraction = true;
}
}
}

[HarmonyPatch(typeof(FOWSystem), "IsExplored")]
class Patch_FOWSystem_IsExplored
{
static bool Prefix(Vector3 pos, ref bool __result)
{
if (ActiveConfig.isRevealed)
{
__result = true; // Set the result to true
return false; // Skip the original method
}
return true; // Continue with the original method
}
}
}
}
//using HarmonyLib;
//using Il2Cpp;
//using System.Net;
//using System.Text;
//using UnityEngine;

// Example commands and variables

//namespace SkInterface
//{
// public static class ActiveConfig
// {
// public static bool isRevealed = false;
// public static bool isPlaying = false;
// }

// public static class CommandActions
// {
// [CommandHandler("revealMap", "Test")]
// public static void RevealMapHttp(HttpListenerResponse response)
// {
// RevealMap(response);
// }

// [CommandHandler("ping", "Main")]
// public static void PingHttp(HttpListenerResponse response)
// {
// WickerServer.Instance.LogResponse(response, "Pong!");
// }

// [CommandHandler("pingg")]
// public static void PingHttp2(HttpListenerResponse response)
// {
// WickerServer.Instance.LogResponse(response, "Pong!");
// }

// [CommandHandler("inputTest", "Main")]
// public static void InputTestHTTP(HttpListenerResponse response, string TestCase, string input = "test", string input2 = "testlols")
// {
// // Write output of each var
// StringBuilder responseContent = new StringBuilder();
// // Append output of each var to the response content
// responseContent.AppendLine("TestCase: '" + TestCase + "'");
// responseContent.AppendLine("input: '" + input + "'");
// responseContent.AppendLine("input2: '" + input2 + "'");

// // Now send the accumulated response content as one response
// WickerServer.Instance.LogResponse(response, responseContent.ToString());
// }

// [CommandHandler("secondInputTest", "Main")]
// public static void InputTest2HTTP(HttpListenerResponse response, string input)
// {
// WickerServer.Instance.LogResponse(response, "Received:" + " '" + input + "'");
// }

// [GameVariable("GameReadyToPlay")]
// public static string GetGameReadyToPlay()
// {
// return GameManager.gameReadyToPlay.ToString();
// }

// [GameVariable("IsGameLoaded")]
// public static string GetGameIsLoaded()
// {
// if (GameManager.Instance != null)
// return GameManager.Instance.isLoadedGame.ToString();

// return "False";
// }
// [GameVariable("GameFullyInitialized")]
// public static string GetGmeFullyInitialized()
// {
// return GameManager.gameFullyInitialized.ToString();
// }

// private static int relicCount = 0;

// [GameVariable("FoodProduced")]
// public static string GetRelicCount()
// {
// if (GameManager.Instance == null)
// {
// return "-1";
// }

// //if (GameManager.Instance != null && relicCount <= 0)
// //{
// // var relicResources = UnityEngine.Object.FindObjectsOfType<Villager>();
// // relicCount = relicResources.Length;
// //}

// return GameManager.Instance.villageStats.GetCurrentTrackedFoodProduced().Count.ToString();
// }


// public static bool IsPlaying { get => ActiveConfig.isPlaying; set => ActiveConfig.isPlaying = value; }
// public static bool IsRevealed { get => ActiveConfig.isRevealed; set => ActiveConfig.isRevealed = value; }

// private static void RevealMap(HttpListenerResponse response)
// {
// if (WickerServer.Instance == null)
// {
// return;
// }

// if (GameManager.Instance == null || !GameManager.gameFullyInitialized)
// {

// WickerServer.Instance.LogResponse(response, "Must be in-game to reveal map!");
// return;
// }

// if (GameManager.Instance != null && GameManager.gameFullyInitialized)
// {
// WickerServer.Instance.LogResponse(response, "Revealing map...");
// GameManager.Instance.cameraManager.fogOfWarEffect.mFog.enabled = false;
// ActiveConfig.isRevealed = true;

// var relicResources = UnityEngine.Object.FindObjectsOfType<RelicExtractionResource>();
// foreach (var relic in relicResources)
// {
// relic.availableForExtraction = true;
// }
// }
// }

// [HarmonyPatch(typeof(FOWSystem), "IsExplored")]
// class Patch_FOWSystem_IsExplored
// {
// static bool Prefix(Vector3 pos, ref bool __result)
// {
// if (ActiveConfig.isRevealed)
// {
// __result = true; // Set the result to true
// return false; // Skip the original method
// }
// return true; // Continue with the original method
// }
// }
// }
//}
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MelonLoader;

[assembly: MelonInfo(typeof(SkInterface.WickerServer), "WickerREST", "1.0.0", "Skrip")]
[assembly: MelonInfo(typeof(SkInterface.WickerServer), "WickerREST", "0.9.0", "Skrip")]
[assembly: MelonGame("Crate Entertainment", "Farthest Frontier")]
Loading

0 comments on commit 4e67bb0

Please sign in to comment.