mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-14 14:24:37 +01:00
Refactor GameAvatar
This commit is contained in:
@@ -32,6 +32,7 @@ import emu.lunarcore.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||
import emu.lunarcore.proto.SpBarInfoOuterClass.SpBarInfo;
|
||||
import emu.lunarcore.proto.VectorOuterClass.Vector;
|
||||
import emu.lunarcore.server.packet.send.PacketPlayerSyncScNotify;
|
||||
import emu.lunarcore.util.Position;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -112,12 +113,22 @@ public class GameAvatar implements GameEntity {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPos() {
|
||||
return this.getOwner().getPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getRot() {
|
||||
return this.getOwner().getRot();
|
||||
}
|
||||
|
||||
public boolean isHero() {
|
||||
return GameData.getHeroExcelMap().containsKey(this.getAvatarId());
|
||||
}
|
||||
@@ -269,7 +280,7 @@ public class GameAvatar implements GameEntity {
|
||||
public SceneEntityInfo toSceneEntityProto() {
|
||||
var proto = SceneEntityInfo.newInstance()
|
||||
.setEntityId(this.getEntityId())
|
||||
.setMotion(MotionInfo.newInstance().setPos(getOwner().getPos().toProto()).setRot(getOwner().getRot().toProto()))
|
||||
.setMotion(MotionInfo.newInstance().setPos(this.getPos().toProto()).setRot(this.getRot().toProto()))
|
||||
.setActor(SceneActorInfo.newInstance().setBaseAvatarId(this.getAvatarId()).setAvatarType(AvatarType.AVATAR_FORMAL_TYPE));
|
||||
|
||||
return proto;
|
||||
|
||||
@@ -2,6 +2,7 @@ package emu.lunarcore.game.scene.entity;
|
||||
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
import emu.lunarcore.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||
import emu.lunarcore.util.Position;
|
||||
|
||||
public interface GameEntity {
|
||||
|
||||
@@ -10,6 +11,10 @@ public interface GameEntity {
|
||||
public void setEntityId(int id);
|
||||
|
||||
public Scene getScene();
|
||||
|
||||
public Position getPos();
|
||||
|
||||
public Position getRot();
|
||||
|
||||
public default int getGroupId() {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user