Ruined Town Sectors fix, Dark Wood - Sectors

This commit is contained in:
szczuras4
2025-12-05 06:16:25 +01:00
parent 06ae2e180e
commit 53fa05e246
4 changed files with 1005 additions and 1102 deletions

View File

@@ -7,6 +7,9 @@ namespace Beyond
[RequireComponent(typeof(BoxCollider))]
public class BoxVolume : StreamingAsset
{
// DODANE: Licznik koliderów wewn¹trz woluminu
private int enteredCollidersCount = 0;
protected override void Draw()
{
if (collider == null)
@@ -49,9 +52,13 @@ namespace Beyond
protected override void OnTriggerEnter(Collider other)
{
if (collisionLayer == 1 << other.gameObject.layer)
// Sprawdzenie warunków kolizji
if (collisionLayer == 1 << other.gameObject.layer && tagMask.IsInTagMask(other.tag))
{
if (tagMask.IsInTagMask(other.tag))
enteredCollidersCount++;
// Aktywacja nastêpuje tylko przy pierwszym wejœciu (licznik = 1)
if (enteredCollidersCount == 1)
{
CancelDeactivationCoroutine();
SetActive(true);
@@ -61,13 +68,20 @@ namespace Beyond
protected override void OnTriggerExit(Collider other)
{
if (collisionLayer == 1 << other.gameObject.layer)
// Sprawdzenie warunków kolizji
if (collisionLayer == 1 << other.gameObject.layer && tagMask.IsInTagMask(other.tag))
{
if (tagMask.IsInTagMask(other.tag))
enteredCollidersCount--;
// Zabezpieczenie na wypadek b³êdu fizyki
if (enteredCollidersCount < 0) enteredCollidersCount = 0;
// Dezaktywacja nastêpuje tylko, gdy ostatni obiekt opuœci wolumin (licznik = 0)
if (enteredCollidersCount == 0)
{
SetActive(false);
}
}
}
}
}
}