Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Oct 30, 2023
0 parents commit 864ac9c
Show file tree
Hide file tree
Showing 27 changed files with 1,456 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
end_of_line = lf
insert_final_newline = true
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on: [ "push", "pull_request" ]

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x

- name: Run the Cake script
uses: cake-build/cake-action@v1
with:
verbosity: Diagnostic

- uses: actions/upload-artifact@v3
with:
name: Dumpostor.dll
path: Dumpostor/bin/Release/net6.0/Dumpostor.dll

- uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
draft: true
files: Dumpostor/bin/Release/net6.0/Dumpostor.dll
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
.idea
/tools
.vscode
*.DotSettings.user
16 changes: 16 additions & 0 deletions Dumpostor.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dumpostor", "Dumpostor\Dumpostor.csproj", "{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
16 changes: 16 additions & 0 deletions Dumpostor/CompilerAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ReSharper disable CheckNamespace

namespace System.Runtime.CompilerServices;

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, Inherited = false)]
internal sealed class RequiredMemberAttribute : Attribute
{
}

[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public CompilerFeatureRequiredAttribute(string featureName)
{
}
}
35 changes: 35 additions & 0 deletions Dumpostor/DummyMapLoadHacks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using HarmonyLib;
using TMPro;
using UnityEngine;

namespace Dumpostor;

[HarmonyPatch]
internal sealed class DummyMapLoadHacks
{
public static void Initialize()
{
TranslationController.Instance.Awake();
DumpostorPlugin.EnglishLanguageUnit = new LanguageUnit(TranslationController.Instance.Languages[SupportedLangs.English]);

var go = new GameObject();
var shadowQuad = go.AddComponent<MeshRenderer>();
shadowQuad.material = new Material(Shader.Find("Unlit/ShadowShader"));
HudManager.Instance.ShadowQuad = shadowQuad;

HudManager.Instance.Chat = go.AddComponent<ChatController>();
HudManager.Instance.GameSettings = go.AddComponent<TextMeshPro>();

Camera.main!.gameObject.AddComponent<FollowerCamera>();

go.AddComponent<NormalGameManager>();
}

[HarmonyPatch(typeof(ChatController), nameof(ChatController.ForceClosed))]
[HarmonyPrefix]
public static bool SkipForceClosed() => false;

[HarmonyPatch(typeof(ChatController), nameof(ChatController.SetVisible))]
[HarmonyPrefix]
public static bool SkipSetVisible() => false;
}
20 changes: 20 additions & 0 deletions Dumpostor/Dumpers/ColorDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.IO;
using System.Linq;
using System.Text.Json;

namespace Dumpostor.Dumpers;

public sealed class ColorDumper : IDumper
{
public string FileName => Path.Combine("enums", "ColorType.json");

public string Dump()
{
var id = 0;

return JsonSerializer.Serialize(
Palette.ColorNames.ToDictionary(k => DumpostorPlugin.EnglishLanguageUnit.GetString(k.ToString()).ToLower().Capitalize(), _ => id++),
DumpostorPlugin.JsonSerializerOptions
);
}
}
22 changes: 22 additions & 0 deletions Dumpostor/Dumpers/EnumDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Linq;
using System.Text.Json;
using Il2CppSystem.IO;

namespace Dumpostor.Dumpers;

public sealed class EnumDumper<T> : IDumper where T : Enum
{
public string FileName => Path.Combine("enums", typeof(T).Name + ".json");

public string Dump()
{
return JsonSerializer.Serialize(
Extensions.GetValues<T>().ToDictionary(k => Enum.GetName(typeof(T), k), v => v),
new JsonSerializerOptions
{
WriteIndented = true,
}
);
}
}
8 changes: 8 additions & 0 deletions Dumpostor/Dumpers/IDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Dumpostor.Dumpers;

public interface IDumper
{
string FileName { get; }

string Dump();
}
29 changes: 29 additions & 0 deletions Dumpostor/Dumpers/InfoDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Text.Json;
using UnityEngine;

namespace Dumpostor.Dumpers;

public sealed class InfoDumper : IDumper
{
public string FileName => "info.json";

public string Dump()
{
return JsonSerializer.Serialize(
new DumpInfo
{
DumpostorVersion = DumpostorPlugin.Version,
GameVersion = Application.version,
PlatformType = Constants.GetPlatformType(),
},
DumpostorPlugin.JsonSerializerOptions
);
}

public sealed class DumpInfo
{
public required string DumpostorVersion { get; init; }
public required string GameVersion { get; init; }
public required Platforms PlatformType { get; init; }
}
}
38 changes: 38 additions & 0 deletions Dumpostor/Dumpers/Map/DoorsDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using UnityEngine;

namespace Dumpostor.Dumpers.Map;

public sealed class DoorsDumper : IMapDumper
{
public string FileName => "doors.json";

public string Dump(ShipStatus shipStatus)
{
var doors = new Dictionary<int, DoorInfo>();

var indexAsId = shipStatus.AllDoors.All(d => d.Id == 0);

for (var i = 0; i < shipStatus.AllDoors.Count; i++)
{
var door = shipStatus.AllDoors[i];

var id = indexAsId ? i : door.Id;
doors.Add(id, new DoorInfo
{
Room = door.Room,
Position = door.transform.position,
});
}

return JsonSerializer.Serialize(doors, DumpostorPlugin.JsonSerializerOptions);
}

public sealed class DoorInfo
{
public required SystemTypes Room { get; init; }
public required Vector2 Position { get; init; }
}
}
8 changes: 8 additions & 0 deletions Dumpostor/Dumpers/Map/IMapDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Dumpostor.Dumpers.Map;

public interface IMapDumper
{
string FileName { get; }

string Dump(ShipStatus shipStatus);
}
33 changes: 33 additions & 0 deletions Dumpostor/Dumpers/Map/SpawnDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Text.Json;
using UnityEngine;

namespace Dumpostor.Dumpers.Map;

public sealed class SpawnDumper : IMapDumper
{
public string FileName => "spawn.json";

public string Dump(ShipStatus shipStatus)
{
return JsonSerializer.Serialize(SpawnInfo.From(shipStatus), DumpostorPlugin.JsonSerializerOptions);
}

public sealed class SpawnInfo
{
public required Vector2 InitialSpawnCenter { get; init; }
public required Vector2 MeetingSpawnCenter { get; init; }
public required Vector2 MeetingSpawnCenter2 { get; init; }
public required float SpawnRadius { get; init; }

public static SpawnInfo From(ShipStatus shipStatus)
{
return new SpawnInfo
{
InitialSpawnCenter = shipStatus.InitialSpawnCenter,
MeetingSpawnCenter = shipStatus.MeetingSpawnCenter,
MeetingSpawnCenter2 = shipStatus.MeetingSpawnCenter2,
SpawnRadius = shipStatus.SpawnRadius,
};
}
}
}
22 changes: 22 additions & 0 deletions Dumpostor/Dumpers/Map/SystemsDumper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Text.Json;

namespace Dumpostor.Dumpers.Map;

public sealed class SystemsDumper : IMapDumper
{
public string FileName => "systems.json";

public string Dump(ShipStatus shipStatus)
{
var systems = new Dictionary<SystemTypes, string>();

foreach (var key in shipStatus.Systems.Keys)
{
ISystemType value = shipStatus.Systems[key];
systems.Add(key, value.Cast<Il2CppSystem.Object>().GetIl2CppType().FullName);
}

return JsonSerializer.Serialize(systems, DumpostorPlugin.JsonSerializerOptions);
}
}
Loading

0 comments on commit 864ac9c

Please sign in to comment.