@adatechnology/game-contracts 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +72 -2
- package/dist/index.global.js +19 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,12 @@ interface PartSpec {
|
|
|
107
107
|
capacity?: number;
|
|
108
108
|
rebar?: TensionRebar;
|
|
109
109
|
pile?: PileSpec;
|
|
110
|
+
/**
|
|
111
|
+
* Longest free span, in metres, the part holds on the parts it stands on: a shelf on the sides of a bookcase, a plank across two trestles. When
|
|
112
|
+
* a support goes and the ones left give it a longer span (one end hangs: the span of a cantilever is twice its overhang), the part falls with
|
|
113
|
+
* what rests on it. Without it the part stays as long as any support is left.
|
|
114
|
+
*/
|
|
115
|
+
maxSpan?: number;
|
|
110
116
|
};
|
|
111
117
|
/**
|
|
112
118
|
* Coats over the core, outermost first (plaster, tile, the paper of a drywall board). `thickness` of the part is the core only; each coat adds
|
|
@@ -506,6 +512,11 @@ interface PartState {
|
|
|
506
512
|
center: Vec3;
|
|
507
513
|
radius: number;
|
|
508
514
|
};
|
|
515
|
+
/** Units (`PartSpec.units`) knocked out one by one by shots and blows, in the part's own axes (`chip` events). Raycasts and shots pass through them. */
|
|
516
|
+
chipped?: Array<{
|
|
517
|
+
center: Vec3;
|
|
518
|
+
size: Vec3;
|
|
519
|
+
}>;
|
|
509
520
|
/** Index into `ObjectState.groups` of the piece this part belongs to (-1 when the part is broken, melted or ash). */
|
|
510
521
|
group: number;
|
|
511
522
|
}
|
|
@@ -773,7 +784,7 @@ type DestructionEvent = (EventBase & {
|
|
|
773
784
|
parts: string[];
|
|
774
785
|
mass: number;
|
|
775
786
|
})
|
|
776
|
-
/** The outer coat of a layered part came off at `point` (`layer` indexes `PartSpec.layers`; `area` in m²). */
|
|
787
|
+
/** The outer coat of a layered part came off at `point` (`layer` indexes `PartSpec.layers`; `area` in m²); `layer` -1 is a crater in the bare core (`MaterialHit.crater`). */
|
|
777
788
|
| (EventBase & {
|
|
778
789
|
type: 'spall';
|
|
779
790
|
part: string;
|
|
@@ -795,6 +806,18 @@ type DestructionEvent = (EventBase & {
|
|
|
795
806
|
};
|
|
796
807
|
fragments?: readonly Fragment[];
|
|
797
808
|
})
|
|
809
|
+
/**
|
|
810
|
+
* One unit of a wall of units (`PartSpec.units`: a brick, a block) came out under shots or blows: `center` in world space, `size` in the part's own
|
|
811
|
+
* axes and `rotation` the part's world rotation (the box of the unit that left), `fragments` the unit itself. The part stays: draw the gap, do not hide it.
|
|
812
|
+
*/
|
|
813
|
+
| (EventBase & {
|
|
814
|
+
type: 'chip';
|
|
815
|
+
part: string;
|
|
816
|
+
center: Vec3;
|
|
817
|
+
size: Vec3;
|
|
818
|
+
rotation: Quat;
|
|
819
|
+
fragments: readonly Fragment[];
|
|
820
|
+
})
|
|
798
821
|
/** Rebar of a reinforced part is bare: segments in world space. Empty `bars` means the cage is gone. */
|
|
799
822
|
| (EventBase & {
|
|
800
823
|
type: 'expose';
|
|
@@ -1723,6 +1746,17 @@ interface AreaPlacement {
|
|
|
1723
1746
|
/** Starts still: no physics until it is grabbed, hit or pushed. For props laid side by side that would otherwise nudge each other off. */
|
|
1724
1747
|
asleep?: boolean;
|
|
1725
1748
|
}
|
|
1749
|
+
/** A rectangle of the floor made of something else: `rect` is `[x0, z0, x1, z1]` in world metres, `surface` a ground profile id of the host. */
|
|
1750
|
+
interface GroundZone {
|
|
1751
|
+
readonly rect: readonly [number, number, number, number];
|
|
1752
|
+
readonly surface: string;
|
|
1753
|
+
}
|
|
1754
|
+
/** What the floor is made of. `surface` is a ground profile id (`lawn`, `road`, `concrete_slab`, `tile_floor`...); a host that does not know it uses its default. */
|
|
1755
|
+
interface GroundLayout {
|
|
1756
|
+
readonly surface: string;
|
|
1757
|
+
/** Later zones over earlier ones. */
|
|
1758
|
+
readonly zones?: readonly GroundZone[];
|
|
1759
|
+
}
|
|
1726
1760
|
/** How the host sets the module's area up: what goes where, and where the camera starts. */
|
|
1727
1761
|
interface ModuleArea {
|
|
1728
1762
|
placements: AreaPlacement[];
|
|
@@ -1979,6 +2013,19 @@ interface ModuleHost {
|
|
|
1979
2013
|
* player stops at them; the function is asked on every step, so it may follow a door that opens. Returns the function that takes it away. A host without a walking player leaves it out.
|
|
1980
2014
|
*/
|
|
1981
2015
|
addBlocker?(blocked: (x: number, z: number, radius: number) => boolean): () => void;
|
|
2016
|
+
/**
|
|
2017
|
+
* Puts an item of the host's catalogue (from any loaded module, by its id) in the world as part of the scenery: it stays through the clears and the openings of areas, and shots, blows, blasts
|
|
2018
|
+
* and fire hit it like any item (a module's lamp rig standing on a real car of the fleet). Scenarios that start from a seeded world run without it, and it comes back after them. `rotationY` turns it about the vertical axis. Returns null while no loaded module has the item; `remove`
|
|
2019
|
+
* takes it away. A host without a catalogue leaves it out.
|
|
2020
|
+
*/
|
|
2021
|
+
addObject?(itemId: string, place: {
|
|
2022
|
+
readonly position: Vec3;
|
|
2023
|
+
readonly rotationY?: number;
|
|
2024
|
+
}): {
|
|
2025
|
+
readonly objectId: string;
|
|
2026
|
+
readonly root: unknown;
|
|
2027
|
+
remove(): void;
|
|
2028
|
+
} | null;
|
|
1982
2029
|
/**
|
|
1983
2030
|
* Lends the host the place of the hands for the tool in the module's hands (a weapon's grip and handguard): the host that draws the player's arms reads `source` every frame, after the
|
|
1984
2031
|
* frame hooks have run, and puts the hands there. Pass null (or call the returned function) to let go. A host without arms leaves it out.
|
|
@@ -2017,6 +2064,8 @@ interface TestableModule<Context = unknown> {
|
|
|
2017
2064
|
controls?(locale: string): ModuleControl[];
|
|
2018
2065
|
layers?(locale: string): ModuleLayer[];
|
|
2019
2066
|
metrics?(locale: string): ModuleMetric[];
|
|
2067
|
+
/** The floor of the module's area, laid when the host opens it. Without it the host keeps its default floor. */
|
|
2068
|
+
ground?: GroundLayout;
|
|
2020
2069
|
/** Called once when the module is loaded, with what the host lends. Returns the function that undoes it. */
|
|
2021
2070
|
attach?(host: ModuleHost): () => void;
|
|
2022
2071
|
}
|
|
@@ -2221,4 +2270,25 @@ interface UnmarkedDrawing {
|
|
|
2221
2270
|
/** Every visible mesh, line, point cloud or sprite under `root` with no marked ancestor (`root` itself not counted as one). */
|
|
2222
2271
|
declare function unmarkedDrawings(root: unknown): UnmarkedDrawing[];
|
|
2223
2272
|
|
|
2224
|
-
|
|
2273
|
+
/** A floor rectangle in an object's own space, metres (x across, z along). */
|
|
2274
|
+
interface Footprint {
|
|
2275
|
+
readonly minX: number;
|
|
2276
|
+
readonly maxX: number;
|
|
2277
|
+
readonly minZ: number;
|
|
2278
|
+
readonly maxZ: number;
|
|
2279
|
+
}
|
|
2280
|
+
/** What `footprintBlocker` reads of an object: its world matrix (three.js `Object3D`, duck-typed so the contracts stay free of three.js). */
|
|
2281
|
+
interface FootprintObject {
|
|
2282
|
+
readonly matrixWorld: {
|
|
2283
|
+
readonly elements: ArrayLike<number>;
|
|
2284
|
+
};
|
|
2285
|
+
readonly parent?: unknown;
|
|
2286
|
+
updateWorldMatrix?(updateParents: boolean, updateChildren: boolean): void;
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* The `ModuleHost.addBlocker` function of a solid object standing on the floor: the walking player stays out of `footprint`, a rectangle in the object's own space,
|
|
2290
|
+
* so the object blocks turned with it and follows it when it moves. An object out of the scene (no parent) blocks nothing.
|
|
2291
|
+
*/
|
|
2292
|
+
declare function footprintBlocker(object: FootprintObject | (() => FootprintObject | null | undefined), footprint: Footprint | (() => Footprint | null | undefined)): (x: number, z: number, radius: number) => boolean;
|
|
2293
|
+
|
|
2294
|
+
export { type ActionControl, type AnimationClipSpec, type AnimationEventSpec, type AnimationKey, type AnimationPose, type AreaPlacement, type AudioListener, type AudioSink, type BallisticExtras, type BenchChange, type BenchDeclaration, type BenchReport, type BenchSheet, type BlastOptions, type BlastReport, type BlastShove, type BlastShoveOptions, type BlastSource, type BodyRegion, type BodySlot, type BooleanControl, type BusyOptions, type BusySink, type BusyTask, type CategorizedOptions, type CategorizedReport, type CategoryDef, type CategoryOptions, type CategoryRegistry, type ChainDelay, type CheckOptions, type CheckSpecOptions, type ChoiceControl, type ChoiceOption, type ConfinementOptions, type ContainerSpec, type ContractChecker, type ContractContext, type ControlPatch, type ControlValue, type Crack, DEFAULT_BLAST_SHOVE, DEFAULT_ENVIRONMENT, DEFAULT_IGNITION_RULES, type DamageStage, type DamageType, type DebrisKind, type DeepPartial, type Dent, type DestructibleImpl, type DestructibleSpec, type DestructionEvent, type DestructionEventType, type EffectHandle, type EffectRequest, type EffectSink, type EnvironmentBus, type EnvironmentKey, type EnvironmentState, type ExplosionChain, type FluidKind, type Footprint, type FootprintObject, type FractureStyle, type Fragment, type FragmentHitOptions, type FragmentMark, type GroundLayout, type GroundZone, type HandPose, type HandTargetSource, type HandTargets, type Hit, type HitIgnition, type HitResult, type Hole, type HostEvent, type HostTool, type HostToolAttachment, IMPACT_CONTRACT, type IgnitionRules, type ImpactContract, type ItemAnimationContract, type ItemUseDef, type JointKind, type JointSpec, type JointState, KIT_ORIGIN_KEY, type KitOrigin, type LiquidId, type LoopHandle, MISSING_BITS, type MaterialId, type ModuleArea, type ModuleBench, type ModuleControl, type ModuleHost, type ModuleItemFluid, type ModuleLayer, type ModuleMetric, type ModuleScenario, type NumberControl, type ObjectState, type PartBreach, type PartShape, type PartSpec, type PartState, type PartStatus, type PartUnits, type PileSpec, type PlayerState, type Quat, type RayHit, type Reinforcement, STAGE_EVENT, type SegmentKind, type ShelterOptions, type Shot, type SoilLayer, type SoilProfile, type SoilState, type SoundHandle, type SoundRequest, type SpecReport, type StructureRole, type SurfaceLayer, TOOL_CLIP, type TensionRebar, type TestableItem, type TestableModule, type Thumbnail, type ToolAnimationStep, type ToolAnimator, type ToolClipId, type ToolClipPlayer, type ToolClipPlayerOptions, type ToolClipSet, type ToolCommand, type ToolCommandResult, type ToolKind, type ToolRig, type TunedMassDamper, type UnmarkedDrawing, type Use, type Vec3, type WarmUpProbes, type WindExposure, type WindState, applyPatches, blastShove, checkAnimation, checkBench, checkCategorized, checkDestructible, checkHit, checkSpec, checkToolClips, createEnvironmentBus, createToolClipPlayer, deepMerge, defineCategories, fillFactor, footprintBlocker, ignitionChance, kitOriginOf, markKitOrigin, mergeById, removeIds, resolveEntry, resolveIgnitionRules, sampleClip, scaleClip, shotExtras, shotToHit, sparkTargetFactor, toolAnimationStep, unmarkedDrawings, useToHit };
|
package/dist/index.global.js
CHANGED
|
@@ -43,6 +43,7 @@ var GameContracts = (() => {
|
|
|
43
43
|
deepMerge: () => deepMerge,
|
|
44
44
|
defineCategories: () => defineCategories,
|
|
45
45
|
fillFactor: () => fillFactor,
|
|
46
|
+
footprintBlocker: () => footprintBlocker,
|
|
46
47
|
ignitionChance: () => ignitionChance,
|
|
47
48
|
kitOriginOf: () => kitOriginOf,
|
|
48
49
|
markKitOrigin: () => markKitOrigin,
|
|
@@ -873,6 +874,24 @@ var GameContracts = (() => {
|
|
|
873
874
|
walk(root, false);
|
|
874
875
|
return out;
|
|
875
876
|
}
|
|
877
|
+
|
|
878
|
+
// src/footprint.ts
|
|
879
|
+
function footprintBlocker(object, footprint) {
|
|
880
|
+
return (x, z, radius) => {
|
|
881
|
+
const o = typeof object === "function" ? object() : object;
|
|
882
|
+
const fp = typeof footprint === "function" ? footprint() : footprint;
|
|
883
|
+
if (!o || !fp || !o.parent) return false;
|
|
884
|
+
o.updateWorldMatrix?.(true, false);
|
|
885
|
+
const e = o.matrixWorld.elements;
|
|
886
|
+
const dx = x - e[12];
|
|
887
|
+
const dz = z - e[14];
|
|
888
|
+
const ax = e[0] ** 2 + e[1] ** 2 + e[2] ** 2;
|
|
889
|
+
const az = e[8] ** 2 + e[9] ** 2 + e[10] ** 2;
|
|
890
|
+
const lx = (dx * e[0] + dz * e[2]) / (ax || 1);
|
|
891
|
+
const lz = (dx * e[8] + dz * e[10]) / (az || 1);
|
|
892
|
+
return lx > fp.minX - radius && lx < fp.maxX + radius && lz > fp.minZ - radius && lz < fp.maxZ + radius;
|
|
893
|
+
};
|
|
894
|
+
}
|
|
876
895
|
return __toCommonJS(index_exports);
|
|
877
896
|
})();
|
|
878
897
|
//# sourceMappingURL=index.global.js.map
|