Beispiel #1
0
        protected override void SpawnMachineAsInstalled()
        {
            base.SpawnMachineAsInstalled();

            chargePressure = CHARGED_PRESSURE;
            binState       = BinState.Ready;
            OnSyncBinState(binState);
        }
Beispiel #2
0
        void OnSyncBinState(BinState oldState, BinState newState)
        {
            binState = newState;

            if (BinCharging)
            {
                rechargeSFX.Play();
            }
            else
            {
                rechargeSFX.Stop();
            }
        }
Beispiel #3
0
        private void OnSyncBinState(BinState oldState, BinState newState)
        {
            binState = newState;

            if (BinCharging)
            {
                runLoopGUID = Guid.NewGuid().ToString();
                SoundManager.PlayAtPositionAttached(rechargeSFX, registerObject.WorldPosition, gameObject, runLoopGUID);
            }
            else
            {
                SoundManager.Stop(runLoopGUID);
            }
        }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        state = BinState.Sealed;
        isUpright = true;
        //hasMiner = false;
        timePryLid = new TimeSpan(2 * Timer.tickSize);
        timeDigTrashOut = new TimeSpan(2 * Timer.tickSize);
        garbages = new List<GarbagePiece>();

        foreach (Transform gChild in garbagesGO.transform)
        {
            garbages.Add(gChild.transform.GetComponent<GarbagePiece>());
        }
    }
Beispiel #5
0
        IEnumerator Recharge()
        {
            while (BinCharging && !BinCharged)
            {
                yield return(WaitFor.Seconds(1));

                chargePressure += 20;
            }

            if (!PowerOff && !PowerDisconnected)
            {
                binState = BinState.Ready;
                OnSyncBinState(binState);
                this.RestartCoroutine(AutoFlush(), ref autoFlushCoroutine);
            }

            // Sound of the bin's air intake flap closing.
            SoundManager.PlayNetworkedAtPos("Click", registerObject.WorldPositionServer, sourceObj: gameObject);
        }
Beispiel #6
0
        void TurnPowerOff()
        {
            // Cannot disable power while flushing
            if (BinFlushing)
            {
                return;
            }

            if (autoFlushCoroutine != null)
            {
                StopCoroutine(autoFlushCoroutine);
            }
            if (rechargeCoroutine != null)
            {
                StopCoroutine(rechargeCoroutine);
            }
            binState = BinState.Off;
            OnSyncBinState(binState);
        }
Beispiel #7
0
        IEnumerator RunFlushSequence()
        {
            // Bin orifice closes...
            binState = BinState.Flushing;
            OnSyncBinState(binState);
            yield return(WaitFor.Seconds(ANIMATION_TIME));

            // Bin orifice closed. Release the charge.
            chargePressure = 0;
            SoundManager.PlayNetworkedAtPos("DisposalMachineFlush", registerObject.WorldPositionServer, sourceObj: gameObject);
            if (virtualContainer != null)
            {
                virtualContainer.GetComponent <ObjectBehaviour>().parentContainer = null;
                DisposalsManager.Instance.NewDisposal(virtualContainer);
                virtualContainer = null;
            }

            // Restore charge.
            binState = BinState.Recharging;
            OnSyncBinState(binState);
            StartCoroutine(Recharge());
        }
Beispiel #8
0
        void TurnPowerOn()
        {
            // Cannot turn the pump on if power is not connected.
            if (PowerDisconnected)
            {
                return;
            }

            if (BinCharged)
            {
                binState = BinState.Ready;
                OnSyncBinState(binState);
                if (ServerHasContents)
                {
                    this.RestartCoroutine(AutoFlush(), ref autoFlushCoroutine);
                }
            }
            else
            {
                binState = BinState.Recharging;
                OnSyncBinState(binState);
                this.RestartCoroutine(Recharge(), ref rechargeCoroutine);
            }
        }
Beispiel #9
0
 private void SetBinState(BinState newState)
 {
     binState = newState;
     UpdateSpriteBinState();
 }
