File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export type ComponentName = keyof typeof transcoders;
55export type BasicDecay = transcoders . BasicDecay . BasicDecay ;
66export type DurabilityModule = transcoders . DurabilityModule . DurabilityModule ;
77export type Fire = transcoders . Fire . Fire ;
8+ export type Fuse = transcoders . Fuse . Fuse ;
89export type HeatSourceBase = transcoders . HeatSourceBase . HeatSourceBase ;
910export type LiquidContainer = transcoders . LiquidContainer . LiquidContainer ;
1011export type NetworkRigidbody = transcoders . NetworkRigidbody . NetworkRigidbody ;
@@ -20,6 +21,7 @@ export type KnownComponent =
2021 | BasicDecay
2122 | DurabilityModule
2223 | Fire
24+ | Fuse
2325 | HeatSourceBase
2426 | LiquidContainer
2527 | NetworkRigidbody
Original file line number Diff line number Diff line change 1+ import { ComponentHash } from '../../ComponentHash' ;
2+ import { BinaryReader , createBinaryWriter } from '../../utils' ;
3+
4+ export type Fuse = {
5+ isFinished ?: boolean ;
6+ isLit ?: boolean ;
7+ currentFuseAmount ?: number ;
8+ } ;
9+
10+ export const decode = ( reader : BinaryReader ) : Fuse => ( {
11+ isFinished : reader . boolean ( ) ,
12+ isLit : reader . boolean ( ) ,
13+ currentFuseAmount : reader . float ( )
14+ } ) ;
15+
16+ export const encode = ( { isFinished = false , isLit = false , currentFuseAmount = 1 } : Fuse ) : string => {
17+ const writer = createBinaryWriter ( ) ;
18+
19+ /* Component hash. */
20+ writer . uInt ( ComponentHash . Fuse ) ;
21+ const hashBits = writer . flush ( ) ;
22+
23+ /* Component data. */
24+ writer . boolean ( isFinished ) ;
25+ writer . boolean ( isLit ) ;
26+ writer . float ( currentFuseAmount ) ;
27+ const dataBits = writer . flush ( ) ;
28+
29+ /* Component data length. */
30+ writer . uInt ( dataBits . length ) ;
31+ const sizeBits = writer . flush ( ) ;
32+
33+ /* Return encoded component. */
34+ writer . binary ( hashBits ) ;
35+ writer . binary ( sizeBits ) ;
36+ writer . binary ( dataBits ) ;
37+
38+ return writer . flush ( ) ;
39+ } ;
Original file line number Diff line number Diff line change 11export * as BasicDecay from './basicDecay' ;
22export * as DurabilityModule from './durabilityModule' ;
33export * as Fire from './fire' ;
4+ export * as Fuse from './fuse' ;
45export * as HeatSourceBase from './heatSourceBase' ;
56export * as LiquidContainer from './liquidContainer' ;
67export * as NetworkRigidbody from './networkRigidbody' ;
You can’t perform that action at this time.
0 commit comments