refactor: gather
This commit is contained in:
parent
eb94ca31ec
commit
11dbddd47b
|
@ -19,7 +19,7 @@ const ItemSlotComponent = (props) => {
|
||||||
const latus = useLatus();
|
const latus = useLatus();
|
||||||
const [qty, setQty] = useState(undefined);
|
const [qty, setQty] = useState(undefined);
|
||||||
useEvent(item, 'qtyChanged', useCallback(() => setQty(item.qty), [item]));
|
useEvent(item, 'qtyChanged', useCallback(() => setQty(item.qty), [item]));
|
||||||
const {Image} = latus.get('%resources.fromResourceType');
|
const {Image} = latus.get('%resources');
|
||||||
let backgroundImageUri;
|
let backgroundImageUri;
|
||||||
let qtyClass;
|
let qtyClass;
|
||||||
if (item) {
|
if (item) {
|
||||||
|
|
|
@ -3,9 +3,9 @@ import {Packet} from '@latus/socket';
|
||||||
export default (latus) => class HarmPacket extends Packet {
|
export default (latus) => class HarmPacket extends Packet {
|
||||||
|
|
||||||
static pack(harms) {
|
static pack(harms) {
|
||||||
const fromType = latus.get('%affinities.fromType');
|
const Affinities = latus.get('%affinities');
|
||||||
return harms.map((harm) => {
|
return harms.map((harm) => {
|
||||||
const {[harm.affinity]: Affinity} = fromType;
|
const {[harm.affinity]: Affinity} = Affinities;
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
harm.affinity = Affinity.id;
|
harm.affinity = Affinity.id;
|
||||||
return harm;
|
return harm;
|
||||||
|
@ -24,9 +24,9 @@ export default (latus) => class HarmPacket extends Packet {
|
||||||
}
|
}
|
||||||
|
|
||||||
static unpack(harms) {
|
static unpack(harms) {
|
||||||
const fromId = latus.get('%affinities.fromId');
|
const Affinities = latus.get('%affinities');
|
||||||
return harms.map((harm) => {
|
return harms.map((harm) => {
|
||||||
const {[harm.affinity]: Affinity} = fromId;
|
const {[harm.affinity]: Affinity} = Affinities;
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
harm.affinity = Affinity.type;
|
harm.affinity = Affinity.type;
|
||||||
return harm;
|
return harm;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import {resource} from '@avocado/resource';
|
|
||||||
import {useEffect, useLatus, useState} from '@latus/react/client';
|
import {useEffect, useLatus, useState} from '@latus/react/client';
|
||||||
import {useSocket} from '@latus/socket';
|
import {useSocket} from '@latus/socket';
|
||||||
|
|
||||||
|
@ -25,7 +24,7 @@ export default () => {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const onCreated = (type, created) => {
|
const onCreated = (type, created) => {
|
||||||
const {fromResourceType: {Room}} = resource(latus);
|
const {Room} = latus.get('%resources');
|
||||||
switch (type) {
|
switch (type) {
|
||||||
// Track room.
|
// Track room.
|
||||||
case Room.resourceId: {
|
case Room.resourceId: {
|
||||||
|
|
33
packages/core/src/traits/darkened.js
Normal file
33
packages/core/src/traits/darkened.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import {Trait} from '@avocado/traits';
|
||||||
|
|
||||||
|
export default () => class Darkened extends Trait {
|
||||||
|
|
||||||
|
static defaultParams() {
|
||||||
|
return {
|
||||||
|
isDarkened: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static describeParams() {
|
||||||
|
return {
|
||||||
|
isDarkened: {
|
||||||
|
type: 'bool',
|
||||||
|
label: 'Is darkened',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static type() {
|
||||||
|
return 'darkened';
|
||||||
|
}
|
||||||
|
|
||||||
|
async load(json) {
|
||||||
|
await super.load(json);
|
||||||
|
this._isDarkened = this.params.isDarkened;
|
||||||
|
}
|
||||||
|
|
||||||
|
get isDarkened() {
|
||||||
|
return this._isDarkened;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
|
@ -60,7 +60,7 @@ export default (latus) => class Receptacle extends decorate(Trait) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'TraitUpdateReceptacleItemFull': {
|
case 'TraitUpdateReceptacleItemFull': {
|
||||||
const {Entity} = latus.get('%resources.fromResourceType');
|
const {Entity} = latus.get('%resources');
|
||||||
this.entity.addItemToSlot(await Entity.load(packet.data.json), packet.data.slotIndex);
|
this.entity.addItemToSlot(await Entity.load(packet.data.json), packet.data.slotIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ export default (latus) => class Receptacle extends decorate(Trait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async load(json) {
|
async load(json) {
|
||||||
const {Entity} = latus.get('%resources.fromResourceType');
|
const {Entity} = latus.get('%resources');
|
||||||
await super.load(json);
|
await super.load(json);
|
||||||
await Promise.all(Object.entries(this.params.slots).map(async ([slotIndex, slotSpec]) => {
|
await Promise.all(Object.entries(this.params.slots).map(async ([slotIndex, slotSpec]) => {
|
||||||
const item = await Entity.load({extends: slotSpec.extends});
|
const item = await Entity.load({extends: slotSpec.extends});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {dirname, join} from 'path';
|
import {dirname, join} from 'path';
|
||||||
import {promisify} from 'util';
|
import {promisify} from 'util';
|
||||||
|
|
||||||
import {resource, JsonResource} from '@avocado/resource';
|
import {JsonResource} from '@avocado/resource';
|
||||||
import {createLoop, destroyLoop} from '@avocado/timing';
|
import {createLoop, destroyLoop} from '@avocado/timing';
|
||||||
import glob from 'glob';
|
import glob from 'glob';
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export default (latus) => class Universe extends JsonResource {
|
||||||
async load(json = {}) {
|
async load(json = {}) {
|
||||||
super.load(json);
|
super.load(json);
|
||||||
const {tps = 60, uri} = json;
|
const {tps = 60, uri} = json;
|
||||||
const {fromResourceType: {Room}} = resource(latus);
|
const {Room} = latus.get('%resources');
|
||||||
if (uri) {
|
if (uri) {
|
||||||
const universePath = dirname(uri);
|
const universePath = dirname(uri);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import {resource} from '@avocado/resource';
|
|
||||||
import {gatherWithLatus} from '@latus/core';
|
import {gatherWithLatus} from '@latus/core';
|
||||||
|
|
||||||
import UniverseInput from './packets/decorators/universe-input';
|
import UniverseInput from './packets/decorators/universe-input';
|
||||||
|
@ -11,7 +10,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const {fromResourceType: {Universe}} = resource(latus);
|
const {Universe} = latus.get('%resources');
|
||||||
const universe = await Universe.load({extends: `/universe/${running}/index.universe.json`});
|
const universe = await Universe.load({extends: `/universe/${running}/index.universe.json`});
|
||||||
latus.set('%universe', universe);
|
latus.set('%universe', universe);
|
||||||
universe.start();
|
universe.start();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import {dirname, join} from 'path';
|
import {dirname, join} from 'path';
|
||||||
|
|
||||||
import {resource} from '@avocado/resource';
|
|
||||||
// import {ValidationError} from '@latus/socket';
|
// import {ValidationError} from '@latus/socket';
|
||||||
|
|
||||||
import Join from '../../packets/join';
|
import Join from '../../packets/join';
|
||||||
|
@ -21,7 +20,7 @@ export default (latus) => class ServerJoin extends Join() {
|
||||||
if (player) {
|
if (player) {
|
||||||
return player.entity.instanceUuid;
|
return player.entity.instanceUuid;
|
||||||
}
|
}
|
||||||
const {Entity} = latus.get('%resources.fromResourceType');
|
const {Entity} = latus.get('%resources');
|
||||||
const entity = await Entity.load(
|
const entity = await Entity.load(
|
||||||
{
|
{
|
||||||
extends: join(
|
extends: join(
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import {resource} from '@avocado/resource';
|
|
||||||
import {
|
import {
|
||||||
createAsyncThunk,
|
createAsyncThunk,
|
||||||
createSelector,
|
createSelector,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user