refactor: neutrino!

This commit is contained in:
cha0s 2020-06-15 17:24:43 -05:00
parent dfb74b5eeb
commit 2166df7d1c
125 changed files with 4659 additions and 2482 deletions

16
.eslint.defaults.js Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
rules: {
'babel/object-curly-spacing': 'off',
'brace-style': ["error", "stroustrup"],
'no-plusplus': 'off',
'padded-blocks': ["error", { "classes": "always" }],
yoda: 'off',
},
settings: {
'import/resolver': {
webpack: {
config: `${__dirname}/webpack.config.js`,
},
},
},
};

3
.eslintrc.js Normal file
View File

@ -0,0 +1,3 @@
const neutrino = require('neutrino');
module.exports = neutrino(require('./.neutrinorc.client')).eslintrc();

123
.gitignore vendored
View File

@ -1,6 +1,119 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist dist
node_modules
.vscode # Gatsby files
/isolate-0x*-v8-*.log .cache/
/resource/*.entity.json # Comment in the public line in if your project uses Gatsby and not Next.js
/resource/*.room.json # https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*
# Neutrino build directory
build

5
.mocharc.js Normal file
View File

@ -0,0 +1,5 @@
const neutrino = require('neutrino');
const side = require('./side');
module.exports = neutrino(require(`./.neutrinorc.${side}`)).mocha();

80
.neutrinorc.client.js Normal file
View File

@ -0,0 +1,80 @@
const path = require('path');
const react = require('@neutrinojs/react');
const styles = require('@neutrinojs/style-loader');
const globImporter = require('node-sass-glob-importer');
const {DefinePlugin} = require('webpack');
const {afterPlatform, initial} = require('./middleware');
module.exports = {
options: {
root: __dirname,
},
use: [
initial({
environmentDefines: ['FRONTEND_ORIGIN'],
scwpPaths: [/^@avocado/],
}),
react({
devServer: {
contentBase: path.resolve(__dirname, 'resource'),
},
style: {
test: /\.(css|sass|scss)$/,
modulesTest: /\.module\.(css|sass|scss)$/,
loaders: [
{
loader: 'postcss-loader',
useId: 'postcss',
options: {
config: {
path: __dirname,
},
},
},
{
loader: 'sass-loader',
useId: 'sass',
options: {
importer: globImporter(),
},
},
],
},
html: {
template: `${__dirname}/src/client/index.ejs`,
title: 'Humus',
},
}),
afterPlatform({
babelPaths: [/^@avocado/, /^contempo/, /^scwp/],
}),
(neutrino) => {
neutrino.config.module.rule('style')
.oneOf('raw')
.before('normal')
.test(/\.raw\.(css|sass|scss)$/)
.use('raw')
.loader('raw-loader')
.end()
.use('postcss')
.loader('postcss-loader')
.options({config: {path: __dirname}})
.end()
.use('sass')
.loader('sass-loader')
.options({importer: globImporter()})
.end()
neutrino.config.resolve.modules
.add(`${neutrino.options.source}/client/scss`);
neutrino.config
.plugin('avocado-define')
.use(DefinePlugin, [
{
AVOCADO_CLIENT: true,
AVOCADO_SERVER: false,
},
]);
}
],
};

34
.neutrinorc.server.js Normal file
View File

@ -0,0 +1,34 @@
const {spawn} = require('child_process');
const copy = require('@neutrinojs/copy');
const node = require('@neutrinojs/node');
const {DefinePlugin} = require('webpack');
const {afterPlatform, initial} = require('./middleware');
module.exports = {
options: {
root: __dirname,
},
use: [
initial({
environmentDefines: ['REDIS_ORIGIN'],
scwpPaths: [/^@avocado/],
}),
node(),
afterPlatform({
babelPaths: [/^@avocado/],
externalMatcher: /(?:@avocado|@pixi|scwp|webpack)/,
}),
(neutrino) => {
neutrino.config
.plugin('avocado-define')
.use(DefinePlugin, [
{
AVOCADO_CLIENT: false,
AVOCADO_SERVER: true,
},
]);
},
],
};

19
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
// "preLaunchTask": "Both",
"request": "attach",
"name": "Terrible",
"address": "127.0.0.1",
"port": 43000,
"skipFiles": [
"<node_internals>/**"
]
},
],
}

54
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,54 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Client",
"type": "shell",
"isBackground": true,
"command": "yarn",
"args": ["run", "client"],
"problemMatcher": [
{
"owner": "custom",
"pattern": { "regexp": "__________" },
"background": {
"activeOnStart": true,
"beginsPattern": "(Compiling|Project is running)",
"endsPattern": "(?:Compiled successfully|Failed to compile)"
},
}
],
},
{
"label": "Server",
"type": "shell",
"isBackground": true,
"command": "yarn",
"args": ["run", "server", "--inspect=127.0.0.1:43000"],
"problemMatcher": [
{
"owner": "custom",
"pattern": { "regexp": "You need to restart the application" },
},
{
"owner": "custom",
"pattern": { "regexp": "__________" },
"background": {
"activeOnStart": true,
"beginsPattern": "(Hash:|Updated modules)",
"endsPattern": "(Built at:|Update applied)"
},
},
],
},
{
"label": "Both",
"isBackground": true,
"dependsOn": [
"Client",
"Server"
],
"problemMatcher": [],
}
]
}

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM node:14
EXPOSE 5000
COPY ./build /var/www
COPY ./node_modules /var/www/server/node_modules
CMD ["node", "/var/www/server/index.js"]

View File

@ -1,14 +0,0 @@
const common = require('./babel.common.config');
module.exports = function(api) {
const config = common(api);
// Presets.
config.presets.push('@babel/preset-react');
config.presets.push('@babel/preset-env');
// Plugins.
config.plugins.push('@babel/plugin-proposal-object-rest-spread');
if (process.argv.find((arg) => '--hot' === arg)) {
config.plugins.push('react-hot-loader/babel');
}
return config;
}

View File

@ -1,9 +0,0 @@
module.exports = function (api) {
api.cache(true);
const presets = [];
const plugins = [];
return {
presets,
plugins
};
}

View File

@ -1,15 +0,0 @@
const common = require('./babel.common.config');
module.exports = function(api) {
const config = common(api);
// Presets.
config.presets.push([
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
]);
return config;
}

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Humus</title>
</head>
<body>
<div class="app">
<div class="debug-container"></div>
</div>
</body>
</html>

View File

5
inspect.js Normal file
View File

@ -0,0 +1,5 @@
const neutrino = require('neutrino');
const side = require('./side');
neutrino(require(`./.neutrinorc.${side}`)).inspect();

132
middleware.js Normal file
View File

@ -0,0 +1,132 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-param-reassign */
const path = require('path');
const airbnb = require('@neutrinojs/airbnb');
const airbnbBase = require('@neutrinojs/airbnb-base');
const mocha = require('@neutrinojs/mocha');
const scwp = require('scwp/neutrino');
const {DefinePlugin} = require('webpack');
const nodeExternals = require('webpack-node-externals');
const side = require('./side');
const avocadoPackages = {};
const pkg = require(`${__dirname}/package.json`);
const gatherPackagePaths = (root, packageMatchers) => {
return packageMatchers.reduce((r, packageMatcher) => (
r.concat([
(pkg.dependencies || {}),
(pkg.devDependencies || {}),
].reduce((r, deps) => {
const packageNames = Object.keys(deps);
const packages = [];
for (let i = 0; i < packageNames.length; i++) {
const packageName = packageNames[i];
if (packageName.match(packageMatcher)) {
packages.push(path.relative(root, path.dirname(require.resolve(packageName))));
}
}
return r.concat(packages);
}, []))
), []);
}
exports.initial = (options) => (neutrino) => {
const {
environmentDefines = [],
scwpPaths = [],
} = options;
neutrino.options.mains.index = `${side}/index`;
neutrino.options.output = `build/${side}`;
neutrino.config.resolve.modules
.add(`${neutrino.options.root}/node_modules`);
neutrino.config.resolveLoader.modules
.add(`${neutrino.options.root}/node_modules`);
neutrino.config.resolve.alias
.set('~', neutrino.options.source);
('server' === side ? airbnbBase : airbnb)({
eslint: {
cache: false,
// eslint-disable-next-line global-require
baseConfig: require('./.eslint.defaults'),
},
})(neutrino);
mocha({
spec: `src/+(${side}|common)/**/*.spec.js`,
})(neutrino);
scwp({
paths: [
'./src/common',
`./src/${side}`,
].concat(
gatherPackagePaths(neutrino.options.root, scwpPaths.concat(/^scwp/))
),
})(neutrino);
neutrino.config
.plugin('environment-define')
.use(DefinePlugin, [
environmentDefines.reduce((r, k) => ({...r, [k]: JSON.stringify(process.env[k])}), {})
]);
};
exports.afterPlatform = (options) => (neutrino) => {
const {
babelPaths = [],
externalMatcher = [],
} = options;
const allBabelPaths = gatherPackagePaths(neutrino.options.root, babelPaths);
neutrino.config.module
.rule('compile')
.use('babel')
.tap((options) => {
options.only = [
neutrino.options.source,
].concat(allBabelPaths);
options.ignore = [];
return options;
});
allBabelPaths.forEach((babelPath) => {
neutrino.config.module
.rule('compile')
.include
.add(path.resolve(neutrino.options.root, babelPath));
});
neutrino.config.module
.rule('compile')
.use('babel')
.get('options').plugins.push(
[
'babel-plugin-webpack-alias',
{
config: `${__dirname}/webpack.config.js`,
},
],
);
if ('client' === side) {
neutrino.config.node.delete('Buffer');
}
else /* if ('server' === side) */ {
neutrino.config.stats('normal');
if ('production' !== process.env.NODE_ENV) {
neutrino.config
.plugin('start-server')
.tap((args) => {
const options = args[0];
const inspectArg = process.argv.find((arg) => -1 !== arg.indexOf('--inspect'));
if (inspectArg) {
options.nodeArgs.push(inspectArg);
}
const profArg = process.argv.find((arg) => -1 !== arg.indexOf('--prof'));
if (profArg) {
options.nodeArgs.push(profArg);
}
return args;
});
}
neutrino.config
.externals(nodeExternals({
whitelist: externalMatcher,
}));
}
}

