261 lines
7.5 KiB
C#
261 lines
7.5 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Bullets/GearDuo.cs")]
|
|
public class GearDuo : Control
|
|
{
|
|
public new class MethodName : Control.MethodName
|
|
{
|
|
public new static readonly StringName _EnterTree = "_EnterTree";
|
|
|
|
public new static readonly StringName _Process = "_Process";
|
|
|
|
public static readonly StringName ResetTimer = "ResetTimer";
|
|
|
|
public static readonly StringName Shake = "Shake";
|
|
}
|
|
|
|
public new class PropertyName : Control.PropertyName
|
|
{
|
|
public static readonly StringName warning = "warning";
|
|
|
|
public static readonly StringName gearObj = "gearObj";
|
|
|
|
public static readonly StringName gearAnim = "gearAnim";
|
|
|
|
public static readonly StringName time = "time";
|
|
|
|
public static readonly StringName cd = "cd";
|
|
}
|
|
|
|
public new class SignalName : Control.SignalName
|
|
{
|
|
}
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D warning;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D gearObj;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AnimationPlayer gearAnim;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private float time = 25f;
|
|
|
|
private float cd;
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
base.Size = new Vector2(BattleDR.current.activeBoard.boardSize.X - 6f, BattleDR.current.activeBoard.boardSize.Y - 6f);
|
|
base.Position = base.Size / -2f;
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (cd > 0f)
|
|
{
|
|
cd -= Main.deltaTime;
|
|
}
|
|
else if (cd > -50f)
|
|
{
|
|
cd = -100f;
|
|
gearObj.GlobalPosition = new Vector2(gearObj.GlobalPosition.X, BattleDR.current.soul.GlobalPosition.Y);
|
|
gearAnim.Play("Gear");
|
|
}
|
|
}
|
|
|
|
public void ResetTimer()
|
|
{
|
|
cd = time;
|
|
}
|
|
|
|
public void Shake()
|
|
{
|
|
CameraController.Shake(10f);
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
internal static List<MethodInfo> GetGodotMethodList()
|
|
{
|
|
return new List<MethodInfo>(4)
|
|
{
|
|
new MethodInfo(MethodName._EnterTree, new PropertyInfo(Variant.Type.Nil, "", PropertyHint.None, "", PropertyUsageFlags.Default, exported: false), MethodFlags.Normal, null, null),
|
|
new MethodInfo(MethodName._Process, new PropertyInfo(Variant.Type.Nil, "", PropertyHint.None, "", PropertyUsageFlags.Default, exported: false), MethodFlags.Normal, new List<PropertyInfo>
|
|
{
|
|
new PropertyInfo(Variant.Type.Float, "delta", PropertyHint.None, "", PropertyUsageFlags.Default, exported: false)
|
|
}, null),
|
|
new MethodInfo(MethodName.ResetTimer, new PropertyInfo(Variant.Type.Nil, "", PropertyHint.None, "", PropertyUsageFlags.Default, exported: false), MethodFlags.Normal, null, null),
|
|
new MethodInfo(MethodName.Shake, new PropertyInfo(Variant.Type.Nil, "", PropertyHint.None, "", PropertyUsageFlags.Default, exported: false), MethodFlags.Normal, null, null)
|
|
};
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
|
|
{
|
|
if (method == MethodName._EnterTree && args.Count == 0)
|
|
{
|
|
_EnterTree();
|
|
ret = default(godot_variant);
|
|
return true;
|
|
}
|
|
if (method == MethodName._Process && args.Count == 1)
|
|
{
|
|
_Process(VariantUtils.ConvertTo<double>(in args[0]));
|
|
ret = default(godot_variant);
|
|
return true;
|
|
}
|
|
if (method == MethodName.ResetTimer && args.Count == 0)
|
|
{
|
|
ResetTimer();
|
|
ret = default(godot_variant);
|
|
return true;
|
|
}
|
|
if (method == MethodName.Shake && args.Count == 0)
|
|
{
|
|
Shake();
|
|
ret = default(godot_variant);
|
|
return true;
|
|
}
|
|
return base.InvokeGodotClassMethod(in method, args, out ret);
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
protected override bool HasGodotClassMethod(in godot_string_name method)
|
|
{
|
|
if (method == MethodName._EnterTree)
|
|
{
|
|
return true;
|
|
}
|
|
if (method == MethodName._Process)
|
|
{
|
|
return true;
|
|
}
|
|
if (method == MethodName.ResetTimer)
|
|
{
|
|
return true;
|
|
}
|
|
if (method == MethodName.Shake)
|
|
{
|
|
return true;
|
|
}
|
|
return base.HasGodotClassMethod(in method);
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
protected override bool SetGodotClassPropertyValue(in godot_string_name name, in godot_variant value)
|
|
{
|
|
if (name == PropertyName.warning)
|
|
{
|
|
warning = VariantUtils.ConvertTo<Node2D>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.gearObj)
|
|
{
|
|
gearObj = VariantUtils.ConvertTo<Node2D>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.gearAnim)
|
|
{
|
|
gearAnim = VariantUtils.ConvertTo<AnimationPlayer>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.time)
|
|
{
|
|
time = VariantUtils.ConvertTo<float>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.cd)
|
|
{
|
|
cd = VariantUtils.ConvertTo<float>(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.warning)
|
|
{
|
|
value = VariantUtils.CreateFrom(in warning);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.gearObj)
|
|
{
|
|
value = VariantUtils.CreateFrom(in gearObj);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.gearAnim)
|
|
{
|
|
value = VariantUtils.CreateFrom(in gearAnim);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.time)
|
|
{
|
|
value = VariantUtils.CreateFrom(in time);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.cd)
|
|
{
|
|
value = VariantUtils.CreateFrom(in cd);
|
|
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.Object, PropertyName.warning, PropertyHint.NodeType, "Node2D", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Object, PropertyName.gearObj, PropertyHint.NodeType, "Node2D", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Object, PropertyName.gearAnim, PropertyHint.NodeType, "AnimationPlayer", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Float, PropertyName.time, PropertyHint.None, "", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Float, PropertyName.cd, PropertyHint.None, "", PropertyUsageFlags.ScriptVariable, exported: false)
|
|
};
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
protected override void SaveGodotObjectData(GodotSerializationInfo info)
|
|
{
|
|
base.SaveGodotObjectData(info);
|
|
info.AddProperty(PropertyName.warning, Variant.From(in warning));
|
|
info.AddProperty(PropertyName.gearObj, Variant.From(in gearObj));
|
|
info.AddProperty(PropertyName.gearAnim, Variant.From(in gearAnim));
|
|
info.AddProperty(PropertyName.time, Variant.From(in time));
|
|
info.AddProperty(PropertyName.cd, Variant.From(in cd));
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
protected override void RestoreGodotObjectData(GodotSerializationInfo info)
|
|
{
|
|
base.RestoreGodotObjectData(info);
|
|
if (info.TryGetProperty(PropertyName.warning, out var value))
|
|
{
|
|
warning = value.As<Node2D>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.gearObj, out var value2))
|
|
{
|
|
gearObj = value2.As<Node2D>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.gearAnim, out var value3))
|
|
{
|
|
gearAnim = value3.As<AnimationPlayer>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.time, out var value4))
|
|
{
|
|
time = value4.As<float>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.cd, out var value5))
|
|
{
|
|
cd = value5.As<float>();
|
|
}
|
|
}
|
|
}
|