Esempio n. 1
0
        private double processMaterials(InstrumentResource resource)
        {
            double result = 1.0;

            foreach (MaterialResource material in resource.materials)
            {
                result += processSingleMaterial(material);
            }
            return(result == 1.0 ? result : result - 1.0);
        }
Esempio n. 2
0
        private double processSingleInstrument(InstrumentResource instrument)
        {
            double result       = 1.0;
            bool   isUsedByThis = instrument.users.Contains(this.id);

            if (instrument.users.Count == 0)
            {
                instrument.isBusy = false;
            }

            if (instrument.isBusy && !instrument.isShared && !isUsedByThis)
            {
                return(Double.Epsilon);
            }

            if (instrument.isBusy && instrument.isShared || instrument.isBusy && isUsedByThis)
            {
                if (!instrument.users.Contains(this.id))
                {
                    instrument.users.Add(this.id);
                }

                result += processMaterials(instrument) * instrument.power * instrument.count / (instrument.users.Count > 0 ? instrument.users.Count : 1);
            }

            if (!instrument.isBusy)
            {
                result += processMaterials(instrument) * instrument.power * instrument.count;
                if (!instrument.users.Contains(this.id))
                {
                    instrument.users.Add(this.id);
                    instrument.isBusy = true;
                }
            }
            return(result == 1.0 ? result : result - 1.0);
        }