View File

@ -1,44 +1,18 @@
{ {
"name": "avocado-examples", "name": "humus",
"version": "1.0.0", "version": "1.0.0",
"author": "cha0s", "main": "index.js",
"license": "MIT", "license": "MIT",
"browserslist": [
"last 1 version",
"> 1%",
"maintained node versions",
"not dead"
],
"devDependencies": {
"@babel/core": "7.3.4",
"@babel/plugin-proposal-object-rest-spread": "7.3.4",
"@babel/polyfill": "7.2.5",
"@babel/preset-env": "7.3.4",
"@babel/preset-react": "7.0.0",
"autoprefixer": "9.6.1",
"babel-loader": "8.0.5",
"contempo": "1.x",
"css-loader": "3.1.0",
"extract-css-chunks-webpack-plugin": "4.5.6",
"html-webpack-plugin": "3.2.0",
"node-sass": "4.12.0",
"node-sass-glob-importer": "5.3.2",
"postcss-loader": "3.0.0",
"raw-loader": "3.1.0",
"sass-loader": "7.1.0",
"start-server-webpack-plugin": "2.2.5",
"webpack": "4.29.6",
"webpack-cli": "3.2.3",
"webpack-dev-server": "3.2.1",
"webpack-node-externals": "1.7.2"
},
"scripts": { "scripts": {
"client": "webpack-dev-server --hot --config webpack.client.config.js", "build:client": "SIDE=CLIENT webpack --mode production --config webpack.config.js",
"client:build": "webpack --config webpack.client.config.js", "build:docker": "yarn run build:client && yarn run build:server && docker build",
"deploy": "yarn server:build --production && yarn client:build --production && cp -ar resource/* dist && rsync -r dist/ www.cha0s.io:~/web/cha0s.io/humus/public_html/", "build:server": "SIDE=SERVER webpack --mode production --config webpack.config.js",
"server": "DEBUG=@avocado:* webpack --autorun --watch --hot --config webpack.server.config.js", "client": "SIDE=CLIENT webpack-dev-server --verbose --disable-host-check --host humus.cha0sdev --port 8421 --mode development --config webpack.config.js",
"server:build": "webpack --config webpack.server.config.js", "inspect": "node ./inspect.js",
"start": "webpack --config webpack.server.config.js && webpack-dev-server --config webpack.client.config.js" "lint": "eslint --cache --format codeframe --ext mjs,jsx,js src test",
"server": "SIDE=SERVER webpack --watch --mode development --config webpack.config.js",
"test:client": "NODE_PRESERVE_SYMLINKS=1 SIDE=client mocha --watch",
"test:server": "NODE_PRESERVE_SYMLINKS=1 SIDE=server mocha --watch"
}, },
"dependencies": { "dependencies": {
"@avocado/behavior": "1.x", "@avocado/behavior": "1.x",
@ -46,6 +20,7 @@
"@avocado/entity": "1.x", "@avocado/entity": "1.x",
"@avocado/graphics": "1.x", "@avocado/graphics": "1.x",
"@avocado/input": "1.x", "@avocado/input": "1.x",
"@avocado/math": "1.x",
"@avocado/net": "1.x", "@avocado/net": "1.x",
"@avocado/physics": "1.x", "@avocado/physics": "1.x",
"@avocado/resource": "1.x", "@avocado/resource": "1.x",
@ -53,6 +28,7 @@
"@avocado/timing": "1.x", "@avocado/timing": "1.x",
"@avocado/topdown": "1.x", "@avocado/topdown": "1.x",
"classnames": "2.2.6", "classnames": "2.2.6",
"contempo": "1.x",
"glob": "^7.1.3", "glob": "^7.1.3",
"immutable": "4.0.0-rc.12", "immutable": "4.0.0-rc.12",
"immutablediff": "0.4.4", "immutablediff": "0.4.4",
@ -60,7 +36,30 @@
"react": "16.8.6", "react": "16.8.6",
"react-dom": "16.8.6", "react-dom": "16.8.6",
"react-hot-loader": "4.8.3", "react-hot-loader": "4.8.3",
"source-map-support": "^0.5.11", "scwp": "1.x",
"v8-natives": "^1.1.0" "source-map-support": "^0.5.11"
},
"devDependencies": {
"@neutrinojs/airbnb": "^9.1.0",
"@neutrinojs/airbnb-base": "^9.1.0",
"@neutrinojs/copy": "^9.2.0",
"@neutrinojs/mocha": "^9.1.0",
"@neutrinojs/node": "^9.1.0",
"@neutrinojs/react": "^9.1.0",
"autoprefixer": "9.8.0",
"babel-plugin-webpack-alias": "^2.1.2",
"eslint": "^6",
"eslint-import-resolver-webpack": "^0.12.1",
"mocha": "^7",
"neutrino": "^9.1.0",
"node-sass": "4.12.0",
"node-sass-glob-importer": "5.3.2",
"postcss-loader": "3.0.0",
"raw-loader": "1.x",
"sass-loader": "7.1.0",
"v8-natives": "^1.1.0",
"webpack": "^4",
"webpack-cli": "^3",
"webpack-dev-server": "^3"
} }
} }

