mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 00:45:55 +00:00
optimizations
This commit is contained in:
parent
91e063c01b
commit
eb1d74ee63
7 changed files with 33 additions and 6 deletions
|
|
@ -2,6 +2,7 @@ using Godot;
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
|
||||
|
|
@ -13,7 +14,7 @@ public partial class Interactable : Area2D
|
|||
|
||||
public override void _Ready()
|
||||
{
|
||||
_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
_inventoryManager = this.GetInventoryManager();
|
||||
}
|
||||
|
||||
protected bool MeetsRequirements()
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ size = Vector2(14, 28)
|
|||
size = Vector2(12, 24)
|
||||
|
||||
[node name="Red Box" type="Area2D" groups=["Destroyable"]]
|
||||
y_sort_enabled = true
|
||||
position = Vector2(0, -9)
|
||||
collision_layer = 64
|
||||
collision_mask = 10
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ radius = 17.2627
|
|||
radius = 1.0
|
||||
|
||||
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle", "EquippedWeapon") groups=["Destroyable", "player"]]
|
||||
y_sort_enabled = true
|
||||
collision_layer = 2
|
||||
collision_mask = 99
|
||||
script = ExtResource("1_m27vu")
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -57,8 +57,8 @@ public partial class Enemy : CharacterBody2D
|
|||
_currentHealth = Health;
|
||||
|
||||
_navigationAgent = GetNodeOrNull<NavigationAgent2D>("NavigationAgent2D");
|
||||
|
||||
_alarmManager = GetNodeOrNull<AlarmManager>("/root/GameScene/AlarmManager");
|
||||
|
||||
_alarmManager = this.GetAlarmManager();
|
||||
|
||||
if (_alarmManager != null)
|
||||
{
|
||||
|
|
@ -66,6 +66,12 @@ public partial class Enemy : CharacterBody2D
|
|||
}
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
if (_alarmManager == null) return;
|
||||
_alarmManager.AlarmEnabled -= AlarmManagerOnAlarmEnabled;
|
||||
}
|
||||
|
||||
private void AlarmManagerOnAlarmEnabled(Vector2 location)
|
||||
{
|
||||
if (NavigationEnabled && location.DistanceTo(this.GlobalPosition) <= AlarmReactRange)
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
if (SelectorScene != null)
|
||||
{
|
||||
_selector = this.CreateSibling<Selector>(SelectorScene, this.GlobalPosition);
|
||||
_selector.Visible = true;
|
||||
_selector.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,4 +66,14 @@ public static class Tools
|
|||
{
|
||||
return node.GetNode<GameManager>("/root/GameScene");
|
||||
}
|
||||
|
||||
public static AlarmManager GetAlarmManager(this Node2D node)
|
||||
{
|
||||
return node.GetNodeOrNull<AlarmManager>("/root/GameScene/AlarmManager");
|
||||
}
|
||||
|
||||
public static InventoryManager GetInventoryManager(this Node2D node)
|
||||
{
|
||||
return node.GetNodeOrNull<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue