public ActivityResolver(IUtilityAi utilityAi, IConditionContext conditionContext, IActivityCreationContext activityCreationContext) { _utilityAi = utilityAi; _conditionContext = conditionContext; _activityCreationContext = activityCreationContext; }
public UtilityAi(IActivityCreationContext activityCreationContext, ISkillEvaluationContext skillEvaluationContext, IConditionContext conditionContext) { _activityCreationContext = activityCreationContext; _skillEvaluationContext = skillEvaluationContext; _conditionContext = conditionContext; }
/// <summary> /// Sends a notification synchronously. /// </summary> /// <param name="context">A reference to the condition context.</param> /// <param name="notification">The notification to send.</param> protected void SendNotification(IConditionContext context, INotification notification) { context.ThrowIfNull(nameof(context)); notification.ThrowIfNull(nameof(notification)); notification.Send(new NotificationContext(context.Logger, context.MapDescriptor, context.CreatureFinder)); }
/// <summary> /// Sends a notification asynchronously. /// </summary> /// <param name="context">A reference to the condition context.</param> /// <param name="notification">The notification to send.</param> /// <param name="delayTime">Optional. The time delay after which the notification should be sent. If left null, the notificaion is scheduled to be sent ASAP.</param> protected void SendNotificationAsync(IConditionContext context, INotification notification, TimeSpan?delayTime = null) { context.ThrowIfNull(nameof(context)); notification.ThrowIfNull(nameof(notification)); context.Scheduler.ScheduleEvent(notification, delayTime); }
public void Load(IConditionContext context, string scriptFile) { mConditionContext = context; string[] lines = File.ReadAllLines(scriptFile); bool startBlockFounded = false; foreach (var line in lines) { if (IsBeginStartLine(line)) { startBlockFounded = true; continue; } if (startBlockFounded) { if (IsEndLine(line)) { startBlockFounded = false; continue; } var condition = ParseCondition(line); if (condition != null) { mStartConditions.Add(condition); } } } }
public override bool Evaluate(GameEntity entity, IConditionContext conditionContext) { IEnumerable <GameEntity> entitiesSeen = entity.vision.EntitiesNoticed .Select(guid => conditionContext.Context.GetEntityWithId(guid)) .Where(e => e != null) // SAME AS IN PostHeartbeatSystem. will ignore removed entites, but they will remain in EntitiesNoticed. todo: is it fine? ; return(entitiesSeen.Any(e => !conditionContext.FriendshipResolver.AreFriends(entity, e))); }
public override bool Evaluate(GameEntity entity, IConditionContext conditionContext) { IEnumerable <GameEntity> selectedItemsInVicinity = conditionContext.EntityDetector.DetectEntities(entity.position.Position, entity.vision.PerceptionRange) .Where(e => e.isCarryable) .Where(e => e.recipee.RecipeeName == ItemRecipee.Id); return(selectedItemsInVicinity.Any()); }
/// <summary> /// Executes the condition's logic. /// </summary> /// <param name="context">The execution context for this condition.</param> protected override void Execute(IConditionContext context) { var inThingContainer = this.Item.ParentContainer; if (!(this.Item is IThing existingThing) || !this.Item.HasExpiration || inThingContainer == null) { // Silent fail. return; } if (this.Item.ExpirationTarget == 0) { // We will delete this item. context.Scheduler.ScheduleEvent(new DeleteItemOperation(requestorId: 0, this.Item)); return; } var creationArguments = ItemCreationArguments.WithTypeId(this.Item.ExpirationTarget); if (this.Item.IsLiquidPool) { creationArguments.Attributes = new[]
/// <summary> /// Executes the condition's logic. /// </summary> /// <param name="context">The execution context for this condition.</param> protected override void Execute(IConditionContext context) { var currentTimeSnapshot = context.CurrentTime; // Clear out any exhaustion that has passed. foreach (var exhaustionType in this.ExhaustionTimesPerType.Keys) { if (this.ExhaustionTimesPerType[exhaustionType] > currentTimeSnapshot) { continue; } this.ExhaustionTimesPerType.Remove(exhaustionType); } if (this.ExhaustionTimesPerType.Count == 0) { return; } var nextExpiry = this.ExhaustionTimesPerType.Min(kvp => kvp.Value - currentTimeSnapshot); this.RepeatAfter = nextExpiry < TimeSpan.Zero ? TimeSpan.Zero : nextExpiry; }
/// <summary> /// Executes the condition's logic. /// </summary> /// <param name="context">The execution context for this condition.</param> protected override void Execute(IConditionContext context) { // For InFight, we just send the updated flags. this.SendNotificationAsync(context, new GenericNotification(() => this.Player.YieldSingleItem(), new PlayerConditionsPacket(this.Player))); }
public abstract bool Evaluate(GameEntity entity, IConditionContext conditionContext);
public EqualCondition(IConditionContext context, string name, T val) : base(context, name) { mValue = val; }
/// <summary> /// Executes the condition's logic. /// </summary> /// <param name="context">The execution context for this condition.</param> protected override void Execute(IConditionContext context) { // For InFight, we just send the updated flags. this.SendNotification(context, new PlayerConditionsUpdateNotification(this.Player)); }
public NotEqualCondition(IConditionContext context, string varName, T val) : base(context, varName) { mValue = val; }
/// <summary> /// Executes the condition's logic. /// </summary> /// <param name="context">The execution context for this condition.</param> protected abstract void Execute(IConditionContext context);
public Condition(IConditionContext context, string variableName) { this.context = context; this.mVariableName = variableName; }
public RaceEqualCondition(IConditionContext context, string name, Race race) : base(context, name, race) { }
public override bool Evaluate(GameEntity entity, IConditionContext conditionContext) { return(entity.vision.EntitiesNoticed .Select(id => conditionContext.Context.GetEntityWithId(id)) .Any(e => conditionContext.FriendshipResolver.AreFriends(entity, e))); }
public override bool Evaluate(GameEntity entity, IConditionContext conditionContext) { return(entity.isAggressive == Aggressive); }
/// <summary> /// Sends a notification synchronously. /// </summary> /// <param name="context">A reference to the condition's context.</param> /// <param name="notification">The notification to send.</param> protected void SendNotification(IConditionContext context, INotification notification) { notification.ThrowIfNull(nameof(notification)); context.GameApi.SendNotification(notification); }