View File

View File

View File

@ -0,0 +1 @@
{"traits":{"animated":{"params":{"animations":{"idle":{"jitter":0.1,"offset":[0,0],"uri":"/blue-fire.animation.json"}}}},"audible":{"params":{"sounds":{"fire":{"uri":"/blue-fire.sound.json"}}}},"collider":{"params":{"collisionGroup":"environmental","isSensor":true}},"harmful":{"params":{"harmfulSound":"fire","harmSpecs":[{"affinity":2,"lock":0.15,"power":-15,"variance":0.25}]}},"darkened":{"params":{"isDarkened":false}},"existent":{"state":{"name":"Blue fire"}},"layered":{},"listed":{},"physical":{},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[16,16]}}},"visible":{"params":{"filter":"bloom"}}}}

View File

@ -0,0 +1 @@
{"traits":{"animated":{"params":{"animations":{"idle":{"jitter":0.1,"offset":[0,0],"uri":"/fire.animation.json"}}}},"audible":{"params":{"sounds":{"fire":{"uri":"/fire.sound.json"}}}},"collider":{"params":{"collisionGroup":"environmental","isSensor":true}},"harmful":{"params":{"harmfulSound":"fire","harmSpecs":[{"affinity":2,"lock":0.15,"power":5,"variance":0.25}]}},"darkened":{"params":{"isDarkened":false}},"existent":{"state":{"name":"Fire"}},"layered":{},"listed":{},"physical":{},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[16,16]}}},"visible":{"params":{"filter":"bloom"}}}}

View File

@ -0,0 +1 @@
{"traits":{"alive":{"state":{"maxLife":1000,"life":1000}},"collider":{"params":{"collidesWithGroups":["default","environmental"]}},"emitter":{},"existent":{"state":{"name":"Flower Barrel"}},"layered":{},"listed":{},"physical":{},"pictured":{"params":{"images":{"initial":{"offset":[0,-8],"size":[32,32],"uri":"/flower-barrel.png"}}}},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[20,10]}}},"visible":{},"vulnerable":{"params":{"modifiers":{"0":0,"2":2}}}}}

1
resource/hoe.entity.json Normal file
View File

@ -0,0 +1 @@
{"traits":{"existent":{},"item":{"params":{"itemActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"useTool"},{"type":"invoke","args":[]}]}]},"slotImageUris":{"default":"/hoe.png"}}},"tool":{"params":{"condition":{"type":"condition","operator":"contains","operands":[{"type":"literal","value":[1,2,3,4]},{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"tileAt"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"target"}]}]}]}]},"actions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"setTileAt"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"target"}]},{"type":"literal","value":6}]}]}]},"target":{"type":"projection","distance":1,"length":1,"width":1}}}}}

View File

