cleaned Randomizer

This commit is contained in:
Dank074 2021-06-07 01:10:53 -05:00
parent c88cca1bf7
commit 8ef477ea80
10 changed files with 98 additions and 98 deletions

View File

@ -72,7 +72,7 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
this.init(0, 0, 0, this._direction, this._force, this._timeStep, this._fuseTime, true); this.init(0, 0, 0, this._direction, this._force, this._timeStep, this._fuseTime, true);
} }
public _Str_17988(k:FurnitureParticleSystemEmitter, _arg_2: number): void public copyStateFrom(k:FurnitureParticleSystemEmitter, _arg_2: number): void
{ {
super.copy(k, _arg_2); super.copy(k, _arg_2);
this._force = k._force; this._force = k._force;
@ -87,7 +87,7 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
this._hasIgnited = k._hasIgnited; this._hasIgnited = k._hasIgnited;
} }
public _Str_24892(k: number, _arg_2: boolean, _arg_3: GraphicAsset[], _arg_4: boolean): void public configureParticle(k: number, _arg_2: boolean, _arg_3: GraphicAsset[], _arg_4: boolean): void
{ {
const _local_5 = []; const _local_5 = [];
_local_5['lifeTime'] = k; _local_5['lifeTime'] = k;
@ -104,17 +104,17 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
{ {
if(this.age > 1) if(this.age > 1)
{ {
this._Str_19068(this, this.direction); this.releaseParticles(this, this.direction);
} }
} }
} }
private _Str_19068(k:FurnitureParticleSystemParticle, _arg_2: Vector3D = null): void private releaseParticles(k:FurnitureParticleSystemParticle, _arg_2: Vector3D = null): void
{ {
if(!_arg_2) _arg_2 = new Vector3D(); if(!_arg_2) _arg_2 = new Vector3D();
const _local_3 = new Vector3D(); const _local_3 = new Vector3D();
const _local_5 = this._Str_23904(); const _local_5 = this.getRandomParticleConfiguration();
let _local_10 = 0; let _local_10 = 0;
@ -123,19 +123,19 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
switch(this._explosionShape) switch(this._explosionShape)
{ {
case FurnitureParticleSystemEmitter.CONE: case FurnitureParticleSystemEmitter.CONE:
_local_3.x = ((this._Str_7471(0.5)) ? Math.random() : -(Math.random())); _local_3.x = ((this.randomBoolean(0.5)) ? Math.random() : -(Math.random()));
_local_3.y = -(Math.random() + 1); _local_3.y = -(Math.random() + 1);
_local_3.z = ((this._Str_7471(0.5)) ? Math.random() : -(Math.random())); _local_3.z = ((this.randomBoolean(0.5)) ? Math.random() : -(Math.random()));
break; break;
case FurnitureParticleSystemEmitter.PLANE: case FurnitureParticleSystemEmitter.PLANE:
_local_3.x = ((this._Str_7471(0.5)) ? Math.random() : -(Math.random())); _local_3.x = ((this.randomBoolean(0.5)) ? Math.random() : -(Math.random()));
_local_3.y = 0; _local_3.y = 0;
_local_3.z = ((this._Str_7471(0.5)) ? Math.random() : -(Math.random())); _local_3.z = ((this.randomBoolean(0.5)) ? Math.random() : -(Math.random()));
break; break;
case FurnitureParticleSystemEmitter.SPHERE: case FurnitureParticleSystemEmitter.SPHERE:
_local_3.x = ((this._Str_7471(0.5)) ? Math.random() : -(Math.random())); _local_3.x = ((this.randomBoolean(0.5)) ? Math.random() : -(Math.random()));
_local_3.y = ((this._Str_7471(0.5)) ? Math.random() : -(Math.random())); _local_3.y = ((this.randomBoolean(0.5)) ? Math.random() : -(Math.random()));
_local_3.z = ((this._Str_7471(0.5)) ? Math.random() : -(Math.random())); _local_3.z = ((this.randomBoolean(0.5)) ? Math.random() : -(Math.random()));
break; break;
} }
@ -171,7 +171,7 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
} }
} }
private _Str_23904() private getRandomParticleConfiguration()
{ {
const k: number = Math.trunc(Math.floor((Math.random() * this._particleConfigurations.length))); const k: number = Math.trunc(Math.floor((Math.random() * this._particleConfigurations.length)));
return this._particleConfigurations[k]; return this._particleConfigurations[k];
@ -180,35 +180,35 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
public update(): void public update(): void
{ {
super.update(); super.update();
this._Str_25039(); this.accumulateForces();
this._Str_25400(); this.verlet();
this._Str_23140(); this.satisfyConstraints();
if(((!(this._Str_16034)) && (this._emittedParticles < this._maxNumberOfParticles))) if(((!(this.isAlive)) && (this._emittedParticles < this._maxNumberOfParticles)))
{ {
if((this.age % this._burstPulse) == 0) if((this.age % this._burstPulse) == 0)
{ {
this._Str_19068(this, this.direction); this.releaseParticles(this, this.direction);
} }
} }
} }
public _Str_25400(): void public verlet(): void
{ {
let _local_2:FurnitureParticleSystemParticle; let _local_2:FurnitureParticleSystemParticle;
let _local_3: number; let _local_3: number;
let _local_4: number; let _local_4: number;
let _local_5: number; let _local_5: number;
if(((this._Str_16034) || (this._emittedParticles < this._maxNumberOfParticles))) if(((this.isAlive) || (this._emittedParticles < this._maxNumberOfParticles)))
{ {
_local_3 = this.x; _local_3 = this.x;
_local_4 = this.y; _local_4 = this.y;
_local_5 = this.z; _local_5 = this.z;
this.x = (((2 - this._airFriction) * this.x) - ((1 - this._airFriction) * this._Str_10744)); this.x = (((2 - this._airFriction) * this.x) - ((1 - this._airFriction) * this.lastX));
this.y = ((((2 - this._airFriction) * this.y) - ((1 - this._airFriction) * this._Str_12459)) + ((this._gravity * this._timeStep) * this._timeStep)); this.y = ((((2 - this._airFriction) * this.y) - ((1 - this._airFriction) * this.lastY)) + ((this._gravity * this._timeStep) * this._timeStep));
this.z = (((2 - this._airFriction) * this.z) - ((1 - this._airFriction) * this._Str_11680)); this.z = (((2 - this._airFriction) * this.z) - ((1 - this._airFriction) * this.lastZ));
this._Str_10744 = _local_3; this.lastX = _local_3;
this._Str_12459 = _local_4; this.lastY = _local_4;
this._Str_11680 = _local_5; this.lastZ = _local_5;
} }
const k: FurnitureParticleSystemParticle[] = []; const k: FurnitureParticleSystemParticle[] = [];
@ -218,13 +218,13 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
_local_3 = _local_2.x; _local_3 = _local_2.x;
_local_4 = _local_2.y; _local_4 = _local_2.y;
_local_5 = _local_2.z; _local_5 = _local_2.z;
_local_2.x = (((2 - this._airFriction) * _local_2.x) - ((1 - this._airFriction) * _local_2._Str_10744)); _local_2.x = (((2 - this._airFriction) * _local_2.x) - ((1 - this._airFriction) * _local_2.lastX));
_local_2.y = ((((2 - this._airFriction) * _local_2.y) - ((1 - this._airFriction) * _local_2._Str_12459)) + ((this._gravity * this._timeStep) * this._timeStep)); _local_2.y = ((((2 - this._airFriction) * _local_2.y) - ((1 - this._airFriction) * _local_2.lastY)) + ((this._gravity * this._timeStep) * this._timeStep));
_local_2.z = (((2 - this._airFriction) * _local_2.z) - ((1 - this._airFriction) * _local_2._Str_11680)); _local_2.z = (((2 - this._airFriction) * _local_2.z) - ((1 - this._airFriction) * _local_2.lastZ));
_local_2._Str_10744 = _local_3; _local_2.lastX = _local_3;
_local_2._Str_12459 = _local_4; _local_2.lastY = _local_4;
_local_2._Str_11680 = _local_5; _local_2.lastZ = _local_5;
if(((_local_2.y > 10) || (!(_local_2._Str_16034)))) if(((_local_2.y > 10) || (!(_local_2.isAlive))))
{ {
k.push(_local_2); k.push(_local_2);
} }
@ -242,11 +242,11 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
} }
} }
private _Str_23140(): void private satisfyConstraints(): void
{ {
} }
private _Str_25039(): void private accumulateForces(): void
{ {
for(const k of this._particles) for(const k of this._particles)
{ {
@ -259,17 +259,17 @@ export class FurnitureParticleSystemEmitter extends FurnitureParticleSystemParti
return this._particles; return this._particles;
} }
public get _Str_22727(): boolean public get hasIgnited(): boolean
{ {
return this._hasIgnited; return this._hasIgnited;
} }
private _Str_7471(k: number): boolean private randomBoolean(k: number): boolean
{ {
return Math.random() < k; return Math.random() < k;
} }
public get _Str_9107(): number public get roomObjectSpriteId(): number
{ {
return this._roomObjectSpriteId; return this._roomObjectSpriteId;
} }

View File

@ -102,7 +102,7 @@ export class FurnitureParticleSystemParticle
return this._isEmitter; return this._isEmitter;
} }
public get _Str_16034(): boolean public get isAlive(): boolean
{ {
return this._age <= this._lifeTime; return this._age <= this._lifeTime;
} }
@ -137,40 +137,40 @@ export class FurnitureParticleSystemParticle
this._z = k; this._z = k;
} }
public get _Str_10744(): number public get lastX(): number
{ {
return this._lastX; return this._lastX;
} }
public set _Str_10744(k: number) public set lastX(k: number)
{ {
this._hasMoved = true; this._hasMoved = true;
this._lastX = k; this._lastX = k;
} }
public get _Str_12459(): number public get lastY(): number
{ {
return this._lastY; return this._lastY;
} }
public set _Str_12459(k: number) public set lastY(k: number)
{ {
this._hasMoved = true; this._hasMoved = true;
this._lastY = k; this._lastY = k;
} }
public get _Str_11680(): number public get lastZ(): number
{ {
return this._lastZ; return this._lastZ;
} }
public set _Str_11680(k: number) public set lastZ(k: number)
{ {
this._hasMoved = true; this._hasMoved = true;
this._lastZ = k; this._lastZ = k;
} }
public get _Str_22611(): boolean public get hasMoved(): boolean
{ {
return this._hasMoved; return this._hasMoved;
} }
@ -188,7 +188,7 @@ export class FurnitureParticleSystemParticle
this._lastX = (k._lastX * _arg_2); this._lastX = (k._lastX * _arg_2);
this._lastY = (k._lastY * _arg_2); this._lastY = (k._lastY * _arg_2);
this._lastZ = (k._lastZ * _arg_2); this._lastZ = (k._lastZ * _arg_2);
this._hasMoved = k._Str_22611; this._hasMoved = k.hasMoved;
this._direction = k._direction; this._direction = k._direction;
this._age = k._age; this._age = k._age;
this._lifeTime = k._lifeTime; this._lifeTime = k._lifeTime;