Beispiel #10
0
    // Update is called once per frame
    void Update()
    {
        if ( state == BinState.Sealed && timeCounter != null && timeCounter.time >= timePryLid)
        {
            lid.SetActive(false);
            state = BinState.Open;

            //reset & reuse same timer.. blah whatever
            timeCounter = new Timer();
        }

        else if ( state == BinState.Open && timeCounter.time >= timeDigTrashOut && garbages.Count > 0) //garbagesGO.transform.childCount
        {
            TakeGarbageOut();

            //reset & reuse same timer.. blah whatever
            timeCounter = new Timer();
        }
    }
Beispiel #11
0
        /// <summary>
        /// Populate the list of GenomicBin objects for this chromosome.
        /// </summary>
        static void BinCountsForChromosome(BinTaskArguments arguments)
        {
            List <GenomicBin> bins = arguments.Bins;
            bool               usePredefinedBins  = bins.Any();
            int                predefinedBinIndex = 0;
            GenericRead        fastaEntry         = arguments.FastaEntry; //fastaEntryKVP.Value;
            BinState           currentBin         = new BinState();
            string             chr = arguments.Chromosome;
            BitArray           possibleAlignments = arguments.PossibleAlignments;
            HitArray           observedAlignments = arguments.ObservedAlignments;
            CanvasCoverageMode coverageMode       = arguments.CoverageMode;
            int                pos = usePredefinedBins ? bins[predefinedBinIndex].Start : 0;

            // Skip past leading Ns
            while (fastaEntry.Bases[pos].Equals('n'))
            {
                pos++;
            }
            List <float> binPositions    = new List <float>();
            List <int>   binObservations = new List <int>();

            for (; pos < fastaEntry.Bases.Length; pos++)
            {
                // Sets the start of the bin
                if (currentBin.StartPosition == -1)
                {
                    currentBin.StartPosition = pos;
                }

                if (!fastaEntry.Bases[pos].Equals("n"))
                {
                    currentBin.NucleotideCount++;
                }


                //if (Utilities.IsGC(fastaEntry.Bases[pos]))
                //    currentBin.GCCount++;
                switch (fastaEntry.Bases[pos])
                {
                case 'C':
                case 'c':
                case 'G':
                case 'g':
                    currentBin.GCCount++;
                    break;
                }

                if (possibleAlignments[pos])
                {
                    currentBin.PossibleCount++;
                    currentBin.ObservedCount += observedAlignments.Data[pos];
                    binObservations.Add(observedAlignments.Data[pos]);
                    if (coverageMode == CanvasCoverageMode.GCContentWeighted)
                    {
                        binPositions.Add(arguments.ObservedVsExpectedGC[arguments.ReadGCContent[pos]]);
                    }
                }

                // We've seen the desired number of possible alignment positions.
                if ((!usePredefinedBins && currentBin.PossibleCount == arguments.BinSize) ||
                    (usePredefinedBins && pos == bins[predefinedBinIndex].Stop - 1))
                {
                    if (coverageMode == CanvasCoverageMode.TruncatedDynamicRange) // Truncated dynamic range
                    {
                        currentBin.ObservedCount = 0;
                        foreach (int Value in binObservations)
                        {
                            currentBin.ObservedCount += Math.Min(10, Value);
                        }
                    }
                    if (coverageMode == CanvasCoverageMode.GCContentWeighted) // read GC content weighted
                    {
                        currentBin.ObservedCount = 0;
                        float tmpObservedCount = 0;
                        for (int i = 0; i < binObservations.Count; i++)
                        {
                            tmpObservedCount += Math.Min(10, (float)binObservations[i] / binPositions[i]);
                        }
                        currentBin.ObservedCount = (int)Math.Round(tmpObservedCount);
                    }

                    int gc = (int)(100 * currentBin.GCCount / currentBin.NucleotideCount);

                    if (usePredefinedBins)
                    {
                        bins[predefinedBinIndex].GC    = gc;
                        bins[predefinedBinIndex].Count = currentBin.ObservedCount;
                        predefinedBinIndex++;
                        if (predefinedBinIndex >= bins.Count)
                        {
                            break;
                        }                                         // we have processed all the bins
                        pos = bins[predefinedBinIndex].Start - 1; // jump to right before the next predefined bin
                    }
                    else
                    {
                        // Note the pos + 1 to make the first three conform to bed specification
                        GenomicBin bin = new GenomicBin(chr, currentBin.StartPosition, pos + 1, gc, currentBin.ObservedCount);
                        bins.Add(bin);
                    }

                    // Reset all relevant variables
                    currentBin.Reset();
                    binObservations.Clear();
                    binPositions.Clear();
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Populate the list of GenomicBin objects for this chromosome.  
        /// </summary>
        static void BinCountsForChromosome(BinTaskArguments arguments)
        {
            List<GenomicBin> bins = arguments.Bins;
            bool usePredefinedBins = bins.Any();
            int predefinedBinIndex = 0;
            GenericRead fastaEntry = arguments.FastaEntry; //fastaEntryKVP.Value;
            BinState currentBin = new BinState();
            string chr = arguments.Chromosome;
            BitArray possibleAlignments = arguments.PossibleAlignments;
            HitArray observedAlignments = arguments.ObservedAlignments;
            CanvasCoverageMode coverageMode = arguments.CoverageMode;
            int pos = usePredefinedBins ? bins[predefinedBinIndex].Start : 0;

            // Skip past leading Ns
            while (fastaEntry.Bases[pos].Equals('n'))
                pos++;
            List<float> binPositions = new List<float>();
            List<int> binObservations = new List<int>();
            for (; pos < fastaEntry.Bases.Length; pos++)
            {
                // Sets the start of the bin
                if (currentBin.StartPosition == -1)
                    currentBin.StartPosition = pos;

                if (!fastaEntry.Bases[pos].Equals("n"))
                    currentBin.NucleotideCount++;


                //if (IsGC(fastaEntry.Bases[pos]))
                //    currentBin.GCCount++;
                switch (fastaEntry.Bases[pos])
                {
                    case 'C':
                    case 'c':
                    case 'G':
                    case 'g':
                        currentBin.GCCount++;
                        break;

                }

                if (possibleAlignments[pos])
                {
                    currentBin.PossibleCount++;
                    currentBin.ObservedCount += observedAlignments.Data[pos];
                    binObservations.Add(observedAlignments.Data[pos]);
                    if (coverageMode == CanvasCoverageMode.GCContentWeighted)
                        binPositions.Add(arguments.ObservedVsExpectedGC[arguments.ReadGCContent[pos]]);
                }

                // We've seen the desired number of possible alignment positions.
                if ((!usePredefinedBins && currentBin.PossibleCount == arguments.BinSize)
                    || (usePredefinedBins && pos == bins[predefinedBinIndex].Stop - 1))
                {
                    if (coverageMode == CanvasCoverageMode.TruncatedDynamicRange) // Truncated dynamic range
                    {
                        currentBin.ObservedCount = 0;
                        foreach (int Value in binObservations)
                        {
                            currentBin.ObservedCount += Math.Min(10, Value);
                        }
                    }
                    if (coverageMode == CanvasCoverageMode.GCContentWeighted) // read GC content weighted 
                    {
                        currentBin.ObservedCount = 0;
                        float tmpObservedCount = 0;
                        for (int i = 0; i < binObservations.Count; i++)
                        {
                            tmpObservedCount += Math.Min(10, (float)binObservations[i] / binPositions[i]);
                        }
                        currentBin.ObservedCount = (int)Math.Round(tmpObservedCount);

                    }

                    int gc = (int)(100 * currentBin.GCCount / currentBin.NucleotideCount);

                    if (usePredefinedBins)
                    {
                        bins[predefinedBinIndex].GC = gc;
                        bins[predefinedBinIndex].Count = currentBin.ObservedCount;
                        predefinedBinIndex++;
                        if (predefinedBinIndex >= bins.Count) { break; } // we have processed all the bins
                        pos = bins[predefinedBinIndex].Start - 1; // jump to right before the next predefined bin
                    }
                    else
                    {
                        // Note the pos + 1 to make the first three conform to bed specification
                        GenomicBin bin = new GenomicBin(chr, currentBin.StartPosition, pos + 1, gc, currentBin.ObservedCount);
                        bins.Add(bin);
                    }

                    // Reset all relevant variables
                    currentBin.Reset();
                    binObservations.Clear();
                    binPositions.Clear();
                }
            }
        }
Beispiel #13
0
 void OnSyncBinState(BinState newState)
 {
     binState = newState;
     UpdateSpriteBinState();
 }