@ -0,0 +1 @@
{"size":[384,384],"layers":[{"entities":[{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":211,"y":84}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":65,"y":54}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":183,"y":179}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":288,"y":87}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":212,"y":258}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":264,"y":166}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":326,"y":229}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":124,"y":96}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":197,"y":62}}}},{"uri":"/kitty.entity.json","traits":{"positioned":{"state":{"x":221,"y":300}}}}],"tiles":{"size":[24,24],"data":[5,1,5,2,6,3,4,2,2,6,6,1,4,6,6,3,5,2,6,2,1,4,5,4,3,5,2,6,2,5,1,1,6,2,5,6,1,4,3,1,1,5,6,2,5,4,2,3,4,3,3,6,5,6,4,2,4,1,6,2,4,6,3,4,3,2,4,2,4,1,3,3,2,2,5,1,5,1,2,3,4,4,3,1,4,6,5,6,3,3,2,4,3,2,1,3,2,5,6,3,5,4,4,2,2,4,4,4,2,4,2,2,3,4,5,6,1,1,1,1,4,2,3,3,3,3,4,3,2,1,1,1,3,3,2,3,3,5,5,1,6,5,1,5,1,4,5,1,3,1,4,2,5,3,6,2,2,1,4,4,2,4,1,5,1,5,5,3,1,6,2,3,2,1,3,4,3,6,6,4,3,3,3,5,4,2,2,4,2,2,1,1,2,1,6,4,6,2,1,5,1,4,5,3,3,4,3,2,6,2,1,3,1,2,2,2,2,3,4,3,1,6,2,3,1,5,1,5,1,3,3,6,2,5,1,3,4,5,3,6,1,3,2,5,1,4,1,6,1,5,4,4,6,5,3,3,1,5,5,1,2,5,2,3,4,2,6,2,2,3,6,1,2,4,2,4,3,1,6,2,1,1,1,1,3,4,4,3,4,6,3,3,1,4,6,3,4,3,5,3,3,6,1,1,4,2,1,3,4,3,2,3,2,3,6,5,6,4,1,1,1,5,5,1,4,5,5,3,6,3,3,5,1,6,2,3,4,5,1,6,6,3,6,3,2,4,1,3,3,3,5,5,2,1,4,3,1,1,4,4,1,2,2,6,1,3,6,4,5,4,4,4,3,5,3,6,1,5,5,1,4,1,4,6,1,4,1,3,2,2,1,3,3,2,1,6,1,4,4,4,3,2,4,3,5,1,1,2,3,2,5,4,3,1,1,5,5,1,2,4,4,3,3,3,4,5,5,3,5,1,5,4,2,2,3,1,1,3,3,6,2,5,5,3,1,4,5,2,1,1,4,2,2,2,6,4,2,4,5,1,4,1,3,4,6,4,6,2,1,2,2,2,4,6,3,5,2,4,1,2,5,4,1,2,1,2,4,1,4,1,3,3,2,6,6,2,3,4,1,2,6,1,1,1,3,6,2,3,1,1,3,6,3,4,4,3,1,5,2,1,1,6,6,5,1,1,1,3,1,5,1,4,2,3,6,1,5,1,1,1,1,1,6,3,2,3,1,2,1,1,4,5,1,2,5,6,2,2,3,3,5,2,5,2,1,4,3,4,5,2,4,5,6,2,4,5]},"tilesetUri":"/tileset.json"}]}

View File

@ -0,0 +1 @@
{"traits":{"alive":{},"animated":{"params":{"animations":{"idle":{"offset":[0,-3],"uri":"/kitty.animation.json"}}}},"audible":{"params":{"sounds":{"deathSound":{"uri":"/ded.sound.json"}}}},"behaved":{"params":{"routines":{"type":"routines","routines":{"initial":{"type":"routine","routine":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}],"value":{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"floor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0},{"type":"literal","value":4}]}]}]}]}},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"moveFor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"Vector"},{"type":"key","key":"fromDirection"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0.25},{"type":"literal","value":2.5}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isAnimating"}],"value":{"type":"literal","value":false}},{"type":"traversal","steps":[{"type":"key","key":"Timing"},{"type":"key","key":"wait"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":1},{"type":"literal","value":4}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}],"value":{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"floor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0},{"type":"literal","value":4}]}]}]}]}},{"type":"traversal","steps":[{"type":"key","key":"Timing"},{"type":"key","key":"wait"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0.5},{"type":"literal","value":3}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isAnimating"}],"value":{"type":"literal","value":true}}]}}}}}},"collider":{"params":{"collidesWithGroups":["default","environmental","projectile"]}},"directional":{"params":{"directionCount":4},"state":{"direction":2}},"emitter":{},"existent":{"state":{"name":"Kitty"}},"layered":{},"listed":{},"lootable":{"params":{"table":[{"perc":70,"json":{"uri":"/yarn-ball.entity.json"}},{"perc":80,"json":{"uri":"/yarn-ball.entity.json"}},{"perc":90,"json":{"uri":"/yarn-ball.entity.json"}}]}},"mobile":{"state":{"speed":40}},"physical":{},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[8,4]}}},"visible":{"state":{"visibleScale":[1,1]}},"vulnerable":{"params":{"types":["bio"]}}}}

View File

@ -0,0 +1 @@
{"traits":{"behaved":{"params":{"routines":{"type":"routines","routines":{"initial":{"type":"routine","routine":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"spawnAt"},{"type":"invoke","args":[{"type":"literal","value":"mama"},{"type":"traversal","steps":[{"type":"key","key":"Utility"},{"type":"key","key":"makeArray"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":100},{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"sub"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"room"},{"type":"key","key":"width"}]},{"type":"literal","value":100}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":100},{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"sub"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"room"},{"type":"key","key":"height"}]},{"type":"literal","value":100}]}]}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"context"},{"type":"key","key":"json"}]}]}]}]}}}}}},"existent":{"state":{"name":"Mama spawner"}},"layered":{},"listed":{},"roomed":{},"spawner":{"params":{"spawns":{"mama":{"uri":"/mama-kitty.entity.json"}}},"state":{"maxSpawns":2}}}}

View File

