Exemple #1
0
 void InvokeOnTargetDestroyed(IRangeTarget target)
 {
     try
     {
         TargetDestroyed?.Invoke(this, target);
     }
     catch (Exception e)
     {
         Urho.IO.Log.Write(LogLevel.Debug,
                           $"There was an unexpected exception during the invocation of {nameof(TargetDestroyed)}: {e.Message}");
     }
 }
        private void OnTargetDestroyed(TargetTargetDestroyedFirefoxEvent payload)
        {
            string targetId = payload.TargetId;

            if (TargetsMap.TryRemove(targetId, out var target))
            {
                target.DidClose();
                TargetDestroyed?.Invoke(this, new TargetChangedArgs {
                    Target = target
                });
            }
        }
Exemple #3
0
        private void DestroyTarget(MessageEventArgs args)
        {
            if (!_targets.ContainsKey(args.MessageData.targetId.ToString()))
            {
                throw new InvalidTargetException("Target should exists before DestroyTarget");
            }

            var target = _targets[args.MessageData.targetId.ToString()];

            if (!target.InitilizedTaskWrapper.Task.IsCompleted)
            {
                target.InitilizedTaskWrapper.SetResult(false);
            }
            _targets.Remove(args.MessageData.targetId.ToString());

            TargetDestroyed?.Invoke(this, new TargetChangedArgs()
            {
                Target = target
            });
        }
Exemple #4
0
        private void DestroyTarget(TargetDestroyedResponse e)
        {
            if (!_targets.ContainsKey(e.TargetId))
            {
                throw new InvalidTargetException("Target should exists before DestroyTarget");
            }

            var target = _targets[e.TargetId];

            if (!target.InitilizedTaskWrapper.Task.IsCompleted)
            {
                target.InitilizedTaskWrapper.SetResult(false);
            }
            _targets.Remove(e.TargetId);

            TargetDestroyed?.Invoke(this, new TargetChangedArgs()
            {
                Target = target
            });
        }
Exemple #5
0
        private async Task DestroyTargetAsync(TargetDestroyedResponse e)
        {
            if (!TargetsMap.ContainsKey(e.TargetId))
            {
                throw new InvalidTargetException("Target should exists before DestroyTarget");
            }

            var target = TargetsMap[e.TargetId];

            TargetsMap.Remove(e.TargetId);

            target.CloseTaskWrapper.TrySetResult(true);

            if (await target.InitializedTask.ConfigureAwait(false))
            {
                TargetDestroyed?.Invoke(this, new TargetChangedArgs
                {
                    Target = target
                });
            }
        }
        private async Task DestroyTargetAsync(TargetTargetDestroyedChromiumEvent e)
        {
            if (!TargetsMap.ContainsKey(e.TargetId))
            {
                throw new PlaywrightSharpException("Target should exists before DestroyTarget");
            }

            var target = TargetsMap[e.TargetId];

            TargetsMap.TryRemove(e.TargetId, out _);
            target.DidClose();

            target.CloseTaskWrapper.TrySetResult(true);

            if (await target.InitializedTask.ConfigureAwait(false))
            {
                var args = new TargetChangedArgs {
                    Target = target
                };
                TargetDestroyed?.Invoke(this, args);
            }
        }
Exemple #7
0
        private async Task DestroyTargetAsync(TargetDestroyedResponse e)
        {
            if (!_targets.ContainsKey(e.TargetId))
            {
                throw new InvalidTargetException("Target should exists before DestroyTarget");
            }

            var target = _targets[e.TargetId];

            _targets.Remove(e.TargetId);

            if (!target.CloseTaskWrapper.Task.IsCompleted)
            {
                target.CloseTaskWrapper.SetResult(true);
            }
            if (await target.InitializedTask)
            {
                TargetDestroyed?.Invoke(this, new TargetChangedArgs
                {
                    Target = target
                });
            }
        }
Exemple #8
0
        public void HandleHit(HitEvent hitEvent)
        {
            HitCount++;


            if (HitCount < BlockSize)
            {
                return;
            }
            else
            {
                foreach (Cell cell in shipCells)
                {
                    if (cell.HitCount == 0)
                    {
                        return;
                    }
                }
                // all cells have been hit, sink the ship
                State = TargetState.Destroyed;
                //raise the event
                TargetDestroyed?.Invoke(this);
            }
        }
 internal void OnTargetDestroyed(Browser browser, TargetChangedArgs args) => TargetDestroyed?.Invoke(browser, args);