View File

@ -512,7 +512,7 @@ export class RoomPlane implements IRoomPlane
//const data = new PlaneDrawingData(maskData, blend(this._color, layer.getColor()), cm._Str_14945()); //const data = new PlaneDrawingData(maskData, blend(this._color, layer.getColor()), cm._Str_14945());
const data = new PlaneDrawingData(maskData, this._color, cm._Str_14945()); const data = new PlaneDrawingData(maskData, this._color, cm._Str_14945());
Randomizer._Str_17384(this._randomSeed); Randomizer.setSeed(this._randomSeed);
for(const column of cm._Str_23721(this.screenWidth(geometry))) for(const column of cm._Str_23721(this.screenWidth(geometry)))
{ {
@ -664,7 +664,7 @@ export class RoomPlane implements IRoomPlane
//this._bitmapData.fillRect(this._bitmapData.rect, 0xFFFFFF); //this._bitmapData.fillRect(this._bitmapData.rect, 0xFFFFFF);
} }
Randomizer._Str_17384(this._randomSeed); Randomizer.setSeed(this._randomSeed);
const texture = this.getTexture(geometry, timeSinceStartMs); const texture = this.getTexture(geometry, timeSinceStartMs);

View File

@ -16,7 +16,7 @@ export class LandscapePlane extends Plane
{ {
const _local_2 = this.getPlaneVisualization(k); const _local_2 = this.getPlaneVisualization(k);
if(_local_2) return !(_local_2._Str_20530); if(_local_2) return !(_local_2.hasAnimationLayers);
return super.isStatic(k); return super.isStatic(k);
} }

