Example #1
0
        private void CheckIfTreatmentFinished(ActiveDisease disease)
        {
            if (_inTimeConsumedCount == _countToConsume)
            {
                IsFinished = true;

                if (OnTreatmentEnded != null)
                {
                    OnTreatmentEnded.Invoke();
                }

                if (!IsNodePart)
                {
                    disease.DeclareDiseaseTreated();

                    disease.Invert();

                    Events.NotifyAll(l => l.DiseaseHealed(disease.Disease));
                }

                //("Disease treatment finished.");
            }
            else
            {
                //("Disease treatment continued. Healing.");

                if (!IsNodePart && IsStarted)
                {
                    Events.NotifyAll(l => l.DiseaseHealingContinued(disease.Disease));
                }
            }
        }
Example #2
0
        public bool OnApplianceTaken(IGameController gc, ApplianceInfo applianceInfo, ActiveDisease disease)
        {
            var treatedStage = disease.TreatedStage;

            if (treatedStage == null)
            {
                treatedStage = disease.GetActiveStage(gc.WorldTime.Value);
            }

            if (treatedStage == null)
            {
                return(false);
            }

            var isTreatedLevel = treatedStage.Level == _treatedLevel;
            var isApplied      = _treatments.Any(treatment => treatment.OnApplianceTaken(gc, applianceInfo, disease));

            if (isTreatedLevel)
            {
                if (_treatments.All(x => x.IsFinished))
                {
                    _isOverallHealingStarted = true;

                    disease.Invert();

                    disease.DeclareDiseaseTreated();

                    Events.NotifyAll(l => l.DiseaseHealed(disease.Disease));

                    return(true);
                }

                if (_treatments.All(x => x.IsStarted) && !_isOverallHealingStarted)
                {
                    _isOverallHealingStarted = true;

                    disease.Invert();

                    Events.NotifyAll(l => l.DiseaseTreatmentStarted(disease.Disease));

                    return(true);
                }

                if (isApplied && _isOverallHealingStarted)
                {
                    Events.NotifyAll(l => l.DiseaseHealingContinued(disease.Disease));
                }
            }

            return(isApplied);
        }
        public bool OnItemConsumed(IGameController gc, InventoryConsumableItemBase consumable, ActiveDisease disease)
        {
            if (disease.TreatedStage == null)
            {
                return(false);
            }

            var isApplied      = _treatments.Any(treatment => treatment.OnItemConsumed(gc, consumable, disease));
            var isTreatedLevel = disease.TreatedStage.Level == _treatedLevel;

            if (isTreatedLevel)
            {
                if (_treatments.All(x => x.IsFinished))
                {
                    _isOverallHealingStarted = true;

                    disease.Invert();

                    disease.DeclareDiseaseTreated();

                    Events.NotifyAll(l => l.DiseaseHealed(disease.Disease));

                    return(true);
                }

                if (_treatments.All(x => x.IsStarted) && !_isOverallHealingStarted)
                {
                    _isOverallHealingStarted = true;

                    disease.Invert();

                    Events.NotifyAll(l => l.DiseaseTreatmentStarted(disease.Disease));

                    return(true);
                }

                if (isApplied && _isOverallHealingStarted)
                {
                    Events.NotifyAll(l => l.DiseaseHealingContinued(disease.Disease));
                }
            }

            return(isApplied);
        }