public bool Test(IActor actor, ILogicState currentState, ILogicStrategyData strategyData) { if (actor is null) { throw new System.ArgumentNullException(nameof(actor)); } var hazardEffect = actor.Person.GetModule <IEffectsModule>().Items.OfType <SurvivalStatHazardEffect>() .SingleOrDefault(x => x.Type == SurvivalStatType.Satiety); if (hazardEffect == null) { return(false); } // var props = actor.Person.GetModule <IInventoryModule>().CalcActualItems(); var resources = props.OfType <Resource>(); var bestResource = ResourceFinder.FindBestConsumableResourceByRule(resources, ConsumeCommonRuleType.Satiety); if (bestResource == null) { return(false); } return(true); }
private static Resource ResourceToReduceHazard(IActor actor, ConsumeCommonRuleType ruleType) { if (actor is null) { throw new ArgumentNullException(nameof(actor)); } var props = actor.Person.GetModule <IInventoryModule>().CalcActualItems(); var resources = props.OfType <Resource>(); var bestResource = ResourceFinder.FindBestConsumableResourceByRule(resources, ruleType); return(bestResource); }
public bool Test(IActor actor, ISectorTaskSourceContext context, ILogicState currentState, ILogicStrategyData strategyData) { if (actor is null) { throw new ArgumentNullException(nameof(actor)); } if (currentState is null) { throw new ArgumentNullException(nameof(currentState)); } if (strategyData is null) { throw new ArgumentNullException(nameof(strategyData)); } //TODO Здесь лучше проверять на наличие эффекта раны var hpStat = actor.Person.GetModule <ISurvivalModule>().Stats .SingleOrDefault(x => x.Type == SurvivalStatType.Health); var isLowHp = hpStat.ValueShare <= 0.5f; if (!isLowHp) { return(false); } // var props = actor.Person.GetModule <IInventoryModule>().CalcActualItems(); var resources = props.OfType <Resource>(); var taskContext = new ActorTaskContext(context.Sector); var bestResource = ResourceFinder.FindBestConsumableResourceByRule( actor, taskContext, resources, ConsumeCommonRuleType.Health); if (bestResource == null) { return(false); } return(true); }
public bool Test(IActor actor, ILogicState currentState, ILogicStrategyData strategyData) { if (actor is null) { throw new System.ArgumentNullException(nameof(actor)); } if (currentState is null) { throw new System.ArgumentNullException(nameof(currentState)); } if (strategyData is null) { throw new System.ArgumentNullException(nameof(strategyData)); } var hpStat = actor.Person.GetModule <ISurvivalModule>().Stats.SingleOrDefault(x => x.Type == SurvivalStatType.Health); var hpStatCoeff = (float)hpStat.Value / (hpStat.Range.Max - hpStat.Range.Min); var isLowHp = hpStatCoeff <= 0.5f; if (!isLowHp) { return(false); } // var props = actor.Person.GetModule <IInventoryModule>().CalcActualItems(); var resources = props.OfType <Resource>(); var bestResource = ResourceFinder.FindBestConsumableResourceByRule(resources, ConsumeCommonRuleType.Health); if (bestResource == null) { return(false); } return(true); }
public bool Test(IActor actor, ILogicState currentState, ILogicStrategyData strategyData) { var hazardEffect = actor.Person.Effects.Items.OfType <SurvivalStatHazardEffect>() .SingleOrDefault(x => x.Type == SurvivalStatType.Water); if (hazardEffect == null) { return(false); } // var props = actor.Person.Inventory.CalcActualItems(); var resources = props.OfType <Resource>(); var bestResource = ResourceFinder.FindBestConsumableResourceByRule(resources, ConsumeCommonRuleType.Thirst); if (bestResource == null) { return(false); } return(true); }