Merge branch 'feature-tabletop' into develop

This commit is contained in:
ThaumRystra
2023-12-18 18:35:56 +02:00
41 changed files with 3233 additions and 275 deletions

View File

@@ -16,8 +16,7 @@ export default function computeAction(computation, node) {
}
});
prop.resources.itemsConsumed?.forEach(itemConsumed => {
if (!itemConsumed.itemId) return;
if (itemConsumed.available < itemConsumed.quantity?.value) {
if (!itemConsumed.itemId || itemConsumed.available < itemConsumed.quantity?.value) {
prop.insufficientResources = true;
}
});

View File

@@ -12,15 +12,17 @@ export const loadedCreatures: Map<string, LoadedCreature> = new Map(); // creatu
export function loadCreature(creatureId: string, subscription: Tracker.Computation) {
if (!creatureId) throw 'creatureId is required';
let creature = loadedCreatures.get(creatureId);
if (!creature || !creature.subs.has(subscription)) {
subscription.onStop(() => {
unloadCreature(creatureId, subscription);
});
}
if (creature) {
creature.subs.add(subscription);
} else {
creature = new LoadedCreature(subscription, creatureId);
loadedCreatures.set(creatureId, creature);
}
subscription.onStop(() => {
unloadCreature(creatureId, subscription);
});
}
function unloadCreature(creatureId, subscription) {
@@ -188,14 +190,15 @@ export function getPropertyChildren(creatureId, property) {
// This propertyId will always appear in the parent of the children
if (loadedCreatures.has(creatureId)) {
const creature = loadedCreatures.get(creatureId);
const props = [];
if (!creature) return [];
const props: CreatureProperty[] = [];
for (const prop of creature.properties.values()) {
if (prop.parent?.id === property._id) {
if (prop.parentId === property._id) {
props.push(prop);
}
}
const cloneProps = EJSON.clone(props);
return cloneProps.sort((a, b) => a.order - b.order);
return cloneProps.sort((a, b) => a.left - b.left);
} else {
return CreatureProperties.find({
'parent.id': property._id,