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

import java.util.HashSet;

import net.arnx.jsonic.JSONHint;

public class Area extends Entity{
	private String name;
	private Plain[] region; // 任意個の平面の方程式
	private HashSet<Allowed> permissions; // エリア内で可能なことの羅列
	@JSONHint(ignore = true) public static final int UNIQUE_ID_LENGTH = 12;

	private Area() {
		// JSONDecode時の呼び出し用
	}
	
	public Area(String name, Plain[] region, HashSet<Allowed> permissions) {
		setName(name);
		setRegion(region);
		setPermissions(permissions);
	}
	
	public String getName() {
		return name;
	}
	
	public Plain[] getRegion() {
		return region;
	}

	public Plain getRegion(int index) {
		return region[index];
	}
	
	public HashSet<Allowed> getPermissions() {
		return permissions;
	}
	
	public boolean isPermission(Allowed allowed) {
		return permissions.contains(allowed);
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void setRegion(Plain[] region) {
		this.region = region;
	}
	
	public void setPermissions(HashSet<Allowed> permissions) {
		this.permissions = permissions;
	}
	
	public void addPermission(Allowed allowed) {
		permissions.add(allowed);
	}
	
	public void removePermission(Allowed allowed) {
		permissions.remove(allowed);
	}
	
	public static enum Allowed {
		SHOOT, KILL;
	}
}