@adatechnology/game-contracts 0.15.0 → 0.17.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 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
  }
@@ -620,6 +631,8 @@ interface Fragment {
620
631
  mass: number;
621
632
  /** Holes the part had where this fragment came from, in the fragment's own axes: the renderer keeps them on the debris. */
622
633
  marks?: readonly FragmentMark[];
634
+ /** Cut from inside the part (a page of a book, not its cover): the renderer draws it in the material's inner colour. */
635
+ inner?: boolean;
623
636
  }
624
637
  interface FragmentMark {
625
638
  /** Relative to the fragment's centre, in the fragment's axes. */
@@ -793,6 +806,18 @@ type DestructionEvent = (EventBase & {
793
806
  };
794
807
  fragments?: readonly Fragment[];
795
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
+ })
796
821
  /** Rebar of a reinforced part is bare: segments in world space. Empty `bars` means the cage is gone. */
797
822
  | (EventBase & {
798
823
  type: 'expose';
@@ -2219,4 +2244,25 @@ interface UnmarkedDrawing {
2219
2244
  /** Every visible mesh, line, point cloud or sprite under `root` with no marked ancestor (`root` itself not counted as one). */
2220
2245
  declare function unmarkedDrawings(root: unknown): UnmarkedDrawing[];
2221
2246
 
2222
- 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 FractureStyle, type Fragment, type FragmentHitOptions, type FragmentMark, 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, ignitionChance, kitOriginOf, markKitOrigin, mergeById, removeIds, resolveEntry, resolveIgnitionRules, sampleClip, scaleClip, shotExtras, shotToHit, sparkTargetFactor, toolAnimationStep, unmarkedDrawings, useToHit };
2247
+ /** A floor rectangle in an object's own space, metres (x across, z along). */
2248
+ interface Footprint {
2249
+ readonly minX: number;
2250
+ readonly maxX: number;
2251
+ readonly minZ: number;
2252
+ readonly maxZ: number;
2253
+ }
2254
+ /** What `footprintBlocker` reads of an object: its world matrix (three.js `Object3D`, duck-typed so the contracts stay free of three.js). */
2255
+ interface FootprintObject {
2256
+ readonly matrixWorld: {
2257
+ readonly elements: ArrayLike<number>;
2258
+ };
2259
+ readonly parent?: unknown;
2260
+ updateWorldMatrix?(updateParents: boolean, updateChildren: boolean): void;
2261
+ }
2262
+ /**
2263
+ * 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,
2264
+ * so the object blocks turned with it and follows it when it moves. An object out of the scene (no parent) blocks nothing.
2265
+ */
2266
+ declare function footprintBlocker(object: FootprintObject | (() => FootprintObject | null | undefined), footprint: Footprint | (() => Footprint | null | undefined)): (x: number, z: number, radius: number) => boolean;
2267
+
2268
+ 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 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 };
@@ -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