@ -0,0 +1 @@
{"traits":{"alive":{"params":{"deathActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"playSound"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"deathSound"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"killAllChildren"},{"type":"invoke","args":[]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"transition"},{"type":"invoke","args":[{"type":"literal","value":{"opacity":0,"visibleScaleX":0.3,"visibleScaleY":3}},{"type":"literal","value":0.2}]}]}]}},"state":{"life":500,"maxLife":500}},"animated":{"params":{"animations":{"idle":{"offset":[0,-8],"uri":"/kitty.animation.json"}}}},"audible":{"params":{"sounds":{"deathSound":{"uri":"/ded.sound.json"}}}},"behaved":{"params":{"routines":{"type":"routines","routines":{"initial":{"type":"routine","routine":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}],"value":{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"floor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0},{"type":"literal","value":4}]}]}]}]}},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"moveFor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"Vector"},{"type":"key","key":"fromDirection"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0.25},{"type":"literal","value":2.5}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isAnimating"}],"value":{"type":"literal","value":false}},{"type":"traversal","steps":[{"type":"key","key":"Timing"},{"type":"key","key":"wait"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":1},{"type":"literal","value":4}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}],"value":{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"floor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0},{"type":"literal","value":4}]}]}]}]}},{"type":"traversal","steps":[{"type":"key","key":"Timing"},{"type":"key","key":"wait"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0.5},{"type":"literal","value":3}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isAnimating"}],"value":{"type":"literal","value":true}},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"spawnAt"},{"type":"invoke","args":[{"type":"literal","value":"kitteh"},{"type":"traversal","steps":[{"type":"key","key":"Utility"},{"type":"key","key":"makeArray"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"x"}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"y"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"context"},{"type":"key","key":"json"}]}]}]}]}}}}}},"collider":{"params":{"collidesWithGroups":["default","environmental","projectile"]}},"directional":{"params":{"directionCount":4},"state":{"direction":2}},"emitter":{},"existent":{"state":{"name":"Mama Kitty"}},"layered":{},"listed":{},"lootable":{"params":{"table":[{"perc":70,"json":{"uri":"/yarn-ball.entity.json"}},{"perc":80,"json":{"uri":"/yarn-ball.entity.json"}},{"perc":90,"json":{"uri":"/yarn-ball.entity.json"}}]}},"mobile":{"state":{"speed":40}},"physical":{},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[16,8]}}},"visible":{"state":{"visibleScale":[2,2]}},"vulnerable":{"params":{"types":["bio"]}},"spawner":{"params":{"spawns":{"kitteh":{"uri":"/kitty.entity.json"}}},"state":{"maxSpawns":10}}}}

View File

@ -0,0 +1 @@
{"traits":{"harmful":{"params":{"harmSpecs":[{"type":"potion","power":-50,"variance":0.1}]}},"existent":{},"item":{"params":{"cooldown":0.5,"itemActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"harm"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"wielder"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"decrementQuantity"},{"type":"invoke","args":[{"type":"literal","value":1}]}]}]},"slotImageUris":{"default":"/potion.png"}}}}}

View File

@ -0,0 +1 @@
{"traits":{"behaved":{"params":{"routines":{"type":"routines","routines":{"initial":{"type":"routine","routine":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"setDoesNotCollideWith"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"wielder"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"setPosition"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"position"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isVisible"}],"value":{"type":"literal","value":true}},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}],"value":{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"direction"}]}},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"moveFor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"Vector"},{"type":"key","key":"fromDirection"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}]}]}]},{"type":"literal","value":0.5}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"destroy"},{"type":"invoke","args":[]}]}]}},"reflect":{"type":"routine","routine":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isColliding"}],"value":{"type":"literal","value":false}},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isHarmful"}],"value":{"type":"literal","value":false}},{"type":"traversal","steps":[{"type":"key","key":"Flow"},{"type":"key","key":"parallel"},{"type":"invoke","args":[{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"transition"},{"type":"invoke","args":[{"type":"literal","value":{"opacity":0,"speed":0}},{"type":"literal","value":0.2}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"moveFor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"Vector"},{"type":"key","key":"sub"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"position"}]},{"type":"traversal","steps":[{"type":"key","key":"other"},{"type":"key","key":"position"}]}]}]},{"type":"literal","value":0.2}]}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"destroy"},{"type":"invoke","args":[]}]}]}}}}},"state":{"isBehaving":false}},"collider":{"params":{"collisionGroup":"projectile","collisionStartActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"context"},{"type":"key","key":"add"},{"type":"invoke","args":[{"type":"literal","value":"other"},{"type":"traversal","steps":[{"type":"key","key":"other"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"currentRoutine"}],"value":{"type":"literal","value":"reflect"}}]},"isSensor":true}},"directional":{"params":{"directionCount":4}},"emitter":{"params":{"particles":{"harmful":{"rate":0.0125,"count":5,"traits":{"primitive":{"params":{"primitives":[{"type":"circle","radius":0.5,"line":{"rgba":[128,128,128]},"fill":{"rgba":[128,128,128]}}]}}}}}}},"existent":{"state":{"name":"Rock (projectile)"}},"harmful":{"params":{"harmKnockback":100,"harmSpecs":[{"type":"blunt","power":50,"variance":0.1}]}},"layered":{},"listed":{},"mobile":{"state":{"speed":200}},"physical":{},"pictured":{"params":{"images":{"initial":{"offset":[0,0],"size":[12,12],"uri":"/rock.png"}}}},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[12,12]}}},"visible":{"state":{"isVisible":false,"visibleScale":[0.3,0.3]}}}}

View File

