-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StaminaManager update #680
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass, logging related changes
int maxDelay = 200; | ||
long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond; | ||
Grasscutter.getLogger().debug("MOTION_FALL_ON_GROUND received after " + actualDelay + "/" + maxDelay + "ms." + (actualDelay > maxDelay ? " Discard" : "")); | ||
Grasscutter.getLogger().trace("MOTION_FALL_ON_GROUND received after " + actualDelay + "/" + maxDelay + "ms." + (actualDelay > maxDelay ? " Discard" : "")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be left as DEBUG
actually.
float newHP = currentHP - damage; | ||
if (newHP < 0) { | ||
newHP = 0; | ||
} | ||
Grasscutter.getLogger().debug(currentHP + "/" + maxHP + "\t" + "\tDamage: " + damage + "\tnewHP: " + newHP); | ||
if (damageFactor > 0) { | ||
Grasscutter.getLogger().debug(currentHP + "/" + maxHP + "\tLandingSpeed: " + cachedLandingSpeed + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see particular reason to keep DEBUG
here specifically for damageFactor > 0
, however regardless of whether it'll be kept or not, there should be some indication on where the log message is coming from, as it is otherwise not clear at all (just bunch of numbers).
} | ||
|
||
private boolean isPlayerMoving() { | ||
float diffX = currentCoordinates.getX() - previousCoordinates.getX(); | ||
float diffY = currentCoordinates.getY() - previousCoordinates.getY(); | ||
float diffZ = currentCoordinates.getZ() - previousCoordinates.getZ(); | ||
Grasscutter.getLogger().debug("isPlayerMoving: " + previousCoordinates + ", " + currentCoordinates + | ||
Grasscutter.getLogger().trace("isPlayerMoving: " + previousCoordinates + ", " + currentCoordinates + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs indication on where it came from, I propose StaminaManager::isPlayerMoving
. isPlayerMoving
alone is pretty generic name that I don't doubt will be reused.
int playerMaxStamina = player.getProperty(PlayerProperty.PROP_MAX_STAMINA); | ||
Grasscutter.getLogger().debug(currentStamina + "/" + playerMaxStamina + "\t" + currentState + "\t" + | ||
Grasscutter.getLogger().trace(currentStamina + "/" + playerMaxStamina + "\t" + currentState + "\t" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indication here too ([StaminaManager]
?)
for (Map.Entry<String, BeforeUpdateStaminaListener> listener : beforeUpdateStaminaListeners.entrySet()) { | ||
int overriddenNewStamina = listener.getValue().onBeforeUpdateStamina(reason, newStamina); | ||
if (overriddenNewStamina != newStamina) { | ||
Grasscutter.getLogger().debug("[StaminaManager] Stamina update absolute(" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be too verbose?
if (!player.isPaused() && sustainedStaminaHandlerTimer == null) { | ||
sustainedStaminaHandlerTimer = new Timer(); | ||
sustainedStaminaHandlerTimer.scheduleAtFixedRate(new SustainedStaminaHandler(), 0, 200); | ||
Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer started"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MovementManager
is StaminaManager
now.
sustainedStaminaHandlerTimer.cancel(); | ||
// Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer stopped"); | ||
sustainedStaminaHandlerTimer = null; | ||
Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer stopped"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MovementManager
is StaminaManager
now.
@@ -218,22 +292,30 @@ public void run() { | |||
int currentStamina = player.getProperty(PlayerProperty.PROP_CUR_PERSIST_STAMINA); | |||
int maxStamina = player.getProperty(PlayerProperty.PROP_MAX_STAMINA); | |||
if (moving || (currentStamina < maxStamina)) { | |||
Grasscutter.getLogger().debug("Player moving: " + moving + ", stamina full: " + | |||
Grasscutter.getLogger().trace("Player moving: " + moving + ", stamina full: " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indication here too ([StaminaManager]
?)
Fix stamina consumption log flooding problem.
Changes for allowing stamina consumption override.
Add TODO's in StaminaManager.
Type of changes
Checklist: