Skip to content

Commit 1e44570

Browse files
skuzzissamyycXELDmenthimenekocnK4ryuu
authored
Release v1.0.3 - yolo (#136)
Co-authored-by: samyyc <s1myyc@outlook.com> Co-authored-by: 菠蘿包 <79680886+ELDment@users.noreply.github.com> Co-authored-by: LynchMus <xubw@vip.qq.com> Co-authored-by: K4ryuu <104531589+K4ryuu@users.noreply.github.com>
1 parent 20f3a2d commit 1e44570

File tree

1,923 files changed

+88098
-26161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,923 files changed

+88098
-26161
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ jobs:
254254
cp -r ./server.pdb/server.pdb ${{ env.WINDOWS_FOLDER }}/swiftlys2/bin/win64/
255255
256256
mkdir -p ${{ env.LINUX_FOLDER }}/swiftlys2/plugins/
257+
mkdir -p ${{ env.LINUX_FOLDER }}/swiftlys2/plugins/disabled
257258
mkdir -p ${{ env.WINDOWS_FOLDER }}/swiftlys2/plugins/
259+
mkdir -p ${{ env.WINDOWS_FOLDER }}/swiftlys2/plugins/disabled
258260
259261
cp -r ${{ env.LINUX_FOLDER }}/ ${{ env.LINUX_FOLDER }}-with-runtimes/
260262
cp -r ${{ env.WINDOWS_FOLDER }}/ ${{ env.WINDOWS_FOLDER }}-with-runtimes/

generator/docs_generator/generator.py

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
os.makedirs(DEST_DIR, exist_ok=True)
99

10+
def get_namespace(yaml_data):
11+
"""Extract namespace from the YAML data."""
12+
for item in yaml_data.get('body', []):
13+
if 'facts' in item:
14+
for fact in item['facts']:
15+
if fact.get('name') == 'Namespace':
16+
if isinstance(fact.get('value'), dict):
17+
return fact['value'].get('text', '')
18+
return fact.get('value', '')
19+
return ''
20+
1021
def extract_metadata(yaml_data, is_index=False):
1122
"""Extract front-matter metadata from DocFX ApiPage YAML."""
1223
title = yaml_data.get('title', '')
@@ -30,31 +41,84 @@ def convert_to_path(s):
3041
if s.lower().endswith(".html"):
3142
s = s[10:]
3243
s = s[:-5]
44+
# Merge Core and Shared into the same path
45+
s = s.replace("SwiftlyS2.Core.", "SwiftlyS2.").replace("SwiftlyS2.Shared.", "SwiftlyS2.")
3346
path = "/".join(s.split(".")).lower()
47+
# Transform -NUMBER to t repeated NUMBER times
48+
parts = path.split("/")
49+
parts[-1] = transform_filename(parts[-1])
50+
path = "/".join(parts)
3451
return path
3552

3653
def transform_filename(base_name):
3754
"""
38-
If filename ends with -NUMBER, replace with NUMBER times 'T'.
39-
Example: class-3 -> classTTT
55+
If filename ends with -NUMBER, replace with NUMBER times 't'.
56+
Example: class-3 -> classttt
4057
"""
4158
match = re.match(r"^(.*?)-(\d+)$", base_name)
4259
if match:
4360
name, num = match.groups()
4461
num = int(num)
45-
return name + ("T" * num)
62+
return name + ("t" * num)
4663
return base_name
4764

4865
def generate_markdown(yaml_data):
4966
"""Generate Markdown content from DocFX ApiPage YAML."""
5067
md = ""
68+
namespace = get_namespace(yaml_data)
69+
5170
for item in yaml_data.get('body', []):
71+
if 'api1' in item:
72+
api1_title = str(item.get('api1', ''))
73+
api1_title = re.sub(r'<[^>]+>', '', api1_title)
74+
md += f"# {api1_title}\n\n"
75+
if 'src' in item:
76+
src = item['src'].replace('/blob/main', '/blob/master')
77+
md += f"[View Source]({src})\n\n"
78+
if 'facts' in item:
79+
for fact in item['facts']:
80+
fact_name = fact.get('name', '')
81+
fact_value = fact.get('value', '')
82+
if isinstance(fact_value, dict):
83+
fact_text = fact_value.get('text', '')
84+
fact_url = fact_value.get('url', '')
85+
if fact_url and fact_url.endswith('.html'):
86+
fact_url = "/docs/api/" + convert_to_path(fact_url)
87+
md += f"**{fact_name}**: [{fact_text}]({fact_url})\n\n"
88+
else:
89+
md += f"**{fact_name}**: {fact_text}\n\n"
90+
else:
91+
md += f"**{fact_name}**: {fact_value}\n\n"
92+
if 'markdown' in item:
93+
md += f"{item['markdown']}\n\n"
5294
if 'h2' in item:
5395
md += f"## {item['h2']}\n\n"
5496
if 'h4' in item:
5597
md += f"#### {item['h4']}\n\n"
5698
if 'code' in item:
5799
md += "```csharp\n" + item['code'] + "\n```\n\n"
100+
if 'inheritance' in item:
101+
for inherit in item['inheritance']:
102+
inherit_text = inherit.get('text', '')
103+
inherit_url = inherit.get('url', '')
104+
if inherit_url:
105+
if inherit_url.endswith('.html'):
106+
inherit_url = "/docs/api/" + convert_to_path(inherit_url)
107+
md += f"- [{inherit_text}]({inherit_url})\n"
108+
else:
109+
md += f"- {inherit_text}\n"
110+
md += "\n"
111+
if 'list' in item:
112+
for list_item in item['list']:
113+
list_text = list_item.get('text', '')
114+
list_url = list_item.get('url', '')
115+
if list_url:
116+
if list_url.endswith('.html'):
117+
list_url = "/docs/api/" + convert_to_path(list_url)
118+
md += f"- [{list_text}]({list_url})\n"
119+
else:
120+
md += f"- {list_text}\n"
121+
md += "\n"
58122
if 'parameters' in item:
59123
for param in item['parameters']:
60124
param_name = param.get('name', '')
@@ -94,7 +158,8 @@ def generate_markdown(yaml_data):
94158
api3_title = re.sub(r'\[[^\]]+\]', '', api3_title)
95159
md += f"### {api3_title}\n\n"
96160
if src != '':
97-
md += f"[Source Code]({src})\n\n"
161+
src = src.replace('/blob/main', '/blob/master')
162+
md += f"[View Source]({src})\n\n"
98163
return md
99164

100165
def convert_yaml_file(src_path, dest_path):
@@ -136,11 +201,11 @@ def convert_yaml_file(src_path, dest_path):
136201
for root, dirs, files in os.walk(SOURCE_DIR):
137202
for file in files:
138203
if file.endswith(".yml") or file.endswith(".yaml"):
139-
rel_path = os.path.relpath(root, SOURCE_DIR)
140-
dest_folder = os.path.join(DEST_DIR, rel_path)
141204
raw_base = os.path.splitext(file)[0]
205+
# Merge Core and Shared paths
206+
raw_base = raw_base.replace("SwiftlyS2.Core.", "SwiftlyS2.").replace("SwiftlyS2.Shared.", "SwiftlyS2.")
142207
new_base = transform_filename(raw_base)
143-
dest_file = os.path.join(dest_folder, convert_to_path(new_base) + ".md")
208+
dest_file = os.path.join(DEST_DIR, convert_to_path(new_base) + ".md")
144209
convert_yaml_file(os.path.join(root, file), dest_file)
145210

146211
print("Markdown generation complete!")

generator/gameevent_generator/generate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,7 @@ def render_class(event: GameEventDef) -> str:
473473
for fname, fdef in event.fields.items():
474474
ftype = fdef.type_name
475475

476-
# userid override: expand to controller, pawn (readonly) and raw int (readwrite)
477-
if fname.lower() == 'userid':
476+
if ftype == 'player_controller' or ftype == 'player_controller_and_pawn' or fname.lower() == 'userid':
478477
base_prop = to_property_name(fname) # UserId
479478
# Controller
480479
prop_name_ctrl = f"{base_prop}Controller"
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
private static readonly nint _$NAME$Offset = Schema.GetOffset($HASH$);
1+
private static nint? _$NAME$Offset;
22

33
public string $NAME$ {
44
get {
5-
var ptr = _Handle + _$NAME$Offset;
6-
return Schema.GetString(ptr);
5+
if (_$NAME$Offset == null) {
6+
_$NAME$Offset = Schema.GetOffset($HASH$);
7+
}
8+
var ptr = _Handle + _$NAME$Offset!.Value;
9+
return Schema.GetString(ptr);
10+
}
11+
set {
12+
if (_$NAME$Offset == null) {
13+
_$NAME$Offset = Schema.GetOffset($HASH$);
14+
}
15+
Schema.SetFixedString(_Handle, _$NAME$Offset!.Value, value, $ELEMENT_COUNT$);
716
}
8-
set => Schema.SetFixedString(_Handle, _$NAME$Offset, value, $ELEMENT_COUNT$);
917
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
private static readonly nint _$NAME$Offset = Schema.GetOffset($HASH$);
1+
private static nint? _$NAME$Offset;
22

33
public $INTERFACE_TYPE$? $NAME$ {
44
get {
5-
var ptr = _Handle.Read<nint>(_$NAME$Offset);
5+
if (_$NAME$Offset == null) {
6+
_$NAME$Offset = Schema.GetOffset($HASH$);
7+
}
8+
var ptr = _Handle.Read<nint>(_$NAME$Offset!.Value);
69
return ptr.IsValidPtr() ? new $IMPL_TYPE$(ptr) : null;
710
}
811
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
private static readonly nint _$NAME$Offset = Schema.GetOffset($HASH$);
1+
private static nint? _$NAME$Offset;
22

33
public $INTERFACE_TYPE$ $NAME$ {
4-
get => new $IMPL_TYPE$(_Handle + _$NAME$Offset);
4+
get {
5+
if (_$NAME$Offset == null) {
6+
_$NAME$Offset = Schema.GetOffset($HASH$);
7+
}
8+
return new $IMPL_TYPE$(_Handle + _$NAME$Offset!.Value);
9+
}
510
}
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
private static readonly nint _$NAME$Offset = Schema.GetOffset($HASH$);
1+
private static nint? _$NAME$Offset;
22

33
public string $NAME$ {
44
get {
5-
var ptr = _Handle.Read<nint>(_$NAME$Offset);
5+
if (_$NAME$Offset == null) {
6+
_$NAME$Offset = Schema.GetOffset($HASH$);
7+
}
8+
var ptr = _Handle.Read<nint>(_$NAME$Offset!.Value);
69
return Schema.GetString(ptr);
710
}
8-
set => Schema.SetString(_Handle, _$NAME$Offset, value);
11+
set {
12+
if (_$NAME$Offset == null) {
13+
_$NAME$Offset = Schema.GetOffset($HASH$);
14+
}
15+
Schema.SetString(_Handle, _$NAME$Offset!.Value, value);
16+
}
917
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
private static readonly nint _$NAME$Offset = Schema.GetOffset($HASH$);
1+
private static nint? _$NAME$Offset;
22

33
public ref $IMPL_TYPE$ $NAME$ {
4-
get => ref _Handle.$REF_METHOD$<$IMPL_TYPE$>(_$NAME$Offset);
4+
get {
5+
if (_$NAME$Offset == null) {
6+
_$NAME$Offset = Schema.GetOffset($HASH$);
7+
}
8+
return ref _Handle.$REF_METHOD$<$IMPL_TYPE$>(_$NAME$Offset!.Value);
9+
}
510
}

managed/managed.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<ItemGroup>
6464
<Compile Remove="src\TestPlugin\**\*.cs" />
6565
<Compile Remove="SwiftlyS2.Benchmarks\**\*.cs" />
66+
<Compile Remove="SwiftlyS2.PluginTemplate\**\*.cs" />
6667
<Compile Remove="**\obj\**\*.cs" />
6768
<Compile Remove="**\bin\**\*.cs" />
6869
</ItemGroup>
Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
using System.Reflection;
2-
using SwiftlyS2.Core.Commands;
32
using SwiftlyS2.Shared.Commands;
43

54
namespace SwiftlyS2.Core.AttributeParsers;
65

7-
internal static class CommandAttributeParser {
8-
public static void ParseFromObject(this ICommandService self, object instance) {
9-
var type = instance.GetType();
10-
var methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
11-
foreach (var method in methods)
6+
internal static class CommandAttributeParser
7+
{
8+
public static void ParseFromObject( this ICommandService self, object instance )
129
{
13-
var commandAttribute = method.GetCustomAttribute<Command>();
14-
var clientCommandHookHandlerAttribute = method.GetCustomAttribute<ClientCommandHookHandler>();
15-
var clientChatHookHandlerAttribute = method.GetCustomAttribute<ClientChatHookHandler>();
16-
if (commandAttribute != null)
17-
{
18-
var commandAliasAttributes = method.GetCustomAttributes<CommandAlias>();
19-
var commandName = commandAttribute.Name;
20-
var commandAlias = commandAliasAttributes.Select(a => a.Alias).ToArray();
21-
var registerRaw = commandAttribute.RegisterRaw;
22-
var permission = commandAttribute.Permission;
23-
self.RegisterCommand(commandName, method.CreateDelegate<ICommandService.CommandListener>(instance), registerRaw, permission);
24-
foreach (var alias in commandAlias)
10+
var type = instance.GetType();
11+
var methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
12+
foreach (var method in methods)
2513
{
26-
self.RegisterCommandAlias(commandName, alias, registerRaw);
27-
}
28-
}
14+
var commandAttribute = method.GetCustomAttribute<Command>();
15+
var clientCommandHookHandlerAttribute = method.GetCustomAttribute<ClientCommandHookHandler>();
16+
var clientChatHookHandlerAttribute = method.GetCustomAttribute<ClientChatHookHandler>();
17+
if (commandAttribute != null)
18+
{
19+
var commandAliasAttributes = method.GetCustomAttributes<CommandAlias>();
20+
var commandName = commandAttribute.Name;
21+
var registerRaw = commandAttribute.RegisterRaw;
22+
var permission = commandAttribute.Permission;
23+
24+
var cmdGuid = self.RegisterCommand(commandName, method.CreateDelegate<ICommandService.CommandListener>(instance), registerRaw, permission);
25+
foreach (var aliasAttr in commandAliasAttributes)
26+
{
27+
self.RegisterCommandAlias(commandName, aliasAttr.Alias, aliasAttr.RegisterRaw);
28+
}
29+
}
2930

30-
if (clientCommandHookHandlerAttribute != null)
31-
{
32-
self.HookClientCommand(method.CreateDelegate<ICommandService.ClientCommandHandler>(instance));
33-
}
31+
if (clientCommandHookHandlerAttribute != null)
32+
{
33+
_ = self.HookClientCommand(method.CreateDelegate<ICommandService.ClientCommandHandler>(instance));
34+
}
3435

35-
if (clientChatHookHandlerAttribute != null)
36-
{
37-
self.HookClientChat(method.CreateDelegate<ICommandService.ClientChatHandler>(instance));
38-
}
36+
if (clientChatHookHandlerAttribute != null)
37+
{
38+
_ = self.HookClientChat(method.CreateDelegate<ICommandService.ClientChatHandler>(instance));
39+
}
40+
}
3941
}
40-
}
4142
}

0 commit comments

Comments
 (0)