looks.module
README.md
turretsKit.looks
Builds a turret's model from simple shapes, locally on every peer, from its synced type,
tier and style. The turretsKit.Turret component calls build whenever its type, tier
or style changes and destroy on the previous rig.
The rig
build returns a Rig:
root: child of the turret entity holding everything, scaled by the tier'sscaletimes the style'sscale(also inrig.scale).yaw: the part that turns left and right;pitch: the part that tilts (child of yaw).muzzles: where shots leave, in the pitch part's local space (unscaled).recoil/recoilRest: parts that kick back on firing, and their rest positions.spin: a part that turns on its own (tesla cap, support dish), ornil.pivot: aim pivot offset from the entity;height: top of the model (label height).wall:{ w, h, d, ... }dimensions, set for wall turrets only (no yaw/pitch).parts: every spawned part.
Part colours come from slots a style paints: body, body2, trim, base, base2,
glow, accent (the turret type's own colour), plus fixed dark, wood, gold,
white. Bases follow the style's base_shape (plate, tower with optional crenellations
and banner, or block). Head shapes ship for machineGun, cannon, mortar, laser, tesla,
frost, poison, missile, sniper, flame and support; walls are built separately. A type's
shape picks the head; an unknown shape falls back to machineGun.
Functions
build(host: any, typeId: string, tier: number, styleId: string): Rig?: builds the model underhost. Unknown style falls back toscifi; unknown type returnsnil. Removes nothing: calldestroyon the previous rig first.destroy(rig: any): despawns a rig's parts.shapes(): { string }: every head shape id, plus"wall", sorted.defineShape(id: string, fn: any): adds a head shape for your own types:fn(ctx, yaw, pitch)builds parts withpart(...)and returns{ muzzles, recoil, spin, pitchY }.part(ctx, parent, mesh, slot, pos, scale, rot?, shadows?): spawns one painted part (mesh:box,cube,rounded,cylinder,sphere,cone,torus,capsule,octahedron;boxbecomes rounded in rounded styles).node(ctx, parent, name, pos): spawns an empty pivot entity.qx(deg),qy(deg),qz(deg): quaternions for a rotation about one axis.