372 lines
11 KiB
C#
372 lines
11 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.Collections;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/ShopCaller.cs")]
|
|
public class ShopCaller : Check
|
|
{
|
|
public enum Type
|
|
{
|
|
Auto = -1,
|
|
SchoolDW,
|
|
ChujinDW1,
|
|
ChujinDW2,
|
|
PenGuy,
|
|
PenGuy2
|
|
}
|
|
|
|
public new class MethodName : Check.MethodName
|
|
{
|
|
public new static readonly StringName Interact = "Interact";
|
|
|
|
public static readonly StringName CallShop = "CallShop";
|
|
}
|
|
|
|
public new class PropertyName : Check.PropertyName
|
|
{
|
|
public static readonly StringName sprite = "sprite";
|
|
|
|
public static readonly StringName bgType = "bgType";
|
|
|
|
public static readonly StringName dialog = "dialog";
|
|
|
|
public static readonly StringName items = "items";
|
|
|
|
public static readonly StringName music = "music";
|
|
|
|
public static readonly StringName bleep = "bleep";
|
|
|
|
public static readonly StringName direction = "direction";
|
|
|
|
public static readonly StringName talkReplacers = "talkReplacers";
|
|
|
|
public static readonly StringName talkSetFlag = "talkSetFlag";
|
|
|
|
public static readonly StringName shop = "shop";
|
|
}
|
|
|
|
public new class SignalName : Check.SignalName
|
|
{
|
|
}
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Type sprite;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Type bgType = Type.Auto;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Type dialog = Type.Auto;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public ShopItems[] items;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public AudioStream music;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public AudioStream bleep;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Entity.Direction direction;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Array<int[]> talkReplacers;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Array<int[]> talkSetFlag;
|
|
|
|
private Shop shop;
|
|
|
|
public override void Interact()
|
|
{
|
|
if (CanDo())
|
|
{
|
|
CallShop();
|
|
}
|
|
else
|
|
{
|
|
Player.instance.canInput = true;
|
|
}
|
|
}
|
|
|
|
public void CallShop()
|
|
{
|
|
Main.inEvent = Coroutine.Start(DoShop());
|
|
}
|
|
|
|
private IEnumerator DoShop()
|
|
{
|
|
Party.StopMoving();
|
|
CameraController.Transition(Main.colorBlack, 30f, 1000);
|
|
while (!CameraController.transitionRoutine.done)
|
|
{
|
|
yield return null;
|
|
}
|
|
for (float a = 0f; a < 15f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
shop = GD.Load<PackedScene>("res://Objects/UI/Shop.tscn").Instantiate<Shop>(PackedScene.GenEditState.Disabled);
|
|
shop.SetUp(this);
|
|
CameraController.instance.AddChild(shop, forceReadableName: false, InternalMode.Disabled);
|
|
while (GodotObject.IsInstanceValid(shop))
|
|
{
|
|
yield return null;
|
|
}
|
|
Player.instance.direction = direction;
|
|
Player.instance.UpdateAnim(force: true);
|
|
for (float a = 0f; a < 15f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
Room.current.DoMusic();
|
|
CameraController.Transition(Main.colorClearB, 30f, 1000);
|
|
while (!CameraController.transitionRoutine.done)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
internal new static List<MethodInfo> GetGodotMethodList()
|
|
{
|
|
return new List<MethodInfo>(2)
|
|
{
|
|
new MethodInfo(MethodName.Interact, new PropertyInfo(Variant.Type.Nil, "", PropertyHint.None, "", PropertyUsageFlags.Default, exported: false), MethodFlags.Normal, null, null),
|
|
new MethodInfo(MethodName.CallShop, 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.Interact && args.Count == 0)
|
|
{
|
|
Interact();
|
|
ret = default(godot_variant);
|
|
return true;
|
|
}
|
|
if (method == MethodName.CallShop && args.Count == 0)
|
|
{
|
|
CallShop();
|
|
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.Interact)
|
|
{
|
|
return true;
|
|
}
|
|
if (method == MethodName.CallShop)
|
|
{
|
|
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.sprite)
|
|
{
|
|
sprite = VariantUtils.ConvertTo<Type>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.bgType)
|
|
{
|
|
bgType = VariantUtils.ConvertTo<Type>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.dialog)
|
|
{
|
|
dialog = VariantUtils.ConvertTo<Type>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.items)
|
|
{
|
|
items = VariantUtils.ConvertToSystemArrayOfGodotObject<ShopItems>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.music)
|
|
{
|
|
music = VariantUtils.ConvertTo<AudioStream>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.bleep)
|
|
{
|
|
bleep = VariantUtils.ConvertTo<AudioStream>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.direction)
|
|
{
|
|
direction = VariantUtils.ConvertTo<Entity.Direction>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.talkReplacers)
|
|
{
|
|
talkReplacers = VariantUtils.ConvertToArray<int[]>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.talkSetFlag)
|
|
{
|
|
talkSetFlag = VariantUtils.ConvertToArray<int[]>(in value);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.shop)
|
|
{
|
|
shop = VariantUtils.ConvertTo<Shop>(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.sprite)
|
|
{
|
|
value = VariantUtils.CreateFrom(in sprite);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.bgType)
|
|
{
|
|
value = VariantUtils.CreateFrom(in bgType);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.dialog)
|
|
{
|
|
value = VariantUtils.CreateFrom(in dialog);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.items)
|
|
{
|
|
GodotObject[] array = items;
|
|
value = VariantUtils.CreateFromSystemArrayOfGodotObject(array);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.music)
|
|
{
|
|
value = VariantUtils.CreateFrom(in music);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.bleep)
|
|
{
|
|
value = VariantUtils.CreateFrom(in bleep);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.direction)
|
|
{
|
|
value = VariantUtils.CreateFrom(in direction);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.talkReplacers)
|
|
{
|
|
value = VariantUtils.CreateFromArray(talkReplacers);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.talkSetFlag)
|
|
{
|
|
value = VariantUtils.CreateFromArray(talkSetFlag);
|
|
return true;
|
|
}
|
|
if (name == PropertyName.shop)
|
|
{
|
|
value = VariantUtils.CreateFrom(in shop);
|
|
return true;
|
|
}
|
|
return base.GetGodotClassPropertyValue(in name, out value);
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
internal new static List<PropertyInfo> GetGodotPropertyList()
|
|
{
|
|
return new List<PropertyInfo>
|
|
{
|
|
new PropertyInfo(Variant.Type.Int, PropertyName.sprite, PropertyHint.Enum, "Auto:-1,SchoolDW:0,ChujinDW1:1,ChujinDW2:2,PenGuy:3,PenGuy2:4", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Int, PropertyName.bgType, PropertyHint.Enum, "Auto:-1,SchoolDW:0,ChujinDW1:1,ChujinDW2:2,PenGuy:3,PenGuy2:4", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Int, PropertyName.dialog, PropertyHint.Enum, "Auto:-1,SchoolDW:0,ChujinDW1:1,ChujinDW2:2,PenGuy:3,PenGuy2:4", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Array, PropertyName.items, PropertyHint.TypeString, "24/17:ShopItems", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Object, PropertyName.music, PropertyHint.ResourceType, "AudioStream", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Object, PropertyName.bleep, PropertyHint.ResourceType, "AudioStream", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Int, PropertyName.direction, PropertyHint.Enum, "South:0,North:1,East:2,West:3,Side:4,None:-1", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Array, PropertyName.talkReplacers, PropertyHint.TypeString, "30/0:", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Array, PropertyName.talkSetFlag, PropertyHint.TypeString, "30/0:", PropertyUsageFlags.Default | PropertyUsageFlags.ScriptVariable, exported: true),
|
|
new PropertyInfo(Variant.Type.Object, PropertyName.shop, PropertyHint.None, "", PropertyUsageFlags.ScriptVariable, exported: false)
|
|
};
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
protected override void SaveGodotObjectData(GodotSerializationInfo info)
|
|
{
|
|
base.SaveGodotObjectData(info);
|
|
info.AddProperty(PropertyName.sprite, Variant.From(in sprite));
|
|
info.AddProperty(PropertyName.bgType, Variant.From(in bgType));
|
|
info.AddProperty(PropertyName.dialog, Variant.From(in dialog));
|
|
StringName name = PropertyName.items;
|
|
GodotObject[] array = items;
|
|
info.AddProperty(name, Variant.CreateFrom(array));
|
|
info.AddProperty(PropertyName.music, Variant.From(in music));
|
|
info.AddProperty(PropertyName.bleep, Variant.From(in bleep));
|
|
info.AddProperty(PropertyName.direction, Variant.From(in direction));
|
|
info.AddProperty(PropertyName.talkReplacers, Variant.CreateFrom(talkReplacers));
|
|
info.AddProperty(PropertyName.talkSetFlag, Variant.CreateFrom(talkSetFlag));
|
|
info.AddProperty(PropertyName.shop, Variant.From(in shop));
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
protected override void RestoreGodotObjectData(GodotSerializationInfo info)
|
|
{
|
|
base.RestoreGodotObjectData(info);
|
|
if (info.TryGetProperty(PropertyName.sprite, out var value))
|
|
{
|
|
sprite = value.As<Type>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.bgType, out var value2))
|
|
{
|
|
bgType = value2.As<Type>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.dialog, out var value3))
|
|
{
|
|
dialog = value3.As<Type>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.items, out var value4))
|
|
{
|
|
items = value4.AsGodotObjectArray<ShopItems>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.music, out var value5))
|
|
{
|
|
music = value5.As<AudioStream>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.bleep, out var value6))
|
|
{
|
|
bleep = value6.As<AudioStream>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.direction, out var value7))
|
|
{
|
|
direction = value7.As<Entity.Direction>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.talkReplacers, out var value8))
|
|
{
|
|
talkReplacers = value8.AsGodotArray<int[]>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.talkSetFlag, out var value9))
|
|
{
|
|
talkSetFlag = value9.AsGodotArray<int[]>();
|
|
}
|
|
if (info.TryGetProperty(PropertyName.shop, out var value10))
|
|
{
|
|
shop = value10.As<Shop>();
|
|
}
|
|
}
|
|
}
|