コード例 #1
0
ファイル: HealthState.cs プロジェクト: ArcticWolves/zara
        public object GetActiveOrScheduled <T>(DateTime currentTime)
            where T : class
        {
            if (typeof(T).IsSubclassOf(typeof(DiseaseDefinitionBase)))
            {
                return(ActiveDiseases.ToList().FirstOrDefault(x => (x.IsActiveNow || x.DiseaseStartTime >= currentTime) && x.Disease.GetType() == typeof(T)));
            }

            if (typeof(T).IsSubclassOf(typeof(InjuryBase)))
            {
                return(ActiveInjuries.ToList().FirstOrDefault(x => (x.IsActiveNow || x.InjuryTriggerTime >= currentTime) && x.Injury.GetType() == typeof(T)));
            }

            return(null);
        }
コード例 #2
0
ファイル: HealthState.cs プロジェクト: ArcticWolves/zara
        public object GetActive <T>()
            where T : class
        {
            if (typeof(T).IsSubclassOf(typeof(DiseaseDefinitionBase)))
            {
                return(ActiveDiseases.ToList().FirstOrDefault(x => x.IsActiveNow && x.Disease.GetType() == typeof(T)));
            }

            if (typeof(T).IsSubclassOf(typeof(InjuryBase)))
            {
                return(ActiveInjuries.ToList().FirstOrDefault(x => x.IsActiveNow && x.Injury.GetType() == typeof(T)));
            }

            return(null);
        }