mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 02:55:54 +00:00
Level Teleporters
This commit is contained in:
parent
5e357e1a96
commit
7a8bb4311b
26 changed files with 581 additions and 410 deletions
48
Scripts/Activables/3D/LevelTeleporter3D.cs
Normal file
48
Scripts/Activables/3D/LevelTeleporter3D.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Activables._3D;
|
||||
|
||||
[Tool]
|
||||
public partial class LevelTeleporter3D : Teleporter3D
|
||||
{
|
||||
[Export] public bool SaveInventory { get; set; }
|
||||
|
||||
public override void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
{
|
||||
// TargetGroup = props["target"].AsString();
|
||||
//
|
||||
// TargetName = props["targetname"].AsString();
|
||||
IsEnabled = props["enabled"].AsBool();
|
||||
}
|
||||
|
||||
protected override async Task Teleport(IsoPlayerStateMachine player)
|
||||
{
|
||||
player.SetState(PlayerState.Cutscene);
|
||||
await TweenPlayer(player.MainObject);
|
||||
|
||||
PlayTeleportStartSound();
|
||||
FireParticles();
|
||||
|
||||
player.SetState(PlayerState.Teleporting);
|
||||
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
await Task.Delay((int)(TeleportAnimationLength * 1000));
|
||||
|
||||
if (SaveInventory)
|
||||
{
|
||||
// Save inventory
|
||||
GlobalState.Instance.SessionSettings.Items = InventoryManager.Instance.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalState.Instance.SessionSettings.EquippedWeaponId = string.Empty;
|
||||
}
|
||||
|
||||
var nextMap = GlobalState.Instance.MapsDatabase.FindNextMap(GlobalState.Instance.SessionSettings.MapId);
|
||||
GlobalState.Instance.GotoScene(nextMap);
|
||||
}
|
||||
}
|
||||
1
Scripts/Activables/3D/LevelTeleporter3D.cs.uid
Normal file
1
Scripts/Activables/3D/LevelTeleporter3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c4e21ceehvqap
|
||||
|
|
@ -35,7 +35,7 @@ public partial class Teleporter3D : StaticBody3D, IActivable, ITargetable
|
|||
|
||||
[Export] public StringName DefaultAnimationName { get; private set; } = "Default";
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
public virtual void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
{
|
||||
TargetGroup = props["target"].AsString();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Cirno.Scripts.Activables;
|
|||
public partial class LevelTeleporter : Teleporter
|
||||
{
|
||||
[Export] public string LevelPath { get; set; }
|
||||
[Export] public MapResource Map { get; private set; }
|
||||
[Export] public MapResource Map { get; private set; }
|
||||
|
||||
[Export] public bool SaveInventory { get; set; }
|
||||
|
||||
|
|
@ -47,13 +47,12 @@ public partial class LevelTeleporter : Teleporter
|
|||
{
|
||||
GlobalState.Instance.SessionSettings.LevelNumber += 1;
|
||||
}
|
||||
|
||||
|
||||
GlobalState.Instance.GotoScene(LevelPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalState.Instance.GotoScene(Map);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue