Add drowning. Better movement ticking.

This commit is contained in:
gentlespoon
2022-05-05 22:07:29 -07:00
committed by Melledy
parent 81998b9cf9
commit 93b3265d72
10 changed files with 485 additions and 296 deletions

View File

@@ -21,7 +21,7 @@ import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.Inventory;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.game.mail.MailHandler;
import emu.grasscutter.game.managers.MotionManager.MotionManager;
import emu.grasscutter.game.managers.MovementManager.MovementManager;
import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.game.props.EntityType;
import emu.grasscutter.game.props.PlayerProperty;
@@ -122,7 +122,7 @@ public class Player {
@Transient private final InvokeHandler<AbilityInvokeEntry> clientAbilityInitFinishHandler;
private MapMarksManager mapMarksManager;
@Transient private MotionManager motionManager;
@Transient private MovementManager movementManager;
@Deprecated
@@ -164,7 +164,7 @@ public class Player {
this.shopLimit = new ArrayList<>();
this.messageHandler = null;
this.mapMarksManager = new MapMarksManager();
this.motionManager = new MotionManager(this);
this.movementManager = new MovementManager(this);
}
// On player creation
@@ -191,7 +191,7 @@ public class Player {
this.getRotation().set(0, 307, 0);
this.messageHandler = null;
this.mapMarksManager = new MapMarksManager();
this.motionManager = new MotionManager(this);
this.movementManager = new MovementManager(this);
}
public int getUid() {
@@ -974,7 +974,7 @@ public class Player {
return mapMarksManager;
}
public MotionManager getMotionManager() { return motionManager; }
public MovementManager getMovementManager() { return movementManager; }
public synchronized void onTick() {
// Check ping
@@ -1004,33 +1004,9 @@ public class Player {
this.resetSendPlayerLocTime();
}
}
scheduleStaminaNotify();
}
private void scheduleStaminaNotify() {
// stamina tick
EntityMoveInfoOuterClass.EntityMoveInfo moveInfo = getMotionManager().getMoveInfo();
if (moveInfo == null) {
return;
}
if (getMotionManager().getMoveInfo().getMotionInfo().getState() == MotionStateOuterClass.MotionState.MOTION_STANDBY) {
if (getProperty(PlayerProperty.PROP_CUR_PERSIST_STAMINA) == getProperty(PlayerProperty.PROP_MAX_STAMINA) ) {
return;
}
}
for (int i = 0; i <= 1000; i+=200) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
getMotionManager().tick();
}
}, i);
}
}
public void resetSendPlayerLocTime() {