View File

@ -75,7 +75,7 @@ export class LandscapeRasterizer extends PlaneRasterizer
if(planeVisualization) if(planeVisualization)
{ {
Randomizer._Str_17384(randomNumber); Randomizer.setSeed(randomNumber);
let layerId = 0; let layerId = 0;
@ -108,7 +108,7 @@ export class LandscapeRasterizer extends PlaneRasterizer
else if(layer.align === 'top') align = PlaneVisualizationLayer.ALIGN_TOP; else if(layer.align === 'top') align = PlaneVisualizationLayer.ALIGN_TOP;
} }
planeVisualization._Str_21464(layerId, material, color, align, offset); planeVisualization.setLayer(layerId, material, color, align, offset);
} }
layerId++; layerId++;
@ -157,7 +157,7 @@ export class LandscapeRasterizer extends PlaneRasterizer
layerId++; layerId++;
} }
planeVisualization._Str_23489(layerId, animationItems, this.assetCollection); planeVisualization.setAnimationLayer(layerId, animationItems, this.assetCollection);
} }
} }
} }
@ -183,7 +183,7 @@ export class LandscapeRasterizer extends PlaneRasterizer
if((_arg_2.length > 0)) if((_arg_2.length > 0))
{ {
const _local_4 = 10000; const _local_4 = 10000;
const _local_5 = Randomizer._Str_1612(1, 0, _local_4); const _local_5 = Randomizer.getValues(1, 0, _local_4);
const _local_6 = (_local_5[0] / _local_4); const _local_6 = (_local_5[0] / _local_4);
if(_arg_2.charAt((_arg_2.length - 1)) === '%') if(_arg_2.charAt((_arg_2.length - 1)) === '%')

View File

@ -175,7 +175,7 @@ export class PlaneMaterialCell
// const limitMin = Math.min(this._extraItemCount, this._extraItemOffsets.length); // const limitMin = Math.min(this._extraItemCount, this._extraItemOffsets.length);
// const limitMax = Math.max(this._extraItemCount, this._extraItemOffsets.length); // const limitMax = Math.max(this._extraItemCount, this._extraItemOffsets.length);
// const offsetIndexes = Randomizer._Str_23572(this._extraItemCount, limitMax); // const offsetIndexes = Randomizer.getArray(this._extraItemCount, limitMax);
// let i = 0; // let i = 0;

View File

@ -62,7 +62,7 @@ export class PlaneMaterialCellMatrix
private static _Str_12526(k: number): number private static _Str_12526(k: number): number
{ {
return ((Randomizer._Str_1612(1, 0, (k * 17631))[0]) % k); return ((Randomizer.getValues(1, 0, (k * 17631))[0]) % k);
} }
public get normalMinX(): number public get normalMinX(): number

View File

@ -578,7 +578,7 @@ export class PlaneRasterizer implements IPlaneRasterizer
else if(layer.align == 'top') align = PlaneVisualizationLayer.ALIGN_TOP; else if(layer.align == 'top') align = PlaneVisualizationLayer.ALIGN_TOP;
} }
planeVisualization._Str_21464(layerId, material, color, align, offset); planeVisualization.setLayer(layerId, material, color, align, offset);
} }
layerId++; layerId++;

View File

@ -44,7 +44,7 @@ export class PlaneVisualization
return this._geometry; return this._geometry;
} }
public get _Str_20530(): boolean public get hasAnimationLayers(): boolean
{ {
return this._hasAnimationLayers; return this._hasAnimationLayers;
} }
@ -106,7 +106,7 @@ export class PlaneVisualization
this._isCached = false; this._isCached = false;
} }
public _Str_21464(k: number, _arg_2: PlaneMaterial, _arg_3: number, _arg_4: number, _arg_5: number = 0): boolean public setLayer(k: number, _arg_2: PlaneMaterial, _arg_3: number, _arg_4: number, _arg_5: number = 0): boolean
{ {
if((k < 0) || (k > this._layers.length)) return false; if((k < 0) || (k > this._layers.length)) return false;
@ -121,7 +121,7 @@ export class PlaneVisualization
return true; return true;
} }
public _Str_23489(k: number, _arg_2: any, _arg_3: IGraphicAssetCollection): boolean public setAnimationLayer(k: number, _arg_2: any, _arg_3: IGraphicAssetCollection): boolean
{ {
if((k < 0) || (k > this._layers.length)) return false; if((k < 0) || (k > this._layers.length)) return false;
@ -154,7 +154,7 @@ export class PlaneVisualization
{ {
if(((this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height)) && (Vector3d.isEqual(this._cachedBitmapNormal, normal))) if(((this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height)) && (Vector3d.isEqual(this._cachedBitmapNormal, normal)))
{ {
if(!this._Str_20530) if(!this.hasAnimationLayers)
{ {
if(canvas) if(canvas)
{ {

View File

@ -1,60 +1,60 @@
export class Randomizer export class Randomizer
{ {
public static _Str_21045: number = 1; public static DEFAULT_SEED: number = 1;
public static _Str_20078: number = 16777216; public static DEFAULT_MODULUS: number = 16777216;
private static _Str_3699:Randomizer = null; private static _randomizer:Randomizer = null;
private _Str_16737: number = 1; private _seed: number = 1;
private _Str_16979: number = 16777216; private _modulus: number = 16777216;
private _Str_25697: number = 69069; private _multiplier: number = 69069;
private _Str_23320: number = 5; private _increment: number = 5;
public static _Str_17384(k: number = 1): void public static setSeed(k: number = 1): void
{ {
if(!Randomizer._Str_3699) Randomizer._Str_3699 = new Randomizer(); if(!Randomizer._randomizer) Randomizer._randomizer = new Randomizer();
Randomizer._Str_3699._Str_15634 = k; Randomizer._randomizer.seed = k;
} }
public static _Str_26085(k: number = 16777216): void public static setModulus(k: number = 16777216): void
{ {
if(!Randomizer._Str_3699) Randomizer._Str_3699 = new Randomizer(); if(!Randomizer._randomizer) Randomizer._randomizer = new Randomizer();
Randomizer._Str_3699._Str_25321 = k; Randomizer._randomizer.modulus = k;
} }
public static _Str_1612(k: number, _arg_2: number, _arg_3: number): number[] public static getValues(k: number, _arg_2: number, _arg_3: number): number[]
{ {
if(!Randomizer._Str_3699) Randomizer._Str_3699 = new Randomizer(); if(!Randomizer._randomizer) Randomizer._randomizer = new Randomizer();
return Randomizer._Str_3699._Str_24535(k, _arg_2, _arg_3); return Randomizer._randomizer.getRandomValues(k, _arg_2, _arg_3);
} }
public static _Str_23572(k: number, _arg_2: number): number[] public static getArray(k: number, _arg_2: number): number[]
{ {
if(!Randomizer._Str_3699) Randomizer._Str_3699 = new Randomizer(); if(!Randomizer._randomizer) Randomizer._randomizer = new Randomizer();
return Randomizer._Str_3699._Str_24231(k, _arg_2); return Randomizer._randomizer.getRandomArray(k, _arg_2);
} }
public set _Str_15634(k: number) public set seed(k: number)
{ {
this._Str_16737 = k; this._seed = k;
} }
public set _Str_25321(k: number) public set modulus(k: number)
{ {
if(k < 1) k = 1; if(k < 1) k = 1;
this._Str_16979 = k; this._modulus = k;
} }
public dispose(): void public dispose(): void
{ {
} }
public _Str_24535(k: number, _arg_2: number, _arg_3: number): number[] public getRandomValues(k: number, _arg_2: number, _arg_3: number): number[]
{ {
const _local_4: number[] = []; const _local_4: number[] = [];
@ -62,14 +62,14 @@
while(_local_5 < k) while(_local_5 < k)
{ {
_local_4.push(this._Str_19361(_arg_2, (_arg_3 - _arg_2))); _local_4.push(this.iterateScaled(_arg_2, (_arg_3 - _arg_2)));
_local_5++; _local_5++;
} }
return _local_4; return _local_4;
} }
public _Str_24231(k: number, _arg_2: number): number[] public getRandomArray(k: number, _arg_2: number): number[]
{ {
if(((k > _arg_2) || (_arg_2 > 1000))) return null; if(((k > _arg_2) || (_arg_2 > 1000))) return null;
@ -89,7 +89,7 @@
while(_local_6 < k) while(_local_6 < k)
{ {
const _local_7 = this._Str_19361(0, (_local_3.length - 1)); const _local_7 = this.iterateScaled(0, (_local_3.length - 1));
_local_5.push(_local_3[_local_7]); _local_5.push(_local_3[_local_7]);
_local_3.splice(_local_7, 1); _local_3.splice(_local_7, 1);
@ -100,26 +100,26 @@
return _local_5; return _local_5;
} }
private _Str_24980(): number private iterate(): number
{ {
let k: number = ((this._Str_25697 * this._Str_16737) + this._Str_23320); let k: number = ((this._multiplier * this._seed) + this._increment);
if(k < 0) k = -(k); if(k < 0) k = -(k);
k = (k % this._Str_16979); k = (k % this._modulus);
this._Str_16737 = k; this._seed = k;
return k; return k;
} }
private _Str_19361(k: number, _arg_2: number): number private iterateScaled(k: number, _arg_2: number): number
{ {
let _local_3: number = this._Str_24980(); let _local_3: number = this.iterate();
if(_arg_2 < 1) return k; if(_arg_2 < 1) return k;
_local_3 = (k + ((_local_3 / this._Str_16979) * _arg_2)); _local_3 = (k + ((_local_3 / this._modulus) * _arg_2));
return _local_3; return _local_3;
} }