private void OnMouseHold()
        {
            if (IsMouseOverUI())
            {
                return;
            }

            OnHold?.Invoke(_floorPos);
        }
Ejemplo n.º 2
0
 private bool Hold(int touchId, Vector2 position)
 {
     if (Pressed && TouchId == touchId)
     {
         OnHold?.Invoke(position);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
 protected void CancelCoroutineTap(OnHold pEvent)
 {
     _onUI = false;
     _targetInteractable = null;
     _targetItemPickUp   = null;
     _tapPosition        = Vector3.zero;
     _isHolding          = true;
     moveHold            = true;
 }
Ejemplo n.º 4
0
 protected void Hold(OnHold e)
 {
     if (_rolling || mode != ECameraTargetType.MAP)
     {
         return;
     }
     Block();
     _holding = true;
     StartCoroutine(OrbitalCoroutine());
 }
Ejemplo n.º 5
0
 public Action(KeyCode key,
               string name,
               OnTrigger onTrigger = null,
               OnHold onHold       = null,
               OnRelease onRelease = null)
 {
     Key             = key;
     Name            = name;
     OnTriggerMethod = onTrigger;
     OnHoldMethod    = onHold;
     OnReleaseMethod = onRelease;
 }
Ejemplo n.º 6
0
        public void KillAllSubscribers()
        {
            if (OnClicked != null)
            {
                foreach (var del in OnClicked?.GetInvocationList())
                {
                    OnClicked -= (Action)del;
                }
            }

            if (OnHovered != null)
            {
                foreach (var del in OnHovered?.GetInvocationList())
                {
                    OnHovered -= (Action)del;
                }
            }

            if (OnUnhovered != null)
            {
                foreach (var del in OnUnhovered?.GetInvocationList())
                {
                    OnUnhovered -= (Action)del;
                }
            }

            if (OnPressed != null)
            {
                foreach (var del in OnPressed?.GetInvocationList())
                {
                    OnPressed -= (Action)del;
                }
            }

            if (OnReleased != null)
            {
                foreach (var del in OnReleased?.GetInvocationList())
                {
                    OnReleased -= (Action)del;
                }
            }

            if (OnHold != null)
            {
                foreach (var del in OnHold?.GetInvocationList())
                {
                    OnHold -= (Action)del;
                }
            }
        }
Ejemplo n.º 7
0
        private void HandleKeyDownHookEvent(MouseHookEventArgs args)
        {
            OnHook?.Invoke(args);

            lock (downButtons)
            {
                // Save button to recognize successfull key presses (down and up)
                bool added = downButtons.Add(args.Button);

                if (added)
                {
                    OnHold?.Invoke(args);
                }
            }
        }
Ejemplo n.º 8
0
        public override void Update(Universe universe, Vector2 origin, AvatarController avatar, List<ScanCode> input, bool ctrl, bool shift, IReadOnlyList<InterfaceLogicalButton> inputPressed,
            Vector2 mouseLocation, bool click, bool clickHold) {
            var size = GetSize();
            var range = origin + size;
            if (_isEnabled) {
                if (Helpers.VectorContains(origin, range, mouseLocation)) {
                    if (click && !clickHold && Window?.CallUpdates != false && Window?.Visible != false) {
                        _pressed = true;
                    }

                    if (_pressed) {
                        if (!click) {
                            _pressed = false;
                            OnClick?.Invoke();
                        }
                    }

                    if (clickHold && Window?.CallUpdates != false && Window?.Visible != false) {
                        if (_update) {
                            HoldTimer();
                            OnHold?.Invoke();
                        }
                    }
                    foreach (var element in Elements) {
                        if (element is UiTextBlock textElement) {
                            textElement.SetColor(_activeTextColor);
                        }
                    }
                } else {
                    _pressed = false;
                    foreach (var element in Elements) {
                        if (element is UiTextBlock textElement) {
                            textElement.SetColor(_textColor);
                        }
                    }
                }
            } else {
                _pressed = false;
                foreach (var element in Elements) {
                    if (element is UiTextBlock textElement) {
                        textElement.SetColor(_disabledTextColor);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void Update()
        {
            var newState_KeyDown = InputProvider.IsDown(Binding);

            if (newState_KeyDown && !lastKeyState)
            {
                OnJustPressed.Fire(this, null);
            }
            else if (newState_KeyDown && lastKeyState)
            {
                OnHold.Fire(this, null);
            }
            else if (!newState_KeyDown && lastKeyState)
            {
                OnJustReleased.Fire(this, null);
            }

            lastKeyState = newState_KeyDown;
        }
Ejemplo n.º 10
0
        private void Hold(Vector2 position)
        {
            if (!swiped && !isHolding)
            {
                Vector2 delta = position - lastTouchPosition;
                lastTouchPosition = position;
                if (delta.sqrMagnitude > minSwipeSpeed * minSwipeSpeed)
                {
                    swiped = true;
                    Direction swipeDirection = GetSwipeDirection(delta);
                    OnSwipe?.Invoke(swipeDirection);
                    return;
                }

                holdingTime += Time.deltaTime;
                if (hitCell != null && holdingTime >= minHoldTime)
                {
                    isHolding = true;
                    OnHold?.Invoke(hitCell);
                }
            }
        }
Ejemplo n.º 11
0
        private void HandleKeyDownHookEvent(KeyboardHookEventArgs args)
        {
            OnHook?.Invoke(args);

            lock (downKeys)
            {
                // Save button to prevent multiple events and also to recognize successfull key presses (down and up)
                bool added = downKeys.Add(args.KeyCode);

                if (added)
                {
                    OnHold?.Invoke(args); // First time
                }
                else
                {
                    if (!settings.HookHoldEventOnce)
                    {
                        OnHold?.Invoke(args);
                    }
                }
            }
        }
Ejemplo n.º 12
0
    IEnumerator HoldCounter()
    {
        if (counting)
        {
            yield break;
        }
        counting = true;

        for (float count = 0; count < 1 && pointerDown; count += Time.fixedDeltaTime)
        {
            yield return(new WaitForFixedUpdate());
        }
        if (!pointerDown)
        {
            counting = false; yield break;
        }

        selected = true;
        lockButtons.Invoke(true);
        OnHold.Invoke();

        counting = false;
        yield break;
    }
Ejemplo n.º 13
0
 protected void OnHoldMovement(OnHold e)
 {
     _bagButton.raycastTarget = false;
     Events.Instance.AddListener <OnRemove>(RemoveHold);
 }
Ejemplo n.º 14
0
 private void OnHoldEvent()
 {
     OnHold?.Invoke(this);
 }
Ejemplo n.º 15
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(New.GetHashCode() ^ Open.GetHashCode() ^ Resolved.GetHashCode() ^ OnHold.GetHashCode() ^ Invalid.GetHashCode() ^ Duplicate.GetHashCode() ^ Wontfix.GetHashCode());
     }
 }
Ejemplo n.º 16
0
 public virtual void FireOnHold()
 {
     OnHold?.Invoke();
     NotifyChanged();
 }
Ejemplo n.º 17
0
        private async Task GetReadyWS()
        {
            if (KKK.IsClientReady != true)
            {
                Console.WriteLine("Waiting for client to be ready..."); //Dont start events until discord api is ready
            }

            do
            {
                // nothing, just pauses the tasks until discord is ready
            } while (KKK.IsClientReady != true);

            Console.WriteLine("It's ready, lets start, shall we?");
            DatabaseContext context = new DatabaseContext();

#if RELEASE
            var server = new WebSocketServer("wss://0.0.0.0:8181");
            var config = BuildConfig();
            server.Certificate = new X509Certificate2(config["certPath"], config["certPassword"]);
#elif DEBUG
            var server = new WebSocketServer("ws://0.0.0.0:8181");
#endif
            server.Start(socket =>
            {
                socket.OnOpen = () =>
                {
                    if (allSockets.Any(client =>
                                       client.ConnectionInfo.ClientIpAddress == socket.ConnectionInfo.ClientIpAddress))
                    {
                        var socket2 = allSockets.Find(client =>
                                                      client.ConnectionInfo.ClientIpAddress == socket.ConnectionInfo.ClientIpAddress);
                        try
                        {
                            allSockets.Remove(socket2);
                        }
                        catch (Exception ex)
                        {
                            logger.Warn(ex.ToString(), "An error occured.");
                        } //Little security, dont let same ip to connect twice

                        allSockets.Add(socket);
                    }
                    else
                    {
                        try
                        {
                            allSockets.Remove(socket);
                        }
                        catch (Exception ex)
                        {
                            logger.Warn(ex.ToString(), "An error occured.");
                        }

                        allSockets.Add(socket);
                    }
                };
                socket.OnClose = () =>
                {
                    Console.WriteLine("Closed connection: " + socket.ConnectionInfo.ClientIpAddress);
                    allSockets.Remove(socket);
                    if (context.Auth.Any(o => o.IP == socket.ConnectionInfo.ClientIpAddress))
                    {
                        string token = context.Auth.AsQueryable().Where(a => a.IP == socket.ConnectionInfo.ClientIpAddress).Single().Token;
                        if (AliveTokens.Contains(token))
                        {
                            AliveTokens.Remove(token);
                            logger.Info($"{socket.ConnectionInfo.ClientIpAddress} Removed from alive tokens list");
                        }
                    }
                };
                socket.OnMessage = message =>
                {
                    Task.Run(async() =>
                    {
                        try
                        {
#if DEBUG
                            Console.WriteLine($"Message Received: {message}");
#endif
                            string[] codes = message.Split('|');
                            switch (codes[0])
                            {
                            case "login":
                                string token = codes[1];
                                if (context.Auth.Any(o => o.Token == token))
                                {
                                    if (!AliveTokens.Contains(context.Auth.AsQueryable().Where(a => a.IP == socket.ConnectionInfo.ClientIpAddress).Single().Token))
                                    {
                                        try
                                        {
                                            AliveTokens.Add(token);
                                            Console.WriteLine(
                                                $"{socket.ConnectionInfo.ClientIpAddress}:{token} Added to alive tokens list");
#if DEBUG
                                            Console.WriteLine("Here is Serverid: " +
                                                              context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid);
#endif
                                            if (KKK.Client.GetGuild(context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid) != null)
                                            {
                                                var guild = KKK.Client.GetGuild(
                                                    context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid);
                                                await socket.Send($"status|Linked|{guild.Name}");
                                            }
                                            else
                                            {
                                                await socket.Send($"status|Linked|null");
                                            }
                                            if (context.Notify.Any(o => o.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid))
                                            {
                                                await socket.Send($"subscribe|playerEvent");
                                            }
                                            if (context.OnJoin.Any(o => (o.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid) && o.sevent == 1))
                                            {
                                                await socket.Send($"subscribe|serverListEvent");
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            logger.Warn(ex.ToString(), "An error occured.");
                                        }
                                    }
                                }
                                else if (!(context.Auth.Any(o => o.Token == token)))
                                {
                                    if (!(context.OnHold.Any(o => o.IP == socket.ConnectionInfo.ClientIpAddress)))
                                    {
                                        using (var contextt = new DatabaseContext())
                                        {
                                            OnHold newonhold = new OnHold();
                                            newonhold.IP     = socket.ConnectionInfo.ClientIpAddress;
                                            newonhold.Token  = token;
                                            contextt.Add(newonhold);
                                            contextt.SaveChanges();
                                        }
                                    }
                                    else if ((context.OnHold.Any(o => o.IP == socket.ConnectionInfo.ClientIpAddress)))
                                    {
                                        var onhold   = context.OnHold.First(a => a.IP == socket.ConnectionInfo.ClientIpAddress);
                                        onhold.Token = token;
                                        context.SaveChanges();
                                    }
                                    Console.WriteLine("Token: " + token +
                                                      $" IP: {socket.ConnectionInfo.ClientIpAddress} Added to onhold list");
                                    await socket.Send("status|OnHold");
                                }

                                break;

                            case "notify":

                                if (AliveTokens.Contains(context.Auth.AsQueryable().Where(a => a.IP == socket.ConnectionInfo.ClientIpAddress).Single().Token))
                                {
                                    await Task.Run(async() =>
                                    {
                                        try
                                        {
                                            string servername  = codes[1];
                                            string discordname = codes[2];
                                            string channelid   = codes[3];
                                            string messageid   = codes[4];
                                            string eventt      = codes[5];
                                            string result      = codes[6];

                                            switch (eventt)
                                            {
                                            case "stop":

                                                switch (result)
                                                {
                                                //notify|{servername}|{discordname}|{channelid}|{messageid}|{eventt}|400|this is a test
                                                case "20":             //ok
                                                    await BotTools.NotificationControlAsync(
                                                        ulong.Parse(messageid), ulong.Parse(channelid),
                                                        $"Your `{servername}` stopped successfully, command was executed by `{discordname}`",
                                                        int.Parse(result));
                                                    break;

                                                case "40":             //its stopped already
                                                    await BotTools.NotificationControlAsync(
                                                        ulong.Parse(messageid), ulong.Parse(channelid),
                                                        $"Your `{servername}` is stopped already, command was executed by `{discordname}`",
                                                        int.Parse(result));
                                                    break;

                                                case "44":             //server not found
                                                    await BotTools.NotificationControlAsync(
                                                        ulong.Parse(messageid), ulong.Parse(channelid),
                                                        $"I couldnt find your `{servername}` server, please make sure you typed the right name, command was executed by `{discordname}`",
                                                        int.Parse(result));
                                                    break;
                                                }

                                                break;

                                            case "start":

                                                switch (result)
                                                {
                                                //notify|{servername}|{discordname}|{channelid}|{messageid}|{eventt}|400|this is a test
                                                case "20":             //ok
                                                    await BotTools.NotificationControlAsync(
                                                        ulong.Parse(messageid), ulong.Parse(channelid),
                                                        $"Your `{servername}` server is starting.. , command was executed by `{discordname}`",
                                                        int.Parse(result));
                                                    break;

                                                case "21":             //ok
                                                    await BotTools.NotificationControlAsync(
                                                        ulong.Parse(messageid), ulong.Parse(channelid),
                                                        $"Your `{servername}` started successfully, command was executed by `{discordname}`",
                                                        int.Parse(result));
                                                    break;

                                                case "40":             //its stopped already
                                                    await BotTools.NotificationControlAsync(
                                                        ulong.Parse(messageid), ulong.Parse(channelid),
                                                        $"Your `{servername}` is running already, command was executed by `{discordname}`",
                                                        int.Parse(result));
                                                    break;

                                                case "44":             //server not found
                                                    await BotTools.NotificationControlAsync(
                                                        ulong.Parse(messageid), ulong.Parse(channelid),
                                                        $"I couldnt find your `{servername}` server, please make sure you typed the right name, command was executed by `{discordname}`",
                                                        int.Parse(result));
                                                    break;
                                                }

                                                break;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            logger.Warn($"Couldn't process request: {ex.Message}");
                                        }
                                    });
                                }

                                break;

                            case "event":
                                await Task.Run(async() =>
                                {
                                    string eventname  = codes[1];
                                    string servername = codes[2];
                                    string playername = codes[3];
                                    try
                                    {
                                        string token = context.Auth.AsQueryable().Where(a => a.IP == socket.ConnectionInfo.ClientIpAddress).Single().Token;
                                        if (AliveTokens.Contains(token))
                                        {
                                            if (KKK.Client.GetGuild(context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid) != null)
                                            {
                                                if (eventname.StartsWith("p") &&
                                                    context.Notify.AsQueryable().Any(x => x.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid) &&
                                                    KKK.Client.GetGuild(context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid)
                                                    .GetChannel(
                                                        context.Notify.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Channelid) != null)
                                                {
                                                    switch (eventname)
                                                    {
                                                    case "pjoin":
                                                        await BotTools.NotificationControlAsync(0,
                                                                                                context.Notify.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Channelid,
                                                                                                $"***{playername}*** Just joined ***{servername}***", 0,
                                                                                                1);
                                                        break;

                                                    case "pleave":
                                                        await BotTools.NotificationControlAsync(0,
                                                                                                context.Notify.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Channelid,
                                                                                                $"***{playername}*** Just left ***{servername}***", 0,
                                                                                                1);
                                                        break;
                                                    }
                                                }
                                                else if (eventname.StartsWith("serverList") &&
                                                         context.OnJoin.Any(o => (o.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid) && o.sevent == 1) &&
                                                         KKK.Client
                                                         .GetGuild(context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid)
                                                         .GetChannel(
                                                             context.OnJoin.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Channelid) !=
                                                         null)
                                                {
                                                    await Task.Run(async() =>
                                                    {
                                                        try
                                                        {
                                                            if (AliveTokens.Contains(token) &&
                                                                (context.OnJoin.Any(o => (o.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid) && o.sevent == 1)))
                                                            {
                                                                ulong guild = context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid;
                                                                if (KKK.Client.GetGuild(guild)
                                                                    .GetChannel(
                                                                        context.OnJoin.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Channelid) != null)
                                                                {
                                                                    if (context.OnJoin.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Messageid != 0)
                                                                    {
                                                                        IMessageChannel chan =
                                                                            (IMessageChannel)KKK.Client.GetChannel(context.OnJoin.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Channelid);
                                                                        IUserMessage msg =
                                                                            (IUserMessage)await chan.GetMessageAsync(context.OnJoin.AsQueryable().Where(a => a.Serverid == context.Auth.AsQueryable().Where(a => a.Token == token).Single().Serverid).Single().Messageid);
                                                                        if (msg != null)
                                                                        {
                                                                            await msg.ModifyAsync(msgProperty =>
                                                                            {
                                                                                msgProperty.Embed =
                                                                                    BuildServerListEmbed(message);
                                                                            });
                                                                        }
                                                                        else
                                                                        {
                                                                            var msgg = await chan.SendMessageAsync(null,
                                                                                                                   false,
                                                                                                                   BotTools.Embed(
                                                                                                                       "Dont remove this message, this message will be updated continuously",
                                                                                                                       20));
                                                                            var server       = context.OnJoin.First(a => a.Serverid == guild);
                                                                            server.Messageid = msgg.Id;
                                                                            server.sevent    = 1;
                                                                            context.SaveChanges();
                                                                            await msgg.ModifyAsync(msgProperty =>
                                                                            {
                                                                                msgProperty.Embed =
                                                                                    BuildServerListEmbed(message);
                                                                            });
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            Console.WriteLine("Exception occured: " + ex.ToString());
                                                        }
                                                    });
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine("Exception occured: " + ex.ToString());
                                    }
                                });

                                break;

                            default:
                                // ban ip in case gets to x requests To-DO
                                Console.WriteLine($"Someone is trying to troll here, invalid packet: {message}");
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    });


                    //Console.WriteLine(message);

                    //allSockets.ToList().ForEach(s => s.Send(message));
                };
            });
            var input = Console.ReadLine();
            while (input != "exit")
            {
                //foreach (var socket in allSockets.ToList())
                //{
                //    await socket.Send(input);
                //}
                //input = Console.ReadLine();
            }
        }