2025-05-03 20:36:17 +08:00

78 lines
2.1 KiB
C#

using System.Collections.Generic;
using System.ComponentModel;
using Godot;
using Godot.Bridge;
using Godot.NativeInterop;
[GlobalClass]
[ScriptPath("res://Scripts/Resources/BattleData.cs")]
public class BattleData : Resource
{
public new class MethodName : Resource.MethodName
{
}
public new class PropertyName : Resource.PropertyName
{
public static readonly StringName enemies = "enemies";
}
public new class SignalName : Resource.SignalName
{
}
[Export(PropertyHint.None, "")]
public Battlers[] enemies;
[EditorBrowsable(EditorBrowsableState.Never)]
protected override bool SetGodotClassPropertyValue(in godot_string_name name, in godot_variant value)
{
if (name == PropertyName.enemies)
{
enemies = VariantUtils.ConvertToSystemArrayOfGodotObject<Battlers>(in value);
return true;
}
return base.SetGodotClassPropertyValue(in name, in value);
}
[EditorBrowsable(EditorBrowsableState.Never)]
protected override bool GetGodotClassPropertyValue(in godot_string_name name, out godot_variant value)
{
if (name == PropertyName.enemies)
{
GodotObject[] array = enemies;
value = VariantUtils.CreateFromSystemArrayOfGodotObject(array);
return true;
}
return base.GetGodotClassPropertyValue(in name, out value);
}
[EditorBrowsable(EditorBrowsableState.Never)]
internal static List<PropertyInfo> GetGodotPropertyList()
{
return new List<PropertyInfo>
{
new PropertyInfo(Variant.Type.Array, PropertyName.enemies, PropertyHint.TypeString, "24/17:Battlers", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true)
};
}
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void SaveGodotObjectData(GodotSerializationInfo info)
{
base.SaveGodotObjectData(info);
StringName name = PropertyName.enemies;
GodotObject[] array = enemies;
info.AddProperty(name, Variant.CreateFrom(array));
}
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void RestoreGodotObjectData(GodotSerializationInfo info)
{
base.RestoreGodotObjectData(info);
if (info.TryGetProperty(PropertyName.enemies, out var value))
{
enemies = value.AsGodotObjectArray<Battlers>();
}
}
}