Moved a lot of core functionality into new Common library

- Remove System.IO from Implicit Usings.
This commit is contained in:
Tony Bark 2026-04-24 08:34:12 -04:00
parent 1f2032dcf8
commit fb013f2b15
18 changed files with 169 additions and 14 deletions

View file

@ -0,0 +1,6 @@
namespace CyberBits.Common;
public record Addon(
[property: JsonPropertyName("cyberware")]
string[] Cyberware
);

12
CyberBits.Common/Bits.cs Normal file
View file

@ -0,0 +1,12 @@
namespace CyberBits.Common;
public record Bits(
[property: JsonPropertyName("image")]
string Image,
[property: JsonPropertyName("feat")]
string Feat,
[property: JsonPropertyName("base")]
string[] Base,
[property: JsonPropertyName("style")]
string[] Style
);

View file

@ -0,0 +1,8 @@
namespace CyberBits.Common;
public struct CBConsts
{
// Ignore VSCode if it complains about "ThisAssembly" not being found.
public const string VERSION =
$"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
}

View file

@ -1,6 +0,0 @@
namespace CyberBits.Common;
public class Class1
{
}

View file

@ -1,16 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RollForward>LatestMajor</RollForward>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Using Remove="System.IO" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitInfo" Version="3.6.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="GodotSharp" Version="4.6.2" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,31 @@
namespace CyberBits.Common;
public static class FileFetcher
{
public static string LoadTextFile(string filename, bool userDir = false)
{
var location = "res";
if (userDir)
location = "user";
using var file = FileAccess.Open($"{location}://{filename}", FileAccess.ModeFlags.Read);
var contents = file.GetAsText();
file.Close();
return contents;
}
public static ConfigFile LoadConfig(string filename, bool userDir = false)
{
var config = new ConfigFile();
// Load data from a file.
var err = config.Load(LoadTextFile(filename, userDir));
if (err != Error.Ok)
sys.Environment.Exit(sys.Environment.ExitCode);
return config;
}
}

View file

@ -0,0 +1,6 @@
// System
global using sys = System;
global using System.Text.Json.Serialization;
// Godot
global using Godot;

View file

@ -0,0 +1,8 @@
namespace CyberBits.Common;
public struct ResourceFiles
{
public const string COCK_JSON = "resources/cock.json";
public const string PUSSY_JSON = "resources/pussy.json";
public const string ADDONS_JSON = "resources/addons.json";
}