Isle-Slingers/js/physics/index.js

73 lines
2.6 KiB
JavaScript
Raw Normal View History

/* ISLE SLINGERS -- physics/index.js (module: physics -- aggregator / public API)
* RC-375D84 S-2 modularization. This is the THIN AGGREGATOR for the physics
* module. The original js/core.js monolith is now split into submodules
* (physics/constants, -/state, -/aim, -/abilities, -/damage, -/step,
* -/collision, -/rules, -/camera); each installs its units into ONE shared
* scope `P`, preserving the monolith's single-closure semantics exactly.
*
* Load contract:
* browser -- every physics/<unit>/index.js <script> must load BEFORE this
* file (it reads the ordered parts off globalThis.ISLE_PHYSICS_PARTS);
* node -- this file requires the submodules in dependency order itself.
*
* Public API (ISLE_CORE) is key-for-key identical to the pre-modularization
* core.js return object -- same 20 keys, same values. No DOM, deterministic.
*/
(function (root, factory) {
var api = factory();
if (typeof module !== 'undefined' && module.exports) module.exports = api;
else root.ISLE_CORE = api;
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
'use strict';
var P = {}; // the single shared physics scope (== the old monolith closure)
var parts;
if (typeof module !== 'undefined' && module.exports) {
// Node: load submodules in dependency order (constants first, camera last)
parts = [
require('./constants/index.js'),
require('./state/index.js'),
require('./aim/index.js'),
require('./abilities/index.js'),
require('./damage/index.js'),
require('./step/index.js'),
require('./collision/index.js'),
require('./topple/index.js'),
require('./rules/index.js'),
require('./camera/index.js')
];
} else {
// browser: submodules already pushed their installers, in <script> order
parts = (typeof globalThis !== 'undefined' && globalThis.ISLE_PHYSICS_PARTS) || [];
}
for (var i = 0; i < parts.length; i++) parts[i](P);
// ------------------------------------------------------------------ API
// (kept key-for-key identical to the pre-S-2 core.js public surface)
return {
WORLD: P.WORLD,
VIEW: P.VIEW,
MATERIALS: P.MATERIALS,
BIRD_TYPES: P.BIRD_TYPES,
ENEMY_TYPES: P.ENEMY_TYPES,
GRAVITY: P.GRAVITY,
MAX_PULL: P.MAX_PULL,
MIN_PULL: P.MIN_PULL,
LAUNCH_POWER: P.LAUNCH_POWER,
BIRD_BONUS: P.BIRD_BONUS,
createGame: P.createGame,
activeBird: P.activeBird,
aimVector: P.aimVector,
trajectory: P.trajectory,
launch: P.launch,
triggerAbility: P.triggerAbility,
step: P.step,
starsFor: P.starsFor,
birdsRemaining: P.birdsRemaining,
AIR_DRAG: P.AIR_DRAG
};
});