mirror: 上游快照导入

This commit is contained in:
gitea committed 2026-11-30 09:52:36 +08:00
commit 7475ccb467
86 files changed
+3213

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<AssemblyVersion>0.0.1.0</AssemblyVersion>
</PropertyGroup>
<!-- <ItemGroup>
<Reference Include="CSharpModBase">
<HintPath>..\CSharpModBase\bin\Debug\net472\CSharpModBase.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup> -->
<ItemGroup>
<ProjectReference Include="..\CSharpModBase\CSharpModBase.csproj">
<!-- <Private>False</Private> -->
<!-- <ExcludeAssets>runtime</ExcludeAssets> -->
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="BtlSvr.Main">
<HintPath>..\GameDll\BtlSvr.Main.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="b1.Native">
<HintPath>..\GameDll\b1.Native.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="b1.NativePlugins">
<HintPath>..\GameDll\b1.NativePlugins.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="GSE.Core">
<HintPath>..\GameDll\GSE.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="GSE.ProtobufDB">
<HintPath>..\GameDll\GSE.ProtobufDB.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Google.Protobuf">
<HintPath>..\GameDll\Google.Protobuf.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Protobuf.RunTime">
<HintPath>..\GameDll\Protobuf.RunTime.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnrealEngine.Runtime">
<HintPath>..\GameDll\UnrealEngine.Runtime.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnrealEngine">
<HintPath>..\GameDll\UnrealEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
</Project>
+72
View File
@@ -0,0 +1,72 @@
using b1;
using UnrealEngine.Engine;
using UnrealEngine.Runtime;
namespace CSharpExample
{
public static class MyUtils
{
private static UWorld? world;
public static UWorld? GetWorld()
{
if (world == null)
{
UObjectRef uobjectRef = GCHelper.FindRef(FGlobals.GWorld);
world = uobjectRef?.Managed as UWorld;
}
return world;
}
public static APawn GetControlledPawn()
{
return UGSE_EngineFuncLib.GetFirstLocalPlayerController(GetWorld()).GetControlledPawn();
}
public static BGUPlayerCharacterCS GetBGUPlayerCharacterCS()
{
return (GetControlledPawn() as BGUPlayerCharacterCS)!;
}
public static BGP_PlayerControllerB1 GetPlayerController()
{
return (BGP_PlayerControllerB1)UGSE_EngineFuncLib.GetFirstLocalPlayerController(GetWorld());
}
public static BUS_GSEventCollection GetBUS_GSEventCollection()
{
return BUS_EventCollectionCS.Get(GetControlledPawn());
}
public static T LoadAsset<T>(string asset) where T : UObject
{
return b1.BGW.BGW_PreloadAssetMgr.Get(GetWorld()).TryGetCachedResourceObj<T>(asset, b1.BGW.ELoadResourceType.SyncLoadAndCache, b1.BGW.EAssetPriority.Default, null, -1, -1);
}
public static UClass LoadClass(string asset)
{
return LoadAsset<UClass>(asset);
}
public static AActor? SpawnActor(string classAsset)
{
var controlledPawn = GetControlledPawn();
FVector actorLocation = controlledPawn.GetActorLocation();
FVector b = controlledPawn.GetActorForwardVector() * 1000.0f;
FVector start = actorLocation + b;
FRotator frotator = UMathLibrary.FindLookAtRotation(start, actorLocation);
UClass uClass = LoadClass($"PrefabricatorAsset'{classAsset}'");
if (uClass == null)
{
return null;
}
return BGUFunctionLibraryCS.BGUSpawnActor(controlledPawn.World, uClass, start, frotator);
}
public static AActor GetActorOfClass(string classAsset)
{
return UGameplayStatics.GetActorOfClass(GetWorld(), LoadAsset<UClass>(classAsset));
}
}
}
+55
View File
@@ -0,0 +1,55 @@
using System;
using b1;
using BtlShare;
using CSharpModBase;
using CSharpModBase.Input;
// using HarmonyLib;
namespace CSharpExample
{
public class MyMod : ICSharpMod
{
public string Name => "ModExample";
public string Version => "0.0.1";
// private readonly Harmony harmony;
public MyMod()
{
// harmony = new Harmony(Name);
// Harmony.DEBUG = true;
}
public void Init()
{
Console.WriteLine($"{Name} Init");
Utils.RegisterKeyBind(Key.ENTER, () => Console.WriteLine("Enter pressed"));
Utils.RegisterKeyBind(ModifierKeys.Control, Key.ENTER, FindPlayer);
// hook
// harmony.PatchAll();
}
public void DeInit()
{
Console.WriteLine($"{Name} DeInit");
// harmony.UnpatchAll();
}
private void FindPlayer()
{
Console.WriteLine("Ctrl+Enter pressed");
var player = MyUtils.GetControlledPawn();
if (player == null)
{
Console.WriteLine("Player not found");
}
else
{
Console.WriteLine($"Player found: {player}");
float hp = BGUFunctionLibraryCS.GetAttrValue(player, EBGUAttrFloat.Hp);
float hpMax = BGUFunctionLibraryCS.GetAttrValue(player, EBGUAttrFloat.HpMax);
Console.WriteLine($"HP: {hp}/{hpMax}");
}
}
}
}
+3
View File
@@ -0,0 +1,3 @@
# 编译
dotnet build
+2
View File
@@ -0,0 +1,2 @@
dotnet build
cp bin/Debug/net472/CSharpExample.dll C:/Users/An/Soft/Steam/steamapps/common/BlackMythWukong/b1/Binaries/Win64/CSharpLoader/Mods
+8
View File
@@ -0,0 +1,8 @@
<?xml version='1.0'?>
<Obfuscator>
<Var name="OutPath" value="bin\Debug\net472\Obfuscated" />
<Var name="KeepPublicApi" value="false" />
<Var name="ReuseNames" value="false" />
<Module file="bin\Debug\net472\CSharpExample.dll">
</Module>
</Obfuscator>