테스트

aion-server 4.8

Gitteol
최고관리자 · 1 · 💬 0 클론/새로받기
 4.8 61f661d · 1 commits 새로받기(Pull)
game-server/src/com/aionemu/gameserver/model/gameobjects/VisibleObject.java
package com.aionemu.gameserver.model.gameobjects;

import com.aionemu.gameserver.controllers.VisibleObjectController;
import com.aionemu.gameserver.model.animations.ObjectDeleteAnimation;
import com.aionemu.gameserver.model.templates.VisibleObjectTemplate;
import com.aionemu.gameserver.model.templates.spawns.SpawnTemplate;
import com.aionemu.gameserver.world.*;
import com.aionemu.gameserver.world.knownlist.KnownList;

/**
 * This class is representing visible objects. It's a base class for all in-game objects that can be spawned in the world at some particular position
 * (such as players, npcs).<br>
 * <br>
 * Objects of this class, as can be spawned in game, can be seen by other visible objects. To keep track of which objects are already "known" by this
 * visible object and which are not, VisibleObject is containing {@link KnownList} which is responsible for holding this information.
 *
 * @author -Nemesiss-
 */
public abstract class VisibleObject extends AionObject {

	private final VisibleObjectTemplate objectTemplate;

	/**
	 * Position of object in the world.
	 */
	protected WorldPosition position;

	/**
	 * KnownList of this VisibleObject.
	 */
	private KnownList knownlist;

	/**
	 * Controller of this VisibleObject
	 */
	private final VisibleObjectController<? extends VisibleObject> controller;

	/**
	 * Visible object's target
	 */
	private VisibleObject target;

	/**
	 * Spawn template of this visibleObject.
	 */
	private final SpawnTemplate spawnTemplate;

	/**
	 * Constructor.
	 *
	 * @param objId
	 * @param objectTemplate
	 */
	public VisibleObject(int objId, VisibleObjectController<? extends VisibleObject> controller, SpawnTemplate spawnTemplate,
		VisibleObjectTemplate objectTemplate, WorldPosition position, boolean autoReleaseObjectId) {
		super(objId, autoReleaseObjectId);
		this.controller = controller;
		this.position = position;
		this.spawnTemplate = spawnTemplate;
		this.objectTemplate = objectTemplate;
	}

	@Override
	public String getName() {
		return objectTemplate.getName();
	}

	public int getInstanceId() {
		return getPosition().getInstanceId();
	}

	/**
	 * Return World map id.
	 */
	public int getWorldId() {
		return getPosition().getMapId();
	}

	/**
	 * Return the WorldType of the current location
	 */
	public WorldType getWorldType() {
		return World.getInstance().getWorldMap(getWorldId()).getWorldType();
	}

	public WorldDropType getWorldDropType() {
		return World.getInstance().getWorldMap(getWorldId()).getWorldDropType();
	}

	/**
	 * Return World position x
	 */
	public float getX() {
		return getPosition().getX();
	}

	/**
	 * Return World position y
	 */
	public float getY() {
		return getPosition().getY();
	}

	/**
	 * Return World position z
	 */
	public float getZ() {
		return getPosition().getZ();
	}

	/**
	 * Heading of the object. Values from <0,120)
	 */
	public byte getHeading() {
		return getPosition().getHeading();
	}

	/**
	 * Return object position
	 *
	 * @return position.
	 */
	public WorldPosition getPosition() {
		return position;
	}

	public WorldMapInstance getWorldMapInstance() {
		return getPosition().getWorldMapInstance();
	}

	/**
	 * Check if object is spawned.
	 *
	 * @return true if object is spawned.
	 */
	public boolean isSpawned() {
		return getPosition().isSpawned();
	}

	/**
	 * @return True if the object is in the world (can be a spawned or despawned object)
	 */
	public boolean isInWorld() {
		return World.getInstance().isInWorld(getObjectId());
	}

	/**
	 * Check if map is instance
	 *
	 * @return true if object in one of the instance maps
	 */
	public boolean isInInstance() {
		return getPosition().isInstanceMap();
	}

	public void clearKnownlist() {
		clearKnownlist(ObjectDeleteAnimation.FADE_OUT);
	}

	public void clearKnownlist(ObjectDeleteAnimation animation) {
		getKnownList().clear(animation);
	}

	public void updateKnownlist() {
		getKnownList().doUpdate();
	}

	/**
	 * @return True, if the object is able to see the given object (basic check without distance validation)
	 */
	public boolean canSee(VisibleObject object) {
		return object != null;
	}

	/**
	 * Set KnownList to this VisibleObject
	 *
	 * @param knownlist
	 */
	public void setKnownlist(KnownList knownlist) {
		this.knownlist = knownlist;
	}

	/**
	 * Returns KnownList of this VisibleObject.
	 *
	 * @return knownList.
	 */
	public KnownList getKnownList() {
		return knownlist;
	}

	/**
	 * Return VisibleObjectController of this VisibleObject
	 *
	 * @return VisibleObjectController.
	 */
	public VisibleObjectController<? extends VisibleObject> getController() {
		return controller;
	}

	/**
	 * @return VisibleObject
	 */
	public final VisibleObject getTarget() {
		return target;
	}

	/**
	 * @param creature
	 */
	public void setTarget(VisibleObject creature) {
		target = creature;
	}

	/**
	 * @param objectId
	 * @return target is object with id equal to objectId
	 */
	public boolean isTargeting(int objectId) {
		return target != null && target.getObjectId() == objectId;
	}

	/**
	 * Return spawnTemplate template of this VisibleObject
	 *
	 * @return SpawnTemplate
	 */
	public SpawnTemplate getSpawn() {
		return spawnTemplate;
	}

	/**
	 * @return the objectTemplate
	 */
	public VisibleObjectTemplate getObjectTemplate() {
		return objectTemplate;
	}

	/**
	 * @param position
	 */
	public void setPosition(WorldPosition position) {
		this.position = position;
	}

	/**
	 * @return Distance in in-game meters how far this object can be seen/detected (a.k.a. known)
	 */
	public float getVisibleDistance() {
		return 95;
	}

	@Override
	public String toString() {
		return getClass().getSimpleName() + " [" + (objectTemplate != null ? "templateId=" + objectTemplate.getTemplateId() + ", " : "") + "objectId="
			+ getObjectId() + ", name=" + getName() + ", position=" + position + "]";
	}
}

📎 첨부파일

댓글 작성 권한이 없습니다.
🏆 포인트 랭킹 TOP 10
순위 닉네임 포인트
1 no_profile 타키야겐지쪽지보내기 자기소개 아이디로 검색 전체게시물 102,949
2 no_profile 동가리쪽지보내기 자기소개 아이디로 검색 전체게시물 63,733
3 no_profile 라프텔쪽지보내기 자기소개 아이디로 검색 전체게시물 51,771
4 no_profile 불멸의행복쪽지보내기 자기소개 아이디로 검색 전체게시물 36,923
5 서번트쪽지보내기 자기소개 아이디로 검색 전체게시물 35,011
6 no_profile 닥터스쪽지보내기 자기소개 아이디로 검색 전체게시물 29,470
7 no_profile 검은고양이쪽지보내기 자기소개 아이디로 검색 전체게시물 29,077
8 no_profile Revolution쪽지보내기 자기소개 아이디로 검색 전체게시물 28,199
9 no_profile 보거스쪽지보내기 자기소개 아이디로 검색 전체게시물 26,731
10 no_profile 호롤롤로쪽지보내기 자기소개 아이디로 검색 전체게시물 17,020
알림 0