102 lines
1.9 KiB
C#
102 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Loadzone.cs")]
|
|
public partial class Loadzone : Area2D, Interacteable
|
|
{
|
|
public enum Trigger
|
|
{
|
|
Touch,
|
|
Interact
|
|
}
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Trigger trigger;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Room.IDs target;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D linked;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D blocker;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Entity.Direction direction = Entity.Direction.None;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Vector2 pos;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStream[] sounds;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private SaveFile.Flags setFlag = SaveFile.Flags.None;
|
|
|
|
public void Interact()
|
|
{
|
|
if (trigger == Trigger.Interact)
|
|
{
|
|
Warp();
|
|
}
|
|
else
|
|
{
|
|
Player.instance.canInput = true;
|
|
}
|
|
}
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
if (trigger == Trigger.Touch)
|
|
{
|
|
base.BodyEntered += Touch;
|
|
}
|
|
}
|
|
|
|
private void Touch(Node other)
|
|
{
|
|
if (Main.inEvent == null && other == Player.instance.controlling)
|
|
{
|
|
Warp();
|
|
}
|
|
}
|
|
|
|
private void Warp()
|
|
{
|
|
if (setFlag != SaveFile.Flags.None)
|
|
{
|
|
SaveFile.AddFlag(setFlag);
|
|
}
|
|
if (Player.instance.controlling != Player.instance || Player.instance.splitEntity != null)
|
|
{
|
|
Main.inEvent = Coroutine.Start(CantLeave());
|
|
return;
|
|
}
|
|
if (linked != null)
|
|
{
|
|
pos = linked.GlobalPosition;
|
|
}
|
|
Main.inEvent = Coroutine.Start(Room.SwitchRooms(target, pos, direction, lockMovement: false, sounds));
|
|
}
|
|
|
|
private IEnumerator CantLeave()
|
|
{
|
|
TextSystem.GetText("CantLeaveKanako");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Player.instance.DoAutoMove(blocker.GlobalPosition, 0.75f);
|
|
while (Player.instance.moving != null)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
}
|