Added token category option

This commit is contained in:
Mitchell McCaffrey
2020-08-27 19:09:16 +10:00
parent a912163079
commit 3c27f65d0f
7 changed files with 70 additions and 25 deletions

View File

@@ -53,10 +53,10 @@ function MapToken({
const tokenGroup = event.target;
const tokenImage = imageRef.current;
if (token && token.isVehicle) {
if (token && token.category === "vehicle") {
// Find all other tokens on the map
const layer = tokenGroup.getLayer();
const tokens = layer.find(".token");
const tokens = layer.find(".character");
for (let other of tokens) {
if (other === tokenGroup) {
continue;
@@ -101,9 +101,9 @@ function MapToken({
const tokenGroup = event.target;
const mountChanges = {};
if (token && token.isVehicle) {
if (token && token.category === "vehicle") {
const parent = tokenGroup.getParent();
const mountedTokens = tokenGroup.find(".token");
const mountedTokens = tokenGroup.find(".character");
for (let mountedToken of mountedTokens) {
// Save and restore token position after moving layer
const position = mountedToken.absolutePosition();
@@ -227,10 +227,10 @@ function MapToken({
return null;
}
// Token name is used by on click to find whether a token is a vehicle
// Token name is used by on click to find whether a token is a vehicle or prop
let tokenName = "";
if (token) {
tokenName = token.isVehicle ? "vehicle" : "token";
tokenName = token.category;
}
if (tokenState && tokenState.locked) {
tokenName = tokenName + "-locked";