@ -0,0 +1 @@
{"traits":{"collider":{"params":{"isSensor":true}},"existent":{"state":{"name":"Rock"}},"item":{"params":{"cooldown":0.33,"itemActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"context"},{"type":"key","key":"add"},{"type":"invoke","args":[{"type":"literal","value":"projectile"},{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"spawn"},{"type":"invoke","args":[{"type":"literal","value":"rock"}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"projectile"},{"type":"key","key":"context"},{"type":"key","key":"add"},{"type":"invoke","args":[{"type":"literal","value":"wielder"},{"type":"traversal","steps":[{"type":"key","key":"wielder"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"projectile"},{"type":"key","key":"isBehaving"}],"value":{"type":"literal","value":true}}]},"slotImageUris":{"default":"/rock.png"}}},"layered":{},"listed":{},"magnetic":{},"mobile":{},"physical":{},"pictured":{"params":{"images":{"initial":{"offset":[0,0],"size":[12,12],"uri":"/rock.png"}}}},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[12,12]}}},"spawner":{"params":{"spawns":{"rock":{"uri":"/rock-projectile.entity.json"}}}},"visible":{}}}

View File

@ -0,0 +1 @@
{"traits":{"existent":{"state":{"name":"Tomato plant"}},"layered":{},"listed":{},"pictured":{"params":{"images":{"initial":{"offset":[0,0],"size":[16,16],"uri":"/tomato-stage-0.png"},"stage-1":{"offset":[0,3],"size":[16,16],"uri":"/tomato-stage-1.png"},"stage-2":{"offset":[0,3],"size":[16,16],"uri":"/tomato-stage-2.png"},"stage-3":{"offset":[0,3],"size":[16,16],"uri":"/tomato-stage-3.png"},"stage-4":{"offset":[0,3],"size":[16,16],"uri":"/tomato-stage-4.png"}}}},"plant":{"params":{"stageSpecs":{"0":{"growAt":2,"image":"initial"},"1":{"growAt":4,"image":"stage-1"},"2":{"growAt":6,"image":"stage-2"},"3":{"growAt":8,"image":"stage-3"},"4":{"image":"stage-4"}}}},"positioned":{},"roomed":{},"tile-entity":{},"visible":{}}}

View File

@ -0,0 +1 @@
{"traits":{"existent":{},"item":{"params":{"itemActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"useTool"},{"type":"invoke","args":[]}]}]},"slotImageUris":{"default":"/seeds.png"}}},"spawner":{"params":{"spawns":{"tomato-plant":{"uri":"/tomato-plant.entity.json"}}}},"tool":{"params":{"condition":{"type":"condition","operator":"and","operands":[{"type":"condition","operator":"is","operands":[{"type":"literal","value":7},{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"tileAt"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"target"}]}]}]}]},{"type":"condition","operator":"is","operands":[{"type":"literal","value":false},{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"hasTileEntityWithUriAt"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"target"}]},{"type":"literal","value":"/tomato-plant.entity.json"}]}]}]}]},"actions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"spawnAt"},{"type":"invoke","args":[{"type":"literal","value":"tomato-plant"},{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"Vector"},{"type":"key","key":"add"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"Vector"},{"type":"key","key":"mul"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"target"}]},{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"tileset"},{"type":"key","key":"tileSize"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"Math"},{"type":"key","key":"Vector"},{"type":"key","key":"scale"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"tileset"},{"type":"key","key":"tileSize"}]},{"type":"literal","value":0.5}]}]}]}]}]}]}]},"target":{"type":"projection","distance":-1,"length":3,"width":3}}}}}

View File

@ -0,0 +1 @@
{"traits":{"existent":{},"item":{"params":{"itemActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"useTool"},{"type":"invoke","args":[]}]}]},"slotImageUris":{"default":"/watering-can.png"}}},"tool":{"params":{"condition":{"type":"condition","operator":"is","operands":[{"type":"literal","value":6},{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"tileAt"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"target"}]}]}]}]},"actions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"wielder"},{"type":"key","key":"layer"},{"type":"key","key":"setTileAt"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"target"}]},{"type":"literal","value":7}]}]}]},"target":{"type":"projection","distance":1,"length":1,"width":1}}}}}

View File

@ -0,0 +1 @@
{"traits":{"collider":{"params":{"isSensor":true}},"existent":{"state":{"name":"Yarn Ball"}},"item":{"params":{"slotImageUris":{"default":"/yarn-ball.png"}}},"layered":{},"listed":{},"magnetic":{},"mobile":{},"pictured":{"params":{"images":{"initial":{"offset":[0,0],"size":[8,8],"uri":"/yarn-ball.png"}}}},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[16,16]}}},"visible":{}}}

8
side.js Normal file
View File

@ -0,0 +1,8 @@
const side = (process.env.SIDE || '').toLowerCase();
if (-1 === ['client', 'server'].indexOf(side)) {
throw new Error(
"You must define the SIDE environment variable as 'server' or 'client' when building!",
);
}
module.exports = side;

View File

