mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-03 22:15:55 +00:00
Delay npc initialization
This commit is contained in:
parent
d1d3a3fdd5
commit
db50df369f
13 changed files with 125 additions and 31 deletions
|
|
@ -19,9 +19,16 @@ public partial class PlayerDetectionModule : Area2D
|
|||
|
||||
//public bool PlayerInActiveArea { get; private set; }
|
||||
private CollisionShape2D _collisionShape2D;
|
||||
|
||||
private bool _initialized = false;
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
CallDeferred(MethodName.Initialize);
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public void SetRange(float range)
|
||||
|
|
@ -35,6 +42,7 @@ public partial class PlayerDetectionModule : Area2D
|
|||
|
||||
public bool IsPlayerInRange(float range)
|
||||
{
|
||||
if (!_initialized) return false;
|
||||
if (GameManager.Instance is null) return false;
|
||||
|
||||
if (!GameManager.Instance.PlayerPosition.HasValue)
|
||||
|
|
@ -47,6 +55,7 @@ public partial class PlayerDetectionModule : Area2D
|
|||
|
||||
public bool IsPlayerInSight()
|
||||
{
|
||||
if (!_initialized) return false;
|
||||
if (GameManager.Instance is null) return false;
|
||||
//if (_cachedPlayer == null) return false;
|
||||
if (!GameManager.Instance.PlayerPosition.HasValue) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue