Newer
Older
CactusServer / src / main / java / cactusServer / entities / Bullet.java
package cactusServer.entities;

import org.ntlab.radishforandroidstudio.framework.model3D.Object3D;
import org.ntlab.radishforandroidstudio.framework.model3D.Position3D;
import org.ntlab.radishforandroidstudio.framework.model3D.Quaternion3D;

import cactusServer.models.BulletModelManager;

public class Bullet extends Entity3D {
	private String playerID;
	private Position3D position;
	private Quaternion3D angle;

	private Bullet() {
		// JSONエンコード時の呼び出し用
	}

	public Bullet(String playerID, Position3D position, Quaternion3D angle) {
		Object3D body = BulletModelManager.getInstance().getBulletModel(0).createObject(); // モデルIDは仮に0を指定
		setPlaceable(body);
		setPlayerID(playerID);
		setPosition(position);
		setAngle(angle);
	}

	public String getPlayerID() {
		return playerID;
	}

	public Position3D getPosition() {
		return position;
	}

	public Quaternion3D getAngle() {
		return angle;
	}

	public void setPlayerID(String playerID) {
		this.playerID = playerID;
	}

	public void setPosition(Position3D position) {
		this.position = position;
		if (this.placeable != null) {
			((Object3D)this.placeable.getBody()).setPosition(position);
		}
	}

	public void setAngle(Quaternion3D angle) {
		this.angle = angle;
		if (this.placeable != null) {
			((Object3D)this.placeable.getBody()).apply(angle, false);
		}
	}

	public void update(Position3D position, Quaternion3D angle) {
		setPosition(position);
		setAngle(angle);
	}
}