public async Task <ScaleformRenderer> AcquireScaleformRenderer(
            Screen.PositionSettings positionalSettings,
            string txdName,
            string txnName)
        {
            if (this.usageCount >= this.maxActiveScaleforms)
            {
                Logger.Error($"scaleformRenderers exceeded max usage limit of {this.maxActiveScaleforms}");
                return(null);
            }

            ScaleformRenderer renderer;

            try
            {
                renderer = this.scaleformRenderers.Pop();

                renderer.UnsetTexture();
                renderer.SetTexture(txdName, txnName);

                renderer.SetPosition(positionalSettings);
            }
            catch (Exception)
            {
                // no scaleformRenderer in stack. create one
                renderer = await this.CreateScaleformRenderer(positionalSettings, txdName, txnName);
            }

            this.usageCount += 1;

            return(renderer);
        }
Ejemplo n.º 2
0
 public void SetPosition(Screen.PositionSettings positionalSettings)
 {
     this.Position = new Vector3(
         positionalSettings.PositionX,
         positionalSettings.PositionY,
         positionalSettings.PositionZ);
     this.Rotation = new Vector3(
         positionalSettings.RotationX,
         positionalSettings.RotationY,
         positionalSettings.RotationZ);
     this.Scale = new Vector3(positionalSettings.ScaleX, positionalSettings.ScaleY, positionalSettings.ScaleZ);
 }
Ejemplo n.º 3
0
        public ScaleformRenderer(
            Scaleform scaleform,
            Screen.PositionSettings positionalSettings,
            string txdName,
            string txnName)
        {
            this.scaleform = scaleform;

            this.SetPosition(positionalSettings);

            this.SetTexture(txdName, txnName);
        }
        private async Task <ScaleformRenderer> CreateScaleformRenderer(
            Screen.PositionSettings positionalSettings,
            string txdName,
            string txnName)
        {
            var scaleformId = $"hypnonema_texture_renderer{this.usageCount + 1:D2}";
            var scaleform   = await this.LoadScaleform(scaleformId, 3000);

            if (scaleform != null)
            {
                return(new ScaleformRenderer(scaleform, positionalSettings, txdName, txnName));
            }

            Logger.Error($"Failed to load scaleform. Timeout exceeded. Scaleform-ID: \"{scaleformId}\"");
            return(null);
        }