예제 #1
0
        public static bool CheckTimesKarmaTypeHasBeenUsedRecently(StoreIncident incident)
        {
            // if they have max event setting off always return false
            if (!ToolkitSettings.MaxEvents)
            {
                return(false);
            }

            Store_Component component = Current.Game.GetComponent <Store_Component>();

            switch (incident.karmaType)
            {
            case KarmaType.Bad:
                return(component.KarmaTypesInLogOf(incident.karmaType) >= ToolkitSettings.MaxBadEventsPerInterval);

            case KarmaType.Good:
                return(component.KarmaTypesInLogOf(incident.karmaType) >= ToolkitSettings.MaxGoodEventsPerInterval);

            case KarmaType.Neutral:
                return(component.KarmaTypesInLogOf(incident.karmaType) >= ToolkitSettings.MaxNeutralEventsPerInterval);

            case KarmaType.Doom:
                return(component.KarmaTypesInLogOf(incident.karmaType) >= ToolkitSettings.MaxBadEventsPerInterval);
            }

            return(false);
        }
예제 #2
0
        public float DaysTillIncidentIsPurchaseable(StoreIncident incident)
        {
            Store_Component component = Current.Game.GetComponent <Store_Component>();

            List <int> associateLogIDS = new List <int>();

            bool onCooldownByKarmaType;
            bool onCooldownByIncidentCap;

            float ticksTillExpires        = -1;
            float daysTillCooldownExpires = -1;

            if (incident.defName == "Item")
            {
                if (ToolkitSettings.MaxEvents)
                {
                    int logged = component.IncidentsInLogOf(incident.abbreviation);
                    onCooldownByKarmaType = logged >= ToolkitSettings.MaxCarePackagesPerInterval;
                }

                if (ToolkitSettings.EventsHaveCooldowns)
                {
                    int logged = component.IncidentsInLogOf(incident.abbreviation);
                    onCooldownByIncidentCap = logged >= incident.eventCap;
                }

                foreach (KeyValuePair <int, string> pair in abbreviationHistory)
                {
                    if (pair.Value == incident.abbreviation)
                    {
                        associateLogIDS.Add(pair.Key);
                    }
                }
            }
            else
            {
                if (ToolkitSettings.MaxEvents)
                {
                    int logged = component.KarmaTypesInLogOf(incident.karmaType);
                    onCooldownByKarmaType = Purchase_Handler.CheckTimesKarmaTypeHasBeenUsedRecently(incident);
                }

                if (ToolkitSettings.EventsHaveCooldowns)
                {
                    int logged = component.IncidentsInLogOf(incident.abbreviation);
                    onCooldownByIncidentCap = logged >= incident.eventCap;
                }

                foreach (KeyValuePair <int, string> pair in abbreviationHistory)
                {
                    if (pair.Value == incident.abbreviation)
                    {
                        associateLogIDS.Add(pair.Key);
                    }
                }

                foreach (KeyValuePair <int, string> pair in karmaHistory)
                {
                    if (pair.Value == incident.karmaType.ToString())
                    {
                        associateLogIDS.Add(pair.Key);
                    }
                }
            }

            foreach (int id in associateLogIDS)
            {
                float ticksAgo            = Find.TickManager.TicksGame - tickHistory[id];
                float daysAgo             = ticksAgo / GenDate.TicksPerDay;
                float ticksTillExpiration = (ToolkitSettings.EventCooldownInterval * GenDate.TicksPerDay) - ticksAgo;
                if (ticksTillExpires == -1 || ticksAgo < ticksTillExpiration)
                {
                    ticksTillExpires        = ticksAgo;
                    daysTillCooldownExpires = ticksTillExpiration / GenDate.TicksPerDay;
                }
            }

            return((float)Math.Round(daysTillCooldownExpires, 1));
        }