private void CheckType()
 {
     if (s != null)
     {
         a_s = GetComponentInParent <AssembledSource>();
     }
 }
Beispiel #2
0
        private void Update()
        {
            if (_paused)
            {
                return;
            }
            if (_receivedNewSource)
            {
                _receivedNewSource = false;
                try
                {
                    AssembledSource outputSource      = (AssembledSource)_newSource;
                    Base            b1                = (Base)outputSource.Source1;
                    Base            b2                = (Base)outputSource.Source2;
                    bool            qualityCondition  = b1.X + b2.X <= 100;
                    Module          destinationModule = qualityCondition ? _outputForGoodQuality : _outputForBadQuality;
#if DEBUG_PRINT
                    string s = !qualityCondition ? " NOT" : "";
                    Debug.Log("[" + name + "] The source " + outputSource.name + " did" + s + " satisfy our quality standards. Sending it to " + destinationModule.name);
#endif
                    SendSourceOut(outputSource, this, destinationModule);
                    DataChanged(GetStats());
                    _newSource = null;
                }
                catch (InvalidCastException exc)
                {
                    Debug.LogError("[" + name + "] " + exc + " // Cannot check quality of this Source.");
                }
            }
        }
        void Update()
        {
            if (_paused)
            {
                return;
            }

            // when there is at least 1 element for each queue, take some _productionTime
            // and then a new AssembledSource is released
            if (_firstInputSourcesQueue.Count > 0 && _secondInputSourcesQueue.Count > 0)
            {
                if (!_isAssembling)
                {
                    _isAssembling = true;
                    _lastProductionStartedTime = Time.time;
                }
                if (_isAssembling && (Time.time - _lastProductionStartedTime) >= _productionTime)
                {
                    _isAssembling = false;
                    Source          source1         = _firstInputSourcesQueue.Dequeue();
                    Source          source2         = _secondInputSourcesQueue.Dequeue();
                    AssembledSource assembledSource = Instantiate(Resources.Load <AssembledSource>("Prefabs/AssembledSources"));
                    assembledSource.Initialize(source1, source2, ComputeAssembledSourceType(), transform);
                    SendSourceOut(assembledSource, this, OutputModules[0]);
                    source1.Assembled();
                    source2.Assembled();
                    DataChanged(GetStats());
                }
            }
        }