diff --git a/src/main/java/cactusServer/entities/Player.java b/src/main/java/cactusServer/entities/Player.java index 03e3b81..2eb5b84 100644 --- a/src/main/java/cactusServer/entities/Player.java +++ b/src/main/java/cactusServer/entities/Player.java @@ -1,34 +1,36 @@ package cactusServer.entities; - + import org.ntlab.radishforandroidstudio.framework.gameMain.OvergroundActor; import org.ntlab.radishforandroidstudio.framework.model3D.Object3D; import org.ntlab.radishforandroidstudio.framework.model3D.Position3D; import org.ntlab.radishforandroidstudio.framework.model3D.Quaternion3D; import org.ntlab.radishforandroidstudio.java3d.Box; import org.ntlab.radishforandroidstudio.java3d.Primitive; - + import cactusServer.models.CharacterModelManager; import cactusServer.models.Instances; import net.arnx.jsonic.JSONHint; - + public class Player extends Entity3D { private String instanceID; private String characterID; private String areaURI; + private Object3D object; private Position3D position; private Quaternion3D angle; private CameraState cameraState; private EmoteState emoteState; + private Primitive prim; private long lastUpdateTime = System.nanoTime(); @JSONHint(ignore = true) public static final int UNIQUE_ID_LENGTH = 12; @JSONHint(ignore = true) public static final long STOP_TIME_LIMIT = (long) (30 * 1e+9); - + private Player() { // JSONDecode���̌Ăяo���p } - + public Player(String instanceID, String characterID, CameraState cameraState, EmoteState.EmoteType animationClassToStart) { setInstanceID(instanceID); @@ -47,50 +49,51 @@ initPlaceable(character.getModelID()); readCharacterData(character); } - + private void initPlaceable(int modelID) { // ����Ȋ����œ��Y�R���X�g���N�^�̍Ō��placeable�̒������s�� Object3D body = CharacterModelManager.getInstance().getCharacterModel(modelID).createObject(); setPlaceable(new OvergroundActor(body, null)); + setObject(body); } - + public String getInstanceID() { return instanceID; } - + public String getCharacterID() { return characterID; } - + public String getAreaURI() { return areaURI; } - + public Position3D getPosition() { return position; } - + public Quaternion3D getAngle() { return angle; } - + public CameraState getCameraState() { return cameraState; } - + public EmoteState getEmoteState() { return emoteState; } - + @JSONHint(ignore = true) public long getLastUpdateTime() { return lastUpdateTime; } - + public void setInstanceID(String instanceID) { this.instanceID = instanceID; } - + public void setCharacterID(String characterID) { if (characterID.startsWith("\"")) { characterID = characterID.substring(1); @@ -100,42 +103,42 @@ } this.characterID = characterID; } - + public void setAreaURI(String areaURI) { this.areaURI = areaURI; } - + public void setPosition(Position3D position) { - this.position = position; + this.position = position; if (this.placeable != null) { ((Object3D)this.placeable.getBody()).setPosition(position); - } + } } - + public void setAngle(Quaternion3D angle) { - this.angle = angle; + this.angle = angle; if (this.placeable != null) { ((Object3D)this.placeable.getBody()).apply(angle, false); - } + } } - + public void setCameraState(CameraState cameraState) { this.cameraState = cameraState; } - + public void setEmoteState(EmoteState emoteState) { this.emoteState = emoteState; } - + public void setAnimationClassToStart(EmoteState.EmoteType animationClassToStart) { setEmoteState(new EmoteState(animationClassToStart)); } - + @JSONHint(ignore = true) public void setLastUpdateTime(long lastUpdateTime) { this.lastUpdateTime = lastUpdateTime; } - + public Player update(String characterID, Position3D position, Quaternion3D angle, CameraState cameraState, EmoteState.EmoteType animationClassToStart, long lastUpdateTime) { setPosition(position); @@ -149,7 +152,7 @@ setLastUpdateTime(lastUpdateTime); return this; } - + private void updateAreaURI() { String[] areaURISplit = areaURI.split("/"); // �c�c/instances/{instanceId}/areas/{areaId} int splitSize = areaURISplit.length; @@ -162,7 +165,7 @@ setAreaURI(findAreaURI(instance)); } } - + private String findAreaURI(Instance instance) { // �L�����N�^�[�̃|�W�V������p���Ăǂ̃G���A���ɂ��邩�𔻒肵�ē��Y�G���A��URI�ɍX�V���� for (String areaId : instance.getAreas().keySet()) { @@ -174,38 +177,53 @@ } return ""; } - + private void updateEmoteType(EmoteState.EmoteType animationClassToStart) { emoteState.setEmoteType(animationClassToStart); } - + public void changeCharacter(String characterID) { - destroy(); + writeCharacterData(); setCharacterID(characterID); Character character = getCharacter(); initPlaceable(character.getModelID()); readCharacterData(character); } - + public void destroy() { writeCharacterData(); Instance instance = Instances.getInstance().getInstance(instanceID); instance.getUniverse().displace(this.getPlaceable()); } - + private Character getCharacter() { return Instances.getInstance().getInstance(instanceID).getCharacter(characterID); } - + private void readCharacterData(Character character) { setPosition(character.getPosition()); setAngle(character.getAngle()); setAreaURI(character.getAreaURI()); } - + + // private void readCharacterData() { + // Character character = getCharacter(); + // readCharacterData(character); + // } + private void writeCharacterData() { Character character = getCharacter(); // if (character == null) return; character.update(position, angle, areaURI); } -} + + @JSONHint(ignore = true) + public Object3D getObject() { + return object; + } + + public void setObject(Object3D object) { + this.object = object; + } + +} \ No newline at end of file