Release Healer Man 0.1.5
This commit is contained in:
1 parent
f4c9cf356c
commit
55cfd43d66
62 files changed
+3030
-153
No files matched your search
@@ -3,6 +3,7 @@ export type MutableCombatPosition = [x: number, y: number, z: number];
|
||||
|
||||
interface RuntimeMobPosition {
|
||||
readonly value: MutableCombatPosition;
|
||||
yaw: number;
|
||||
mounted: boolean;
|
||||
}
|
||||
|
||||
@@ -12,9 +13,10 @@ function finite(value: number): number {
|
||||
return Number.isFinite(value) ? value : 0;
|
||||
}
|
||||
|
||||
export function registerMobRuntime(id: string, initial: CombatPosition = [0, 0, 0]): () => void {
|
||||
export function registerMobRuntime(id: string, initial: CombatPosition = [0, 0, 0], yaw = 0): () => void {
|
||||
const record: RuntimeMobPosition = {
|
||||
value: [finite(initial[0]), finite(initial[1]), finite(initial[2])],
|
||||
yaw: finite(yaw),
|
||||
mounted: true,
|
||||
};
|
||||
runtimePositions.set(id, record);
|
||||
@@ -24,16 +26,17 @@ export function registerMobRuntime(id: string, initial: CombatPosition = [0, 0,
|
||||
}
|
||||
|
||||
/** Allocation-free update intended for roaming-pack useFrame callbacks. */
|
||||
export function updateMobRuntimePosition(id: string, x: number, y: number, z: number): void {
|
||||
export function updateMobRuntimePosition(id: string, x: number, y: number, z: number, yaw?: number): void {
|
||||
const record = runtimePositions.get(id);
|
||||
if (record) {
|
||||
record.value[0] = finite(x);
|
||||
record.value[1] = finite(y);
|
||||
record.value[2] = finite(z);
|
||||
if (yaw !== undefined) record.yaw = finite(yaw);
|
||||
record.mounted = true;
|
||||
return;
|
||||
}
|
||||
runtimePositions.set(id, { value: [finite(x), finite(y), finite(z)], mounted: true });
|
||||
runtimePositions.set(id, { value: [finite(x), finite(y), finite(z)], yaw: finite(yaw ?? 0), mounted: true });
|
||||
}
|
||||
|
||||
export function unregisterMobRuntime(id: string): void {
|
||||
@@ -56,6 +59,11 @@ export function getMobRuntimePosition(id: string): CombatPosition | null {
|
||||
return record?.mounted ? [...record.value] as MutableCombatPosition : null;
|
||||
}
|
||||
|
||||
export function getMobRuntimeTransform(id: string): { readonly position: CombatPosition; readonly yaw: number } | null {
|
||||
const record = runtimePositions.get(id);
|
||||
return record?.mounted ? { position: [...record.value] as MutableCombatPosition, yaw: record.yaw } : null;
|
||||
}
|
||||
|
||||
export function mobRuntimeDistanceSquared(id: string, origin: CombatPosition): number {
|
||||
const record = runtimePositions.get(id);
|
||||
if (!record?.mounted) return Number.POSITIVE_INFINITY;
|
||||
|
||||
Reference in new issue
Block a user