How to use the @casual-simulation/aux-common.hasValue function in @casual-simulation/aux-common

To help you get started, we’ve selected a few @casual-simulation/aux-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / aux-vm-node / managers / AuxUserAuthenticator.ts View on Github external
this._userUpdated.next(newUser.username);
                } else {
                    this._userUpdated.next(user.username);
                    this._userUpdated.next(newUser.username);
                }
            } else {
                // Remove user
                this._userTokens.delete(user.username);
                this._users.delete(user.username);
                this._botAccountMap.delete(bot.id);

                this._userUpdated.next(user.username);
            }
        } else {
            // We might have a new user
            if (hasValue(bot.tags['aux.account.username'])) {
                // We have a new user
                const newUser = this._calculateUserAccountInfo(context, bot);
                this._botAccountMap.set(bot.id, newUser);
                this._users.set(newUser.username, newUser);

                this._userUpdated.next(newUser.username);
            } else {
                // Do nothing
            }
        }
    }
github casual-simulation / aux / src / aux-vm-node / managers / AuxUserAuthenticator.ts View on Github external
private _updateTokenInfo(context: BotCalculationContext, bot: Bot) {
        const token = this._botTokenMap.get(bot.id);
        if (token) {
            // We had a token

            if (hasValue(bot.tags['aux.token.username'])) {
                let oldUserTokens = this._getTokensForUsername(token.username);

                // Update token
                this._tokens.delete(token.token);
                oldUserTokens.delete(token.token);

                const newToken = this._calculateUserTokenInfo(context, bot);
                let newUserTokens = this._getTokensForUsername(
                    newToken.username
                );

                newUserTokens.add(newToken.token);
                this._botTokenMap.set(bot.id, newToken);
                this._tokens.set(newToken.token, newToken);

                if (newToken.username === token.username) {
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / AuxBot3DDecoratorFactory.ts View on Github external
loadDecorators(bot3d: AuxBot3D): AuxBot3DDecorator[] {
        let decorators: AuxBot3DDecorator[] = [];
        const isUser = !!bot3d.bot && hasValue(bot3d.bot.tags['_auxUser']);
        const isLocalUser = isUser && bot3d.bot.id === appManager.user.id;

        if (isUser) {
            if (isLocalUser) {
                // Local user gets controls for changing their user position in contexts.
                decorators.push(new UserControlsDecorator(bot3d, this.game));
            } else {
                // Remote user gets mesh to visualize where it is in contexts.
                decorators.push(new UserMeshDecorator(bot3d));
            }
        } else {
            let botShapeDecorator = new BotShapeDecorator(bot3d);
            let textureDecorator = new TextureDecorator(
                bot3d,
                botShapeDecorator
            );
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / IFramePlaneDecorator.ts View on Github external
if (hasValue(iframeValue) && isValidURL(iframeValue)) {
            if (this.url !== iframeValue) {
                this.url = iframeValue;
                iframeValueChanged = true;
            }
        } else {
            if (this.url !== null && this.url !== undefined) {
                this.url = null;
                iframeValueChanged = true;
            }
        }

        let allowSizeChangeThisUpdate = true;
        if (iframeValueChanged) {
            if (hasValue(this.url)) {
                if (!this.mixerPlane) {
                    // Create the mixer plane.
                    this.mixerPlane = this._createMixerPlane();
                    allowSizeChangeThisUpdate = false; // Don't need to update element or plane size since our current values are accurate here.
                }

                HtmlMixerHelpers.setIframeSrc(this.mixerPlane, this.url);
            } else {
                // Remove the mixer plane.
                this._destroyMixerPlane();
            }
        }

        if (allowSizeChangeThisUpdate && this.mixerPlane) {
            if (iframeElementWidthValueChanged || iframeSizeValueChanged) {
                // Recreate the mixer plane if element width or plane size changes ONLY if the mixer plane already exists and wasnt created this frame.
github casual-simulation / aux / src / aux-vm / managers / DependencyManager.ts View on Github external
return {};
        }

        this._botIdMap.set(update.bot.id, update.bot);
        const tags = this._botMap.get(update.bot.id);
        if (tags) {
            // ID never updates so we don't need to include it.
            const botTags = tagsOnBot(update.bot);
            tags.splice(0, tags.length, ...botTags);

            const dependencies = this.getDependencies(update.bot.id);

            for (let tag of update.tags) {
                const bots = this._tagMap.get(tag);
                const val = update.bot.tags[tag];
                if (hasValue(val)) {
                    if (isFormula(val)) {
                        let formulaDependencies = this._dependencies.calculateAuxDependencies(
                            val
                        );

                        if (dependencies[tag]) {
                            this._removeTagDependents(
                                dependencies,
                                tag,
                                update.bot.id
                            );
                        }

                        dependencies[tag] = formulaDependencies;
                        this._addTagDependents(
                            formulaDependencies,
github casual-simulation / aux / src / aux-server / aux-web / aux-projector / BotValue / BotValue.ts View on Github external
setInitialValue(value: string) {
        if (!hasValue(this.value)) {
            this.value = value;
            this.$emit('tagChanged', this.bot, this.tag, value);
            this.getBotManager().editBot(this.bot, this.tag, value);
        }
    }
github casual-simulation / aux / src / aux-server / aux-web / aux-player / scene / PlayerSimulation3D.ts View on Github external
private async _updateUserBot(calc: BotCalculationContext, bot: Bot) {
        const userBot = this.simulation.helper.userBot;
        console.log(
            "[PlayerSimulation3D] Setting user's context to: " + this.context
        );
        let userBackgroundColor = calculateBotValue(
            calc,
            bot,
            `aux.context.color`
        );
        this._userInventoryColor = hasValue(userBackgroundColor)
            ? new Color(userBackgroundColor)
            : undefined;
        await this.simulation.helper.updateBot(userBot, {
            tags: { 'aux._userContext': this.context },
        });
        await this.simulation.helper.updateBot(userBot, {
            tags: { 'aux._userChannel': this.simulation.id },
        });
        this._subs.push(
            this.simulation.watcher
                .botChanged(bot.id)
                .pipe(
                    tap(update => {
                        const bot = update;
                        let userBackgroundColor = calculateBotValue(
                            calc,
github casual-simulation / aux / src / aux-server / aux-web / aux-player / Checkout / Checkout.ts View on Github external
.subscribe(connected => {
                    const key = getStripeKey(sim);
                    const hasKey = hasValue(key);
                    if (hasKey) {
                        loadStripe();
                    }
                }),
            sim.localEvents.subscribe(e => {