att-string-transcoder
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -5,2 +5,4 @@ import * as transcoders from './transcoders'; | ||
export declare type DurabilityModule = transcoders.DurabilityModule.DurabilityModule; | ||
export declare type Fire = transcoders.Fire.Fire; | ||
export declare type Fuse = transcoders.Fuse.Fuse; | ||
export declare type HeatSourceBase = transcoders.HeatSourceBase.HeatSourceBase; | ||
@@ -13,6 +15,7 @@ export declare type LiquidContainer = transcoders.LiquidContainer.LiquidContainer; | ||
export declare type PopulationSpawnArea = transcoders.PopulationSpawnArea.PopulationSpawnArea; | ||
export declare type SentGift = transcoders.SentGift.SentGift; | ||
export declare type SpawnArea = transcoders.SpawnArea.SpawnArea; | ||
export declare type StatManager = transcoders.StatManager.StatManager; | ||
export declare type WoodcutTree = transcoders.WoodcutTree.WoodcutTree; | ||
export declare type KnownComponent = BasicDecay | DurabilityModule | HeatSourceBase | LiquidContainer | NetworkRigidbody | PhysicalMaterialPart | Pickup | PickupDock | PopulationSpawnArea | SpawnArea | StatManager | WoodcutTree; | ||
export declare type KnownComponent = BasicDecay | DurabilityModule | Fire | Fuse | HeatSourceBase | LiquidContainer | NetworkRigidbody | PhysicalMaterialPart | Pickup | PickupDock | PopulationSpawnArea | SentGift | SpawnArea | StatManager | WoodcutTree; | ||
export declare type UnknownComponent = { | ||
@@ -19,0 +22,0 @@ hash: number; |
export * as BasicDecay from './basicDecay'; | ||
export * as DurabilityModule from './durabilityModule'; | ||
export * as Fire from './fire'; | ||
export * as Fuse from './fuse'; | ||
export * as HeatSourceBase from './heatSourceBase'; | ||
@@ -10,4 +12,5 @@ export * as LiquidContainer from './liquidContainer'; | ||
export * as PopulationSpawnArea from './populationSpawnArea'; | ||
export * as SentGift from './sentGift'; | ||
export * as SpawnArea from './spawnArea'; | ||
export * as StatManager from './statManager'; | ||
export * as WoodcutTree from './woodcutTree'; |
@@ -22,5 +22,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WoodcutTree = exports.StatManager = exports.SpawnArea = exports.PopulationSpawnArea = exports.PickupDock = exports.Pickup = exports.PhysicalMaterialPart = exports.NetworkRigidbody = exports.LiquidContainer = exports.HeatSourceBase = exports.DurabilityModule = exports.BasicDecay = void 0; | ||
exports.WoodcutTree = exports.StatManager = exports.SpawnArea = exports.SentGift = exports.PopulationSpawnArea = exports.PickupDock = exports.Pickup = exports.PhysicalMaterialPart = exports.NetworkRigidbody = exports.LiquidContainer = exports.HeatSourceBase = exports.Fuse = exports.Fire = exports.DurabilityModule = exports.BasicDecay = void 0; | ||
exports.BasicDecay = __importStar(require("./basicDecay")); | ||
exports.DurabilityModule = __importStar(require("./durabilityModule")); | ||
exports.Fire = __importStar(require("./fire")); | ||
exports.Fuse = __importStar(require("./fuse")); | ||
exports.HeatSourceBase = __importStar(require("./heatSourceBase")); | ||
@@ -33,4 +35,5 @@ exports.LiquidContainer = __importStar(require("./liquidContainer")); | ||
exports.PopulationSpawnArea = __importStar(require("./populationSpawnArea")); | ||
exports.SentGift = __importStar(require("./sentGift")); | ||
exports.SpawnArea = __importStar(require("./spawnArea")); | ||
exports.StatManager = __importStar(require("./statManager")); | ||
exports.WoodcutTree = __importStar(require("./woodcutTree")); |
import { BinaryReader } from '../../utils'; | ||
declare type PopulationSaveDataChild = { | ||
declare type PopulationSaveDataChild = null | { | ||
index: number; | ||
@@ -4,0 +4,0 @@ pointIndex: number; |
@@ -14,2 +14,8 @@ "use strict"; | ||
for (let index = 0; index < childrenLength; ++index) { | ||
/* Skip child if is null. */ | ||
const isNull = reader.boolean(); | ||
if (isNull) { | ||
children.push(null); | ||
continue; | ||
} | ||
children.push({ | ||
@@ -16,0 +22,0 @@ index: reader.int(), |
import { Prefab } from './Prefab'; | ||
import { PrefabData } from './decoders'; | ||
import { PhysicalMaterialPartHash } from '.'; | ||
import { PhysicalMaterialPartHash } from './PhysicalMaterialPartHash'; | ||
declare type PrefabManager<S> = { | ||
@@ -21,2 +21,4 @@ name: string; | ||
setOnFire: (isLit?: boolean) => PrefabManager<S>; | ||
setGiftBoxLabel: (label: string) => PrefabManager<S>; | ||
addGift: <P extends Prefab, C extends keyof P['slots']>(gift: PrefabManager<C>) => PrefabManager<S>; | ||
useSlot: <P extends Prefab, C extends keyof P['slots']>(slot: S, childPrefab: PrefabManager<C>) => PrefabManager<S>; | ||
@@ -23,0 +25,0 @@ toString: () => string; |
@@ -6,4 +6,5 @@ "use strict"; | ||
const createString_1 = require("./createString"); | ||
const _1 = require("."); | ||
const VALID_MATERIALS = Object.values(_1.PhysicalMaterialPartHash) | ||
const PhysicalMaterialPartHash_1 = require("./PhysicalMaterialPartHash"); | ||
const utils_1 = require("./utils"); | ||
const VALID_MATERIALS = Object.values(PhysicalMaterialPartHash_1.PhysicalMaterialPartHash) | ||
.filter(key => typeof key === 'string') | ||
@@ -84,3 +85,3 @@ .sort((a, b) => (a < b ? -1 : 1)); | ||
this.data.components = Object.assign(Object.assign({}, this.data.components), { PhysicalMaterialPart: { | ||
materialHash: _1.PhysicalMaterialPartHash[material] | ||
materialHash: PhysicalMaterialPartHash_1.PhysicalMaterialPartHash[material] | ||
} }); | ||
@@ -104,5 +105,30 @@ return this; | ||
setOnFire(isLit = true) { | ||
this.data.embeddedEntities.Fire = Object.assign(Object.assign({}, this.data.embeddedEntities.Fire), { isAlive: isLit, components: Object.assign(Object.assign({}, this.data.embeddedEntities.Fire.components), { HeatSourceBase: Object.assign(Object.assign({}, this.data.embeddedEntities.Fire.components.HeatSourceBase), { isLit }) }) }); | ||
var _a, _b, _c; | ||
this.data.embeddedEntities.Fire = Object.assign(Object.assign({}, this.data.embeddedEntities.Fire), { isAlive: isLit, components: Object.assign(Object.assign({}, (_a = this.data.embeddedEntities.Fire) === null || _a === void 0 ? void 0 : _a.components), { HeatSourceBase: Object.assign(Object.assign({}, (_c = (_b = this.data.embeddedEntities.Fire) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.HeatSourceBase), { isLit }) }) }); | ||
return this; | ||
}, | ||
setGiftBoxLabel(label) { | ||
this.data.components = Object.assign(Object.assign({}, this.data.components), { SentGift: Object.assign(Object.assign({}, this.data.components.SentGift), { senderName: label }) }); | ||
return this; | ||
}, | ||
addGift(giftPrefab) { | ||
var _a, _b; | ||
if (!utils_1.reasonableGifts.includes(giftPrefab.data.prefabObject.hash)) { | ||
throw new Error('No gifts for naughty people.'); | ||
} | ||
const string = (0, createString_1.createString)(giftPrefab.data); | ||
const [dataString, versionsString] = string.split('|'); | ||
const [hash, messageSizeInBytes, ...data] = dataString.split(',').map(Number); | ||
const [_, ...chunkVersioning] = versionsString.split(',').map(Number); | ||
this.data.components = Object.assign(Object.assign({}, this.data.components), { SentGift: Object.assign(Object.assign({}, this.data.components.SentGift), { gifts: [ | ||
...((_b = (_a = this.data.components.SentGift) === null || _a === void 0 ? void 0 : _a.gifts) !== null && _b !== void 0 ? _b : []), | ||
{ | ||
data, | ||
messageSizeInBytes, | ||
hash, | ||
chunkVersioning | ||
} | ||
] }) }); | ||
return this; | ||
}, | ||
useSlot(slotName, childPrefab) { | ||
@@ -109,0 +135,0 @@ var _a, _b; |
@@ -5,6 +5,9 @@ export declare type BinaryReader = { | ||
uInt: () => number; | ||
uShort: () => number; | ||
uLong: () => number; | ||
float: () => number; | ||
int: () => number; | ||
char: () => string; | ||
string: () => string; | ||
}; | ||
export declare const createBinaryReader: (binary: string) => BinaryReader; |
@@ -26,2 +26,6 @@ "use strict"; | ||
}, | ||
uShort: function () { | ||
const bits = this.binary(16); | ||
return (0, binaryToNumber_1.binaryToNumber)(bits); | ||
}, | ||
uLong: function () { | ||
@@ -38,2 +42,38 @@ const bits = this.binary(64); | ||
return (0, binaryToInt_1.binaryToInt)(bits); | ||
}, | ||
char: function () { | ||
const bits = this.binary(8); | ||
const charCode = (0, binaryToNumber_1.binaryToNumber)(bits); | ||
return String.fromCharCode(charCode); | ||
}, | ||
string: function () { | ||
const length = this.uShort(); | ||
if (length === 0) | ||
return ''; | ||
/* Align bits. */ | ||
const offset = index.current % 8 === 0 ? 0 : 8 - (index.current % 8); | ||
if (offset > 0) | ||
this.binary(offset); | ||
let currentByte = (index.current % 32) / 8; | ||
/* Read garbled text from binary. */ | ||
let textBuffer = ''; | ||
while (textBuffer.length < length) { | ||
textBuffer += this.char(); | ||
} | ||
/* Untangle garbled text. */ | ||
let text = ''; | ||
let bufferIndex = 0; | ||
while (currentByte < 4 && bufferIndex < length) { | ||
text += textBuffer[bufferIndex++]; | ||
currentByte++; | ||
} | ||
while (bufferIndex + 4 <= length) { | ||
const chars = textBuffer.substr(bufferIndex, 4); | ||
text += chars.split('').reverse().join(''); | ||
bufferIndex += 4; | ||
} | ||
while (bufferIndex < length) { | ||
text += textBuffer[bufferIndex++]; | ||
} | ||
return text; | ||
} | ||
@@ -40,0 +80,0 @@ }; |
@@ -5,7 +5,10 @@ export declare type BinaryWriter = { | ||
uInt: (number: number) => void; | ||
uShort: (number: number) => void; | ||
uLong: (number: number) => void; | ||
float: (number: number) => void; | ||
int: (number: number) => void; | ||
char: (char: string) => void; | ||
string: (text: string) => void; | ||
flush: () => string; | ||
}; | ||
export declare const createBinaryWriter: () => BinaryWriter; |
@@ -5,5 +5,7 @@ "use strict"; | ||
const floatToBinary_1 = require("./floatToBinary"); | ||
const uShortToBinary_1 = require("./uShortToBinary"); | ||
const uLongToBinary_1 = require("./uLongToBinary"); | ||
const intToBinary_1 = require("./intToBinary"); | ||
const uIntToBinary_1 = require("./uIntToBinary"); | ||
const numberToBinary_1 = require("./numberToBinary"); | ||
const createBinaryWriter = () => { | ||
@@ -21,2 +23,5 @@ let binary = ''; | ||
}, | ||
uShort: function (number) { | ||
binary += (0, uShortToBinary_1.uShortToBinary)(number); | ||
}, | ||
uLong: function (number) { | ||
@@ -31,2 +36,38 @@ binary += (0, uLongToBinary_1.uLongToBinary)(number); | ||
}, | ||
char: function (char) { | ||
const charCode = char.charCodeAt(0); | ||
const bits = (0, numberToBinary_1.numberToBinary)(charCode).padStart(8, '0'); | ||
binary += bits; | ||
}, | ||
string: function (textBuffer) { | ||
this.uShort(textBuffer.length); | ||
if (textBuffer.length === 0) | ||
return; | ||
/* Align bits. */ | ||
const index = binary.length; | ||
const offset = index % 8 === 0 ? 0 : 8 - (index % 8); | ||
if (offset > 0) { | ||
const align = '0'.repeat(offset); | ||
this.binary(align); | ||
} | ||
let currentByte = (binary.length % 32) / 8; | ||
/* Garble text, ATT style. */ | ||
let text = ''; | ||
let bufferIndex = 0; | ||
while (currentByte < 4 && bufferIndex < textBuffer.length) { | ||
text += textBuffer[bufferIndex++]; | ||
currentByte++; | ||
} | ||
while (bufferIndex + 4 <= textBuffer.length) { | ||
const chars = textBuffer.substr(bufferIndex, 4); | ||
text += chars.split('').reverse().join(''); | ||
bufferIndex += 4; | ||
} | ||
while (bufferIndex < textBuffer.length) { | ||
text += textBuffer[bufferIndex++]; | ||
} | ||
for (const letter of text) { | ||
this.char(letter); | ||
} | ||
}, | ||
flush: function () { | ||
@@ -33,0 +74,0 @@ const result = binary; |
@@ -11,4 +11,6 @@ export { binaryToNumber } from './binaryToNumber'; | ||
export { numberToBinary } from './numberToBinary'; | ||
export { reasonableGifts } from './reasonableGifts'; | ||
export { uIntToBinary } from './uIntToBinary'; | ||
export { uLongToBinary } from './uLongToBinary'; | ||
export { uShortToBinary } from './uShortToBinary'; | ||
export { unpackFloat } from './unpackFloat'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unpackFloat = exports.uLongToBinary = exports.uIntToBinary = exports.numberToBinary = exports.intToBinary = exports.floatToBinary = exports.createBinaryWriter = exports.createBinaryReader = exports.generateComposition = exports.composeTree = exports.binaryToULong = exports.binaryToUIntArray = exports.binaryToInt = exports.binaryToNumber = void 0; | ||
exports.unpackFloat = exports.uShortToBinary = exports.uLongToBinary = exports.uIntToBinary = exports.reasonableGifts = exports.numberToBinary = exports.intToBinary = exports.floatToBinary = exports.createBinaryWriter = exports.createBinaryReader = exports.generateComposition = exports.composeTree = exports.binaryToULong = exports.binaryToUIntArray = exports.binaryToInt = exports.binaryToNumber = void 0; | ||
var binaryToNumber_1 = require("./binaryToNumber"); | ||
@@ -25,2 +25,4 @@ Object.defineProperty(exports, "binaryToNumber", { enumerable: true, get: function () { return binaryToNumber_1.binaryToNumber; } }); | ||
Object.defineProperty(exports, "numberToBinary", { enumerable: true, get: function () { return numberToBinary_1.numberToBinary; } }); | ||
var reasonableGifts_1 = require("./reasonableGifts"); | ||
Object.defineProperty(exports, "reasonableGifts", { enumerable: true, get: function () { return reasonableGifts_1.reasonableGifts; } }); | ||
var uIntToBinary_1 = require("./uIntToBinary"); | ||
@@ -30,3 +32,5 @@ Object.defineProperty(exports, "uIntToBinary", { enumerable: true, get: function () { return uIntToBinary_1.uIntToBinary; } }); | ||
Object.defineProperty(exports, "uLongToBinary", { enumerable: true, get: function () { return uLongToBinary_1.uLongToBinary; } }); | ||
var uShortToBinary_1 = require("./uShortToBinary"); | ||
Object.defineProperty(exports, "uShortToBinary", { enumerable: true, get: function () { return uShortToBinary_1.uShortToBinary; } }); | ||
var unpackFloat_1 = require("./unpackFloat"); | ||
Object.defineProperty(exports, "unpackFloat", { enumerable: true, get: function () { return unpackFloat_1.unpackFloat; } }); |
{ | ||
"name": "att-string-transcoder", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Trancode integer strings for A Township Tale.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
712342
135
9182