@ -17,11 +17,12 @@ import {
import {clearAnimation, setAnimation} from '@avocado/timing'; import {clearAnimation, setAnimation} from '@avocado/timing';
import {World} from '@avocado/physics/matter/world'; import {World} from '@avocado/physics/matter/world';
import {Room, RoomView} from '@avocado/topdown'; import {Room, RoomView} from '@avocado/topdown';
import contempo from 'contempo';
// 1st party. // 1st party.
import {actionIds} from '../common/action-ids'; import {actionIds} from '../common/action-ids';
import {augmentParserWithThroughput} from '../common/parser-throughput'; import {augmentParserWithThroughput} from '../common/parser-throughput';
import {SelfEntityPacket} from '../common/packets/self-entity.packet'; import SelfEntityPacket from '../common/packets/self-entity.packet';
import {WorldTime} from '../common/world-time.synchronized'; import WorldTime from '../common/world-time.synchronized';
import {CycleTracker} from './cycle-tracker'; import {CycleTracker} from './cycle-tracker';
import {showMessage} from './overlay'; import {showMessage} from './overlay';
@ -210,7 +211,7 @@ export class App extends decorate(class {}) {
parser: this.AugmentedParser, parser: this.AugmentedParser,
}); });
this.socket.on('connect', () => { this.socket.on('connect', () => {
this.removeFromDom(document.querySelector('.app')); this.removeFromDom(document.querySelector('#root'));
this.room = null; this.room = null;
this.selfEntity = undefined; this.selfEntity = undefined;
this.selfEntityUuid = undefined; this.selfEntityUuid = undefined;
@ -302,7 +303,7 @@ export class App extends decorate(class {}) {
onPacket(packet) { onPacket(packet) {
if (!this.hasReceivedState) { if (!this.hasReceivedState) {
this.renderIntoDom(document.querySelector('.app')).then(() => { this.renderIntoDom(document.querySelector('#root')).then(() => {
this.startProcessingInput(); this.startProcessingInput();
this.startSimulation(); this.startSimulation();
this.startRendering(); this.startRendering();
@ -468,7 +469,7 @@ export class App extends decorate(class {}) {
const styles = innerStyles(); const styles = innerStyles();
for (const key in styles) { for (const key in styles) {
const style = styles[key]; const style = styles[key];
inner.style[key] = style; // inner.style[key] = style;
} }
} }
const listenForCameraChanges = () => { const listenForCameraChanges = () => {

13
src/client/index.ejs Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="<%= htmlWebpackPlugin.options.lang %>">
<head>
<meta charset="utf-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<div id="<%= htmlWebpackPlugin.options.appMountId %>">
<div class="debug-container"></div>
</div>
</body>
</html>

View File

@ -1,3 +1,4 @@
import './index.scss';
// 1st party. // 1st party.
import {App} from './app'; import {App} from './app';
// Application. // Application.

View File

@ -24,7 +24,7 @@ ins {
user-select: none; user-select: none;
} }
.app { #root {
display: flex; display: flex;
align-items: center; align-items: center;
height: 100%; height: 100%;

View File

@ -6,7 +6,7 @@ import {compose} from '@avocado/core';
import contempo from 'contempo'; import contempo from 'contempo';
const decorate = compose( const decorate = compose(
contempo(require('./index.raw.scss').default), contempo(require('./index.raw.scss')),
); );
const ChatComponent = () => { const ChatComponent = () => {

View File

@ -6,7 +6,7 @@ import {compose} from '@avocado/core';
import contempo from 'contempo'; import contempo from 'contempo';
const decorate = compose( const decorate = compose(
contempo(require('./connection-status.raw.scss').default), contempo(require('./connection-status.raw.scss')),
); );
const ConnectionStatusComponent = ({socket}) => { const ConnectionStatusComponent = ({socket}) => {

View File

@ -8,7 +8,7 @@ import contempo from 'contempo';
import Throughput from './throughput'; import Throughput from './throughput';
const decorate = compose( const decorate = compose(
contempo(require('./index.raw.scss').default), contempo(require('./index.raw.scss')),
); );
const ConnectionComponent = ({ const ConnectionComponent = ({

View File

@ -7,7 +7,7 @@ import {Vector} from '@avocado/math';
import contempo from 'contempo'; import contempo from 'contempo';
const decorate = compose( const decorate = compose(
contempo(require('./throughput.raw.scss').default), contempo(require('./throughput.raw.scss')),
); );
function formatKbps(bps) { function formatKbps(bps) {

View File

@ -12,7 +12,7 @@ import SelfEntity from './self-entity';
import Timers from './timers'; import Timers from './timers';
const decorate = compose( const decorate = compose(
contempo(require('./index.raw.scss').default), contempo(require('./index.raw.scss')),
hot, hot,
); );

View File

@ -8,7 +8,7 @@ import contempo from 'contempo';
import {usePropertyChange} from '../hooks/use-property-change'; import {usePropertyChange} from '../hooks/use-property-change';
const decorate = compose( const decorate = compose(
contempo(require('./self-entity.raw.scss').default), contempo(require('./self-entity.raw.scss')),
); );
const SelfEntityComponent = ({app}) => { const SelfEntityComponent = ({app}) => {

View File

@ -8,7 +8,7 @@ import contempo from 'contempo';
import {usePropertyChange} from '../hooks/use-property-change'; import {usePropertyChange} from '../hooks/use-property-change';
const decorate = compose( const decorate = compose(
contempo(require('./timers.raw.scss').default), contempo(require('./timers.raw.scss')),
); );
const TimersComponent = ({app}) => { const TimersComponent = ({app}) => {

View File

@ -11,7 +11,7 @@ import {useInventorySlice} from '../hooks/use-inventory-slice';
import ItemSlot from './item-slot'; import ItemSlot from './item-slot';
const decorate = compose( const decorate = compose(
contempo(require('./hotbar.raw.scss').default), contempo(require('./hotbar.raw.scss')),
); );
const HotbarComponent = ({selfEntity}) => { const HotbarComponent = ({selfEntity}) => {

View File

@ -13,7 +13,7 @@ import Inventory from './inventory';
import WorldTime from './world-time'; import WorldTime from './world-time';
const decorate = compose( const decorate = compose(
contempo(require('./index.raw.scss').default), contempo(require('./index.raw.scss')),
); );
const MenuComponent = ({app}) => { const MenuComponent = ({app}) => {

View File

@ -8,7 +8,7 @@ import {useInventorySlice} from '../hooks/use-inventory-slice';
import ItemSlot from './item-slot'; import ItemSlot from './item-slot';
const decorate = compose( const decorate = compose(
contempo(require('./inventory.raw.scss').default), contempo(require('./inventory.raw.scss')),
); );
const InventoryComponent = ({selfEntity}) => { const InventoryComponent = ({selfEntity}) => {

View File

@ -8,7 +8,7 @@ import contempo from 'contempo';
import {useEvent} from '../hooks/use-event'; import {useEvent} from '../hooks/use-event';
const decorate = compose( const decorate = compose(
contempo(require('./item-slot.raw.scss').default), contempo(require('./item-slot.raw.scss')),
); );
const ItemSlotComponent = (props) => { const ItemSlotComponent = (props) => {

View File

@ -8,7 +8,7 @@ import contempo from 'contempo';
import {usePropertyChange} from '../hooks/use-property-change'; import {usePropertyChange} from '../hooks/use-property-change';
const decorate = compose( const decorate = compose(
contempo(require('./quick-status.raw.scss').default), contempo(require('./quick-status.raw.scss')),
); );
const QuickStatusComponent = ({selfEntity}) => { const QuickStatusComponent = ({selfEntity}) => {

View File

@ -4,10 +4,10 @@ import React, {useEffect, useState} from 'react';
import {compose} from '@avocado/core'; import {compose} from '@avocado/core';
import contempo from 'contempo'; import contempo from 'contempo';
// 1st party. // 1st party.
import {WorldTime} from '../../../common/world-time.synchronized'; import WorldTime from '../../../common/world-time.synchronized';
const decorate = compose( const decorate = compose(
contempo(require('./world-time.raw.scss').default), contempo(require('./world-time.raw.scss')),
); );
const WorldTimeComponent = ({worldTime}) => { const WorldTimeComponent = ({worldTime}) => {

View File

@ -1,5 +1,5 @@
import {behaviorItemFromJSON} from '@avocado/behavior'; import {behaviorItemFromJSON} from '@avocado/behavior';
import {invokeHookFlat} from '@avocado/core'; import {invokeHookFlat} from 'scwp';
let _harmInteractions; let _harmInteractions;
export function harmInteractions(vulnerabilityType, harmType) { export function harmInteractions(vulnerabilityType, harmType) {

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class HarmPacket extends Packet { export default class HarmPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -2,13 +2,11 @@ import {compose} from '@avocado/core';
import {StateProperty, Trait} from '@avocado/entity'; import {StateProperty, Trait} from '@avocado/entity';
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
import {AFFINITY_PHYSICAL} from './constants';
const decorate = compose( const decorate = compose(
StateProperty('isHarmful'), StateProperty('isHarmful'),
); );
export class Harmful extends decorate(Trait) { export default class Harmful extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -10,9 +10,9 @@ import {
} from '@avocado/core'; } from '@avocado/core';
import {harmInteractions} from './harm'; import {harmInteractions} from './harm';
import {HarmPacket} from './harm.packet'; import HarmPacket from './harm.packet';
export class Vulnerable extends Trait { export default class Vulnerable extends Trait {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class SelfEntityPacket extends Packet { export default class SelfEntityPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdatePlantPacket extends Packet { export default class TraitUpdatePlantPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -2,7 +2,7 @@ import msgpack from 'msgpack-lite';
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdateReceptacleItemFullPacket extends Packet { export default class TraitUpdateReceptacleItemFullPacket extends Packet {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdateReceptacleItemQtyPacket extends Packet { export default class TraitUpdateReceptacleItemQtyPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdateReceptacleItemSwapPacket extends Packet { export default class TraitUpdateReceptacleItemSwapPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -1,6 +1,6 @@
import {SynchronizedUpdatePacket} from '@avocado/net'; import {SynchronizedUpdatePacket} from '@avocado/net';
export class WorldTimePacket extends SynchronizedUpdatePacket { export default class WorldTimePacket extends SynchronizedUpdatePacket {
static get synchronizationSchema() { static get synchronizationSchema() {
return { return {

View File

@ -3,7 +3,7 @@ import {Trait} from '@avocado/entity';
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
// Input handling. // Input handling.
export class Controllable extends Trait { export default class Controllable extends Trait {
static type() { static type() {
return 'controllable'; return 'controllable';

View File

@ -1,7 +1,7 @@
import {Trait} from '@avocado/entity'; import {Trait} from '@avocado/entity';
// Input handling. // Input handling.
export class Darkened extends Trait { export default class Darkened extends Trait {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -11,7 +11,7 @@ import {BundlePacket, ServerSynchronizer} from '@avocado/net';
const decorate = compose( const decorate = compose(
); );
export class Informed extends decorate(Trait) { export default class Informed extends decorate(Trait) {
static type() { static type() {
return 'informed'; return 'informed';

View File

@ -15,7 +15,7 @@ const decorate = compose(
}), }),
); );
export class Item extends decorate(Trait) { export default class Item extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -8,7 +8,7 @@ const decorate = compose(
}), }),
); );
export class Lootable extends decorate(Trait) { export default class Lootable extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -8,7 +8,7 @@ const decorate = compose(
}), }),
); );
export class Magnetic extends decorate(Trait) { export default class Magnetic extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -2,7 +2,7 @@ import {behaviorItemFromJSON, Context} from '@avocado/behavior';
import {compose, Property} from '@avocado/core'; import {compose, Property} from '@avocado/core';
import {StateProperty, Trait} from '@avocado/entity'; import {StateProperty, Trait} from '@avocado/entity';
import {TraitUpdatePlantPacket} from '../packets/trait-update-plant.packet'; import TraitUpdatePlantPacket from '../packets/trait-update-plant.packet';
const decorate = compose( const decorate = compose(
StateProperty('growthStage', { StateProperty('growthStage', {
@ -10,7 +10,7 @@ const decorate = compose(
}), }),
); );
export class Plant extends decorate(Trait) { export default class Plant extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,15 +1,9 @@
import {compose} from '@avocado/core'; import {compose} from '@avocado/core';
import {Entity, StateProperty, Trait} from '@avocado/entity'; import {Entity, StateProperty, Trait} from '@avocado/entity';
import { import TraitUpdateReceptacleItemQtyPacket from '../packets/trait-update-receptacle-item-qty.packet';
TraitUpdateReceptacleItemQtyPacket, import TraitUpdateReceptacleItemSwapPacket from '../packets/trait-update-receptacle-item-swap.packet';
} from '../packets/trait-update-receptacle-item-qty.packet'; import TraitUpdateReceptacleItemFullPacket from '../packets/trait-update-receptacle-item-full.packet';
import {
TraitUpdateReceptacleItemSwapPacket,
} from '../packets/trait-update-receptacle-item-swap.packet';
import {
TraitUpdateReceptacleItemFullPacket,
} from '../packets/trait-update-receptacle-item-full.packet';
const decorate = compose( const decorate = compose(
StateProperty('slotCount', { StateProperty('slotCount', {
@ -21,7 +15,7 @@ const NULL_SLOT = 65535;
const AUTO_SLOT = 65535; const AUTO_SLOT = 65535;
// TODO more localized events; inventoryChanged is too noisy // TODO more localized events; inventoryChanged is too noisy
export class Receptacle extends decorate(Trait) { export default class Receptacle extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -8,7 +8,7 @@ const decorate = compose(
); );
// Tools. // Tools.
export class Tool extends decorate(Trait) { export default class Tool extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -8,7 +8,7 @@ const decorate = compose(
}), }),
); );
export class Wielder extends decorate(Trait) { export default class Wielder extends decorate(Trait) {
static dependencies() { static dependencies() {
return [ return [

View File

@ -2,7 +2,7 @@ import {compose} from '@avocado/core';
import {SynchronizedMixin} from '@avocado/net'; import {SynchronizedMixin} from '@avocado/net';
import {Ticker} from '@avocado/timing'; import {Ticker} from '@avocado/timing';
import {WorldTimePacket} from './packets/world-time.packet'; import WorldTimePacket from './packets/world-time.packet';
const MAGIC_TO_FIT_HOUR_INTO_USHORT = 2730; const MAGIC_TO_FIT_HOUR_INTO_USHORT = 2730;
@ -10,7 +10,7 @@ const decorate = compose(
SynchronizedMixin, SynchronizedMixin,
); );
export class WorldTime extends decorate(class {}) { export default class WorldTime extends decorate(class {}) {
constructor(json) { constructor(json) {
super(); super();

Some files were not shown because too many files have changed in this diff Show More