This commit is contained in:
Marco 2025-02-21 18:57:00 +01:00
commit b07a8fe60d
33 changed files with 594 additions and 58 deletions

View file

@ -45,6 +45,13 @@ public partial class Door : Activable
//_solidShape.Disabled = false;
}
public void Destroy()
{
_animatedSprite.Play("Destroyed");
State = DoorState.Destroyed;
CallDeferred(MethodName.DeferredDisableCollision, true);
}
private void DeferredDisableCollision(bool state)
{
_collisionShape.Disabled = state;
@ -56,30 +63,44 @@ public partial class Door : Activable
switch (activationType)
{
case ActivationType.Toggle:
switch (State)
{
case DoorState.Closed:
Open();
break;
case DoorState.Open:
Close();
break;
default:
throw new ArgumentOutOfRangeException();
}
ToggleDoor();
break;
case ActivationType.Enable:
Open();
break;
case ActivationType.Disable:
Close();
break;
case ActivationType.Disable:
Open();
break;
case ActivationType.Use:
ToggleDoor();
break;
case ActivationType.Destroy:
Destroy();
break;
case ActivationType.Open:
Open();
break;
case ActivationType.Close:
Close();
break;
default:
throw new ArgumentOutOfRangeException(nameof(activationType), activationType, null);
ToggleDoor();
break;
}
}
private void ToggleDoor()
{
switch (State)
{
case DoorState.Closed:
Open();
break;
case DoorState.Open:
Close();
break;
default:
throw new ArgumentOutOfRangeException();
}
}
@ -93,6 +114,9 @@ public partial class Door : Activable
case DoorState.Open:
Open();
break;
case DoorState.Destroyed:
Destroy();
break;
default:
throw new ArgumentOutOfRangeException();
}
@ -117,5 +141,6 @@ public partial class Door : Activable
public enum DoorState
{
Closed,
Open
Open,
Destroyed
}