Exemple #1
0
        private void FireAncestorMemo(ApprovalTracker approval)
        {
            var appropriateMemoDefs = new List <AncestorMemoDef>(DefDatabase <AncestorMemoDef> .AllDefsListForReading.Where(d => d.memoType == this.type));

            if (appropriateMemoDefs.Count == 0)
            {
                Log.Error("No valid Memo Defs of type " + this.type + "!");
                return;
            }

            bool hasFired = false;

            while (!hasFired && appropriateMemoDefs.Count > 0)
            {
                AncestorMemoDef memoDef = appropriateMemoDefs.RandomElement();
                appropriateMemoDefs.Remove(memoDef);

                var incidentParams = new IncidentParms();
                incidentParams.forced = true;
                if (memoDef.Worker.TryExecute(incidentParams))
                {
                    hasFired = true;
                }
            }

            if (!hasFired)
            {
                Log.Error("Despite valid Memo Defs existing for type " + this.type + " no memo fired!");
            }
        }
Exemple #2
0
        private void FinalizeAndSendLetter(ApprovalTracker approval)
        {
            if (this.type == MemoType.undecided)
            {
                var hourHistoryDelta = approval.HourHistoryDelta();
                if (hourHistoryDelta >= 0.0)
                {
                    this.type = MemoType.positive;
                }
                else
                {
                    this.type = MemoType.negative;
                }
            }

            if (this.type == MemoType.positive)
            {
                Find.LetterStack.ReceiveLetter("Good Omen!", "One of your colonists has spotted a propitious omen! " +
                                               " Surely the Ancestors are smiling on you.", LetterType.Good);
            }
            else
            {
                Find.LetterStack.ReceiveLetter("Ill Omen!", "One of your colonists has spotted an inauspicious " +
                                               "omen! Be wary in the coming hours.", LetterType.BadNonUrgent);
            }
            this.finalized = true;
        }
Exemple #3
0
        public void AncestorMemoTimerTickInterval(ApprovalTracker approval)
        {
            double intervalDelta = approval.IntervalDelta;

            this.nextEvent.AncestorMemoTickInterval(approval);

            if (this.nextEvent.Completed)
            {
                this.prevEvent = this.nextEvent;
                this.nextEvent = this.GenTimerEvent();
            }
            else if (this.nextEvent.Finalized)
            {
                return;
            }
            else if (approval.IntervalDelta > TriggerPositiveMemoThreshold &&
                     this.CanScheduleDelta)
            {
                this.nextEvent = this.GenDeltaEvent(MemoType.positive);
            }
            else if (approval.IntervalDelta < TriggerNegativeMemoThreshold &&
                     this.CanScheduleDelta)
            {
                this.nextEvent = this.GenDeltaEvent(MemoType.negative);
            }
        }
Exemple #4
0
        private static string EstApproval(float moodPercent)
        {
            List <float> MinMaxAvg           = new List <float>();
            var          approvalForInterval = ApprovalTracker.PawnApprovalForInterval(moodPercent);

            return(String.Format("{0,6:###.##} | {1,6:###.##} | {2,6:###.##}",
                                 minVisitorDaysPerSeason * AncestorUtils.IntervalsPerDay * approvalForInterval,
                                 avgVisitorDaysPerSeason * AncestorUtils.IntervalsPerDay * approvalForInterval,
                                 maxVisitorDaysPerSeason * AncestorUtils.IntervalsPerDay * approvalForInterval));
        }
Exemple #5
0
 public void AncestorMemoTickInterval(ApprovalTracker approval)
 {
     if (!this.Finalized && this.omenFireTick <= Find.TickManager.TicksGame)
     {
         this.FinalizeAndSendLetter(approval);
     }
     else if (this.memoFireTick <= Find.TickManager.TicksGame)
     {
         this.FireAncestorMemo(approval);
         this.completed = true;
     }
 }
Exemple #6
0
        private void Initialize()
        {
            var introDef = DefDatabase <ConceptDef> .GetNamed("MTW_AncestorShrineIntro");

            LessonAutoActivator.TeachOpportunity(introDef, OpportunityType.Important);

            if (this.AncestorFaction != null)
            {
                while (this.unspawnedAncestors.Count() < AncestorConstants.MIN_ANCESTORS)
                {
                    this.unspawnedAncestors.Add(this.GenAncestor());
                }
            }
            else
            {
                this.AlertNullFaction();
            }
            this.visitSchedule = AncestorVisitScheduler.BuildSeasonScheduleForCurrentSeason();
            this.visitSchedule.DisableAlreadyPassedVisits();
            this.approval    = new ApprovalTracker();
            this.timer       = new AncestorMemoTimer();
            this.initialized = true;
        }
Exemple #7
0
        private void PawnApprovalTickInterval(Pawn p)
        {
            float moodDelta = ApprovalTracker.PawnApprovalForInterval(p.needs.mood.CurInstantLevelPercentage);

            this.visitInfoMap[p.thingIDNumber].AddApproval(moodDelta);
        }
Exemple #8
0
        public void Notify_DespawnedForAnchorBlocked(Pawn ancestor)
        {
            var loss = ApprovalTracker.PawnApprovalForAnchorBlocked();

            this.visitInfoMap[ancestor.thingIDNumber].AddApproval(loss);
        }