2022-04-17 12:43:07 +00:00
|
|
|
package emu.grasscutter.server.packet.send;
|
|
|
|
|
2022-05-06 05:07:29 +00:00
|
|
|
import emu.grasscutter.game.avatar.Avatar;
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.game.entity.GameEntity;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.game.props.LifeState;
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.net.packet.BasePacket;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
|
|
|
import emu.grasscutter.net.proto.LifeStateChangeNotifyOuterClass.LifeStateChangeNotify;
|
2022-05-06 05:07:29 +00:00
|
|
|
import emu.grasscutter.net.proto.PlayerDieTypeOuterClass.PlayerDieType;
|
|
|
|
import emu.grasscutter.net.proto.ServerBuffOuterClass.ServerBuff;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public class PacketLifeStateChangeNotify extends BasePacket {
|
|
|
|
public PacketLifeStateChangeNotify(GameEntity attacker, GameEntity target, LifeState lifeState) {
|
2022-04-17 12:43:07 +00:00
|
|
|
super(PacketOpcodes.LifeStateChangeNotify);
|
|
|
|
|
|
|
|
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
|
|
|
|
.setEntityId(target.getId())
|
|
|
|
.setLifeState(lifeState.getValue())
|
|
|
|
.setSourceEntityId(attacker.getId())
|
|
|
|
.build();
|
|
|
|
|
|
|
|
this.setData(proto);
|
|
|
|
}
|
2022-04-27 04:21:57 +00:00
|
|
|
public PacketLifeStateChangeNotify(int attackerId, GameEntity target, LifeState lifeState) {
|
2022-04-17 12:43:07 +00:00
|
|
|
super(PacketOpcodes.LifeStateChangeNotify);
|
|
|
|
|
|
|
|
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
|
|
|
|
.setEntityId(target.getId())
|
|
|
|
.setLifeState(lifeState.getValue())
|
|
|
|
.setSourceEntityId(attackerId)
|
|
|
|
.build();
|
2022-05-06 05:07:29 +00:00
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
this.setData(proto);
|
|
|
|
}
|
2022-05-06 05:07:29 +00:00
|
|
|
|
|
|
|
public PacketLifeStateChangeNotify(GameEntity entity, LifeState lifeState, PlayerDieType dieType) {
|
|
|
|
this(entity, lifeState, null, "", dieType);
|
|
|
|
}
|
|
|
|
|
|
|
|
public PacketLifeStateChangeNotify(GameEntity entity, LifeState lifeState, GameEntity sourceEntity,
|
|
|
|
String attackTag, PlayerDieType dieType) {
|
|
|
|
super(PacketOpcodes.LifeStateChangeNotify);
|
|
|
|
|
|
|
|
LifeStateChangeNotify.Builder proto = LifeStateChangeNotify.newBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
proto.setEntityId(entity.getId());
|
|
|
|
proto.setLifeState(lifeState.getValue());
|
|
|
|
if (sourceEntity != null) {
|
|
|
|
proto.setSourceEntityId(sourceEntity.getId());
|
|
|
|
}
|
|
|
|
proto.setAttackTag(attackTag);
|
|
|
|
proto.setDieType(dieType);
|
|
|
|
|
|
|
|
this.setData(proto.build());
|
|
|
|
}
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|