mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-05-16 13:03:40 +08:00
08f361954a
* add missing EntityTypes * small command refactorings and improvements * move common command patterns and methods to CommandHelpers * let the spawn command detect the entityType instead of spawning every entity as EntityVehicle * add extra options for spawning gadgets for better debuging and testing * More spawn command additions and cleanups+EntityVehicle changes * Moved remaining patterns from GiveCommand and ClearCommand to CommandHelpers * Added patterns for hp, maxhp, atk, def and (monster)ai for the spawn command * Moved intParam parsing via regex to the CommandHelpers * Read most of EntityVehicle stats from the ConfigGadget instead of hardcoding them Co-authored-by: hartie95 <mail@hartie95.de>
46 lines
1.5 KiB
Java
46 lines
1.5 KiB
Java
package emu.grasscutter.game.entity;
|
|
|
|
import emu.grasscutter.data.binout.ConfigGadget;
|
|
import emu.grasscutter.game.props.FightProperty;
|
|
import emu.grasscutter.game.world.Scene;
|
|
|
|
public abstract class EntityBaseGadget extends GameEntity {
|
|
|
|
public EntityBaseGadget(Scene scene) {
|
|
super(scene);
|
|
}
|
|
|
|
public abstract int getGadgetId();
|
|
|
|
@Override
|
|
public void onDeath(int killerId) {
|
|
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
|
}
|
|
|
|
protected void fillFightProps(ConfigGadget configGadget) {
|
|
if (configGadget == null || configGadget.getCombat() == null) {
|
|
return;
|
|
}
|
|
var combatData = configGadget.getCombat();
|
|
var combatProperties = combatData.getProperty();
|
|
|
|
var targetHp = combatProperties.getHP();
|
|
setFightProperty(FightProperty.FIGHT_PROP_MAX_HP, targetHp);
|
|
setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, targetHp);
|
|
if (combatProperties.isInvincible()) {
|
|
targetHp = Float.POSITIVE_INFINITY;
|
|
}
|
|
setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, targetHp);
|
|
|
|
var atk = combatProperties.getAttack();
|
|
setFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, atk);
|
|
setFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, atk);
|
|
|
|
var def = combatProperties.getDefence();
|
|
setFightProperty(FightProperty.FIGHT_PROP_BASE_DEFENSE, def);
|
|
setFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, def);
|
|
|
|
setLockHP(combatProperties.isLockHP());
|
|
}
|
|
}
|