Skip to content

Commit

Permalink
#608 fix bug: cactus blossom taking too long to reopen
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldgenerator7 committed Sep 10, 2024
1 parent c33555c commit 2cc42c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Assets/Scripts/EnemyAI/CactusBlossomController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
Expand Down Expand Up @@ -30,7 +31,7 @@ public float OpenPercent
openPercent = Mathf.Clamp(value, 0, 1);
}
}
private float closedWaitTime = 0;
private float closedWaitStartTime = 0;

public enum State
{
Expand Down Expand Up @@ -66,12 +67,11 @@ void Update()
if (openPercent == 0)
{
state = State.CLOSED;
closedWaitTime = 0;
closedWaitStartTime = Managers.Time.Time;
}
break;
case State.CLOSED:
closedWaitTime += (1 / closedDuration) * Time.deltaTime;
if (closedWaitTime >= closedDuration)
if (Managers.Time.Time - closedWaitStartTime >= closedDuration)
{
state = State.OPENING;
}
Expand Down Expand Up @@ -141,13 +141,13 @@ public override SavableObject CurrentState
get => new SavableObject(this,
"state", (int)state,
"openPercent", openPercent,
"closedWaitTime", closedWaitTime
"closedWaitStartTime", closedWaitStartTime
);
set
{
state = (State)value.Int("state");
openPercent = value.Float("openPercent");
closedWaitTime = value.Float("closedWaitTime");
closedWaitStartTime = value.Float("closedWaitStartTime");
placePetals(openPercent);
}
}
Expand Down

0 comments on commit 2cc42c2

Please sign in to comment.