mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:35:34 +00:00
Spawn markers in level
This commit is contained in:
parent
f7448eb3f5
commit
4b65b25dcd
18 changed files with 335 additions and 197 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Actors._3D;
|
||||
|
||||
|
|
@ -7,6 +8,20 @@ public partial class PlayerStartMarker3D : Marker3D
|
|||
{
|
||||
private readonly Vector3 _boxSize = new Vector3(0.5f, 0.8f, 0.5f);
|
||||
|
||||
[Export] public int MarkerId { get; set; } = 0;
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
{
|
||||
//GroupName = (string)props["targetname"];
|
||||
this.AddToGroup("SpawnMarkers");
|
||||
MarkerId = props["id"].AsInt32();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
this.AddToGroup("SpawnMarkers");
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (!Engine.IsEditorHint()) return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using Cirno.Scripts.Actors._3D;
|
||||
using Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Misc;
|
||||
|
|
@ -223,17 +224,27 @@ public partial class GameController : Node
|
|||
|
||||
private Vector3 GetStartPosition()
|
||||
{
|
||||
if (MapResource != null)
|
||||
{
|
||||
if (SpawnMarkers.TryGetValue(EggStartIndex, out var spawnMarker))
|
||||
{
|
||||
var marker = GetNode<Node3D>(spawnMarker);
|
||||
var spawners = GetTree().GetNodesInGroup("SpawnMarkers").Cast<PlayerStartMarker3D>().ToList();
|
||||
|
||||
return marker.Position; // Why position and not globalposition? I have no idea
|
||||
}
|
||||
if (spawners.Count == 0)
|
||||
{
|
||||
return Vector3.Zero;
|
||||
}
|
||||
|
||||
var m = GetNode<Node3D>(SpawnMarkers.First().Value);
|
||||
return m.GlobalPosition;
|
||||
var spawnerToUse = spawners.FirstOrDefault(x => x.MarkerId == EggStartIndex) ?? spawners[0];
|
||||
return spawnerToUse.GlobalPosition;
|
||||
|
||||
// if (MapResource != null)
|
||||
// {
|
||||
// if (SpawnMarkers.TryGetValue(EggStartIndex, out var spawnMarker))
|
||||
// {
|
||||
// var marker = GetNode<Node3D>(spawnMarker);
|
||||
//
|
||||
// return marker.Position; // Why position and not globalposition? I have no idea
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// var m = GetNode<Node3D>(SpawnMarkers.First().Value);
|
||||
// return m.GlobalPosition;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue