var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var Random = (function () {
    function Random(seed, texture) {
        if (seed === void 0) { seed = 0; }
        this.mPointer = 0;
        this.mSeed = 0;
        this.mSeed = seed;
        this.mTexture = texture;
    }
    Object.defineProperty(Random.prototype, "seed", {
        get: function () {
            return this.mSeed;
        },
        set: function (value) {
            if (value != this.mSeed) {
                this.mIsSeedValid = false;
                this.mPointer = 0;
            }
            this.mSeed = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Random.prototype, "pointer", {
        get: function () {
            return this.mPointer;
        },
        set: function (value) {
            this.mPointer = value;
        },
        enumerable: true,
        configurable: true
    });
    Random.prototype.Float = function (min, max) {
        if (max === void 0) { max = NaN; }
        if (isNaN(max)) {
            max = min;
            min = 0;
        }
        return this.Next() * (max - min) + min;
    };
    Random.prototype.Int = function (min, max) {
        if (max === void 0) { max = NaN; }
        if (isNaN(max)) {
            max = min;
            min = 0;
        }
        return Math.floor(this.Float(min, max));
    };
    Random.prototype.Sign = function (chance) {
        if (chance === void 0) { chance = 0.5; }
        return this.Next() < chance ? 1 : -1;
    };
    Random.prototype.Reset = function () {
        this.mPointer = 0;
    };
    Random.prototype.Bool = function (chance) {
        if (chance === void 0) { chance = 0.5; }
        return this.Next() < chance;
    };
    Random.prototype.Bit = function (chance, shift) {
        if (chance === void 0) { chance = 0.5; }
        if (shift === void 0) { shift = 0; }
        return this.Next() < chance ? (1 << shift) : 0;
    };
    Random.prototype.Next = function () {
        if (this.mIsSeedValid == false) {
            this.mIsSeedValid = true;
        }
        this.mPointer = (this.mPointer + this.mSeed + 1) % 200000;
        var realX = this.mPointer % 1000;
        var realY = (this.mPointer / 1000) >> 0;
        var colors = this.mTexture.getPixels(realX, realY, 1, 1);
        var realC = 0x1 * colors[0] + 0x100 * colors[1] + 0x10000 * colors[2] + 0x1000000 * colors[3];
        // return (realC * 0.999999999999998 + 1E-15) / 16777215;//4294967295;
        return (realC) / 4294967295;
    };
    return Random;
}());
__reflect(Random.prototype, "Random");
//# sourceMappingURL=Random.js.map