Skip to content
Open
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
682 changes: 675 additions & 7 deletions .gitignore

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-dotnettools.csdevkit",
"ms-dotnettools.csharp"
]
}
65 changes: 65 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Client (Debug)",
"type": "coreclr",
"request": "launch",
"program": "${env:VINTAGE_STORY}/Vintagestory.exe",
"linux": {
"program": "${env:VINTAGE_STORY}/Vintagestory"
},
"osx": {
"program": "${env:VINTAGE_STORY}/Vintagestory"
},
"preLaunchTask": "build",
"args": [
// "--playStyle" , "preset-surviveandbuild",
// "--openWorld" , "modding test world",
"--tracelog",
"--addModPath",
"${workspaceFolder}/detailedanimals/bin/Debug/Mods",
"--addOrigin",
"${workspaceFolder}/detailedanimals/assets"
],
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Launch Server",
"type": "coreclr",
"request": "launch",
"program": "${env:VINTAGE_STORY}/VintagestoryServer.exe",
"linux": {
"program": "${env:VINTAGE_STORY}/VintagestoryServer"
},
"osx": {
"program": "${env:VINTAGE_STORY}/VintagestoryServer"
},
"preLaunchTask": "build",
"args": [
"--tracelog",
"--addModPath",
"${workspaceFolder}/detailedanimals/bin/Debug/Mods",
"--addOrigin",
"${workspaceFolder}/detailedanimals/assets"
],
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "CakeBuild",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Cake)",
"program": "${workspaceFolder}/CakeBuild/bin/Debug/net7.0/CakeBuild.dll",
"args": [],
"cwd": "${workspaceFolder}/CakeBuild",
"stopAtEntry": false,
"console": "internalConsole"
}
]
}
40 changes: 40 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"-c",
"Debug",
"${workspaceFolder}/detailedanimals/detailedanimals.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "package",
"command": "dotnet",
"type": "process",
"args": [
"run",
"--project",
"${workspaceFolder}/CakeBuild/CakeBuild.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "build (Cake)",
"command": "dotnet",
"type": "process",
"args": [
"build",
"-c",
"Debug",
"${workspaceFolder}/CakeBuild/CakeBuild.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
19 changes: 19 additions & 0 deletions CakeBuild/CakeBuild.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Frosting" Version="5.0.0" />
<PackageReference Include="Cake.Json" Version="7.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<Reference Include="VintagestoryAPI">
<HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
120 changes: 120 additions & 0 deletions CakeBuild/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using Cake.Common;
using Cake.Common.IO;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.Clean;
using Cake.Common.Tools.DotNet.Publish;
using Cake.Core;
using Cake.Frosting;
using Cake.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using Vintagestory.API.Common;

namespace CakeBuild
{
public static class Program
{
public static int Main(string[] args)
{
return new CakeHost()
.UseContext<BuildContext>()
.Run(args);
}
}

public class BuildContext : FrostingContext
{
public const string ProjectName = "detailedanimals";
public string BuildConfiguration { get; }
public string Version { get; }
public string Name { get; }
public bool SkipJsonValidation { get; }

public BuildContext(ICakeContext context)
: base(context)
{
BuildConfiguration = context.Argument("configuration", "Release");
SkipJsonValidation = context.Argument("skipJsonValidation", false);
var modInfo = context.DeserializeJsonFromFile<ModInfo>($"../{ProjectName}/modinfo.json");
Version = modInfo.Version;
Name = modInfo.ModID;
}
}

[TaskName("ValidateJson")]
public sealed class ValidateJsonTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
if (context.SkipJsonValidation)
{
return;
}
var jsonFiles = context.GetFiles($"../{BuildContext.ProjectName}/assets/**/*.json");
foreach (var file in jsonFiles)
{
try
{
var json = File.ReadAllText(file.FullPath);
JToken.Parse(json);
}
catch (JsonException ex)
{
throw new Exception($"Validation failed for JSON file: {file.FullPath}{Environment.NewLine}{ex.Message}", ex);
}
}
}
}

[TaskName("Build")]
[IsDependentOn(typeof(ValidateJsonTask))]
public sealed class BuildTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.DotNetClean($"../{BuildContext.ProjectName}/{BuildContext.ProjectName}.csproj",
new DotNetCleanSettings
{
Configuration = context.BuildConfiguration
});


context.DotNetPublish($"../{BuildContext.ProjectName}/{BuildContext.ProjectName}.csproj",
new DotNetPublishSettings
{
Configuration = context.BuildConfiguration
});
}
}

[TaskName("Package")]
[IsDependentOn(typeof(BuildTask))]
public sealed class PackageTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.EnsureDirectoryExists("../Releases");
context.CleanDirectory("../Releases");
context.EnsureDirectoryExists($"../Releases/{context.Name}");
context.CopyFiles($"../{BuildContext.ProjectName}/bin/{context.BuildConfiguration}/Mods/mod/publish/*", $"../Releases/{context.Name}");
if (context.DirectoryExists($"../{BuildContext.ProjectName}/assets"))
{
context.CopyDirectory($"../{BuildContext.ProjectName}/assets", $"../Releases/{context.Name}/assets");
}
context.CopyFile($"../{BuildContext.ProjectName}/modinfo.json", $"../Releases/{context.Name}/modinfo.json");
if (context.FileExists($"../{BuildContext.ProjectName}/modicon.png"))
{
context.CopyFile($"../{BuildContext.ProjectName}/modicon.png", $"../Releases/{context.Name}/modicon.png");
}
context.Zip($"../Releases/{context.Name}", $"../Releases/{context.Name}_{context.Version}.zip");
}
}

