Ejemplo n.º 1
0
        protected IEnumerator Update_Routine()
        {
            while (true)
            {
                float waitTime = _updateRate.val / 1000;
                if (waitTime > 0.0f)
                {
                    yield return(new WaitForSecondsRealtime(waitTime));
                }
                else
                {
                    yield return(new WaitForFixedUpdate());

                    waitTime = Time.fixedUnscaledDeltaTime;
                }

                try
                {
                    foreach (var randomizer in _randomizerEnabledList)
                    {
                        randomizer.Update(waitTime);
                    }

                    if (null != _displayRandomizer._syncTarget && _displayPopup.isActiveAndEnabled)
                    {
                        ParamRandomizer.CopyValues(_displayRandomizer, _displayRandomizer._syncTarget);
                    }
                }
                catch (Exception e)
                {
                    SuperController.LogError(e.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        // receiver JSONStorable
        protected void SyncReceiver(string receiverID)
        {
            List <string> targetChoices = new List <string>();

            foreach (ParamRandomizer randomizer in _randomizerList)
            {
                DeregisterRandomizer(randomizer);
            }

            Dictionary <string, ParamRandomizer> oldDict = null;

            // If this is just refreshing the list we need to save existing randomizers
            string defaultTarget;

            if (_skipUpdateVal)
            {
                oldDict         = _randomizerDict;
                _randomizerDict = new Dictionary <string, ParamRandomizer>();
                defaultTarget   = _targetJson.val;
            }
            else
            {
                // Otherwise if the receiver changed then clear the enabled list
                _randomizerEnabledList.Clear();
            }
            _randomizerDict.Clear();
            _randomizerList.Clear();

            if (_atom != null && receiverID != null)
            {
                if (!_skipUpdateVal)
                {
                    _receiver = _atom.GetStorableByID(receiverID);
                }
                if (_receiver != null)
                {
                    foreach (string paramName in _receiver.GetFloatParamNames())
                    {
                        ParamRandomizer randomizer;
                        // Use the old randomizer if it exists, otherwise make a new one
                        if (!(oldDict != null && oldDict.TryGetValue(paramName, out randomizer)))
                        {
                            randomizer = new ParamRandomizer(paramName, _receiver.GetFloatJSONParam(paramName));
                        }
                        RegisterRandomizer(randomizer);
                        _randomizerList.Add(randomizer);
                        _randomizerDict[paramName] = randomizer;
                        targetChoices.Add(paramName);
                    }
                }
                else
                {
                    // some storables can be late loaded, like skin, clothing, hair, etc so must keep track of missing receiver
                    //SuperController.LogMessage("Missing receiver: " + receiverID);
                    SetWaitForMissingReceiver(receiverID);
                }
            }
            else
            {
                _receiver = null;
            }

            _targetJson.choices = targetChoices;
            if (!_skipUpdateVal || !targetChoices.Contains(_receiverJSON.val))
            {
                if (targetChoices.Count > 0)
                {
                    _targetJson.val = targetChoices[0];
                }
                // Clear the display
                ParamRandomizer.CopyValues(_displayRandomizer, new ParamRandomizer("display", null));
            }
            UpdateEnabledList();
        }