Beispiel #1
0
 public bool Tick(IBehaviorHost host, RealmTime time)
 {
     Host = host;
     try
     {
         return TickCore(time);
     }
     catch (Exception e)
     {
         Console.Out.WriteLine(e);
         return true;
     }
 }
Beispiel #2
0
        /// <inheritdoc />
        public async Task ExecuteAsync <TArgument>(IBehaviorHost host, TArgument argument) where TArgument : IBehaviorArgument
        {
            if (host == null)
            {
                return;
            }

            Log.Debug($"Executing behaviours of [{host.GetType().FullName}].");
            foreach (var behaviour in host.Behaviors.OrderByDescending(d => d.Priority))
            {
                if (behaviour is IAsyncBehavior <TArgument> castedBehaviour)
                {
                    Log.Debug($"Executing [{behaviour.GetType().FullName}] using [{argument.GetType().FullName}]");
                    await castedBehaviour.ExecuteAsync(argument);
                }
            }
        }
        public async Task <bool> IsCancelledAsync(IBehaviorHost behaviorHost, IServiceProvider serviceProvider)
        {
            if (behaviorHost == null)
            {
                return(false);
            }

            var closeContext    = new WindowClosingContext(behaviorHost, serviceProvider);
            var behaviourRunner = serviceProvider.GetRequiredService <IBehaviorRunner>();
            await behaviourRunner.ExecuteAsync(behaviorHost, closeContext);

            if (closeContext.Cancelled)
            {
                CancelArgs.Cancel = true;
                return(true);
            }

            return(false);
        }
Beispiel #4
0
 public bool Tick(IBehaviorHost host, RealmTime time)
 {
     this.Host = host;
     return TickCore(time);
 }
Beispiel #5
0
 public bool ConditionMeet(IBehaviorHost host)
 {
     this.Host = host;
     return ConditionMeetCore();
 }
Beispiel #6
0
 public void Behave(BehaviorCondition cond, IBehaviorHost host, RealmTime? time, object state, string msg, Player player)
 {
     this.Host = host;
     BehaveCore(cond, time, state, msg, player);
 }
Beispiel #7
0
 public void Behave(BehaviorCondition cond, IBehaviorHost host, RealmTime? time, object state)
 {
     this.Host = host;
     BehaveCore(cond, time, state);
 }
 public void Behave(BehaviorCondition cond, IBehaviorHost host, RealmTime? time, object state, string msg)
 {
     Host = host;
     BehaveCore(cond, time, state, msg);
 }
 public bool Tick(IBehaviorHost host, RealmTime time)
 {
     Host = host;
     try
     {
         return TickCore(time);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return true;
     }
 }
Beispiel #10
0
 public void Behave(BehaviorCondition cond, IBehaviorHost host, RealmTime? time, object state, params Object[] args)
 {
     this.Host = host;
     BehaveCore(cond, time, state, args);
 }