[TaskName("Default")]
[IsDependentOn(typeof(PackageTask))]
public class DefaultTask : FrostingTask
{
}
}
2 changes: 2 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dotnet run --project CakeBuild/CakeBuild.csproj -- $args
exit $LASTEXITCODE;
34 changes: 1 addition & 33 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1 @@
# To define the environment variable, put something like this in your .bashrc file:
# export VINTAGE_STORY_DEV="$HOME/software/vintagestory_dev"

starttime=$(($(date +%s%N)/1000000))

RED='\033[0;31m'
NC='\033[0m' # No Color

null_textured_shapes=$(grep -rl "#null" assets/)
# Only print anything if files were found
if [[ -n $null_textured_shapes ]]; then
echo -e "${RED}These shape files contain null textures:"
echo -e "${null_textured_shapes}${NC}"
fi

precook=$(($(date +%s%N)/1000000))
python3 texsrc/cook.py
postcook=$(($(date +%s%N)/1000000))

cp assets/detailedanimals/lang/es-419.json assets/detailedanimals/lang/es-es.json
dotnet run --project ./Build/CakeBuild/CakeBuild.csproj -- "$@"
rm assets/detailedanimals/lang/es-es.json
rm -r bin/
rm -r src/obj/
rm "${VINTAGE_STORY_DEV}"/Mods/detailedanimals_*.zip
mkdir -p "${VINTAGE_STORY_DEV}/Mods"
cp Build/Releases/detailedanimals_*.zip "${VINTAGE_STORY_DEV}/Mods"

endtime=$(($(date +%s%N)/1000000))
cooktime=$(( postcook - precook ))
buildtime=$(( endtime - postcook ))
totaltime=$(( endtime - starttime ))
echo -e "${totaltime} milliseconds total: $((precook - starttime)) to validate, ${cooktime} to cook, and ${buildtime} to build"
dotnet run --project ./CakeBuild/CakeBuild.csproj -- "$@"
4 changes: 4 additions & 0 deletions detailedanimals.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Solution>
<Project Path="CakeBuild/CakeBuild.csproj" />
<Project Path="detailedanimals/detailedanimals.csproj" Id="e11c3fca-81b1-4fe4-8078-55791db705a8" />
</Solution>
16 changes: 16 additions & 0 deletions detailedanimals/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"profiles": {
"Client": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "\"$(VINTAGE_STORY)/Vintagestory.dll\" --tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\" --addOrigin \"$(ProjectDir)/assets\"",
"workingDirectory": "$(VINTAGE_STORY)"
},
"Server": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "\"$(VINTAGE_STORY)/VintagestoryServer.dll\" --tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\" --addOrigin \"$(ProjectDir)/assets\"",
"workingDirectory": "$(VINTAGE_STORY)"
}
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/$(Configuration)</OutputPath>
<OutputPath>bin\$(Configuration)\Mods\mod</OutputPath>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Reference Include="VintagestoryAPI">
<HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VintagestoryLib">
<HintPath>$(VINTAGE_STORY)/VintagestoryLib.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VSSurvivalMod">
<HintPath>$(VINTAGE_STORY)/Mods/VSSurvivalMod.dll</HintPath>
<Private>False</Private>
Expand All @@ -31,22 +28,42 @@
<HintPath>$(VINTAGE_STORY)/Lib/Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lib.Harmony">
<HintPath>$(VINTAGE_STORY)/Lib/0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony">
<HintPath>$(VINTAGE_STORY)/Lib/0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VintagestoryLib">
<HintPath>$(VINTAGE_STORY)/VintagestoryLib.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="protobuf-net">
<HintPath>$(VINTAGE_STORY)/Lib/protobuf-net.dll</HintPath>
<Private>False</Private>
<HintPath>$(VINTAGE_STORY)/Lib/protobuf-net.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="cairo-sharp">
<HintPath>$(VINTAGE_STORY)/Lib/cairo-sharp.dll</HintPath>
<Private>False</Private>
<HintPath>$(VINTAGE_STORY)/Lib/cairo-sharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="genelib">
<HintPath>../../genelib/Build/Releases/genelib/Genelib.dll</HintPath>
<Private>False</Private>
<Reference Include="Microsoft.Data.Sqlite">
<HintPath>$(VINTAGE_STORY)/Lib/Microsoft.Data.Sqlite.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="GeneLib">
<HintPath>$(ProjectDir)/libs/**</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

<ItemGroup>
<Content Include="modinfo.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="modicon.png" Condition="Exists('modicon.png')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
Binary file added detailedanimals/libs/Genelib.dll
Binary file not shown.
File renamed without changes.
File renamed without changes
File renamed without changes.
Loading