Ejemplo n.º 1
0
        private bool handleWildcardColliderCallback(loveColliderCallback cb, loveColliderCallbackParameters cbParam, loveToy Toy, ColliderData[] colliders)
        {
            var colliderInfoA = ColliderCon.matchName(colliders, cbParam.a.name);

            if (colliderInfoA == null)
            {
                return(true); // hax.
            }
            for (int i = 0; i < colliders.Length; i++)
            {
                var col = colliders[i];
                if (col.name == colliderInfoA.name)
                {
                    continue;
                }
                var dist = Vector3.Distance(colliderInfoA.position, col.position) - (colliderInfoA.radius + col.radius);
                if (dist < cb.minDistance)
                {
                    cb.fCallback.Call(Toy, dist, cb, colliderInfoA, col);
                    return(true);
                }
            }
            cb.fCallback.Call(Toy, -1, cb, colliderInfoA, null);
            return(true);
        }
Ejemplo n.º 2
0
        public void update(ColliderData[] colliders, loveToy Toy)
        {
            for (int i = 0; i < Callbacks.Count; i++)
            {
                var cbFunc  = Callbacks[i];
                var cbParam = CallbackData[i];
                // Check if both are assigned
                if (cbParam.a == null || cbParam.b == null)
                {
                    continue;
                }

                // check if it has any collider search checked
                if (cbParam.b.any)
                {
                    if (handleWildcardColliderCallback(cbFunc, cbParam, Toy, colliders)) // bool for scope hack lol, indent next line (skip iteration)
                    {
                        continue;
                    }
                }

                // load collider info
                var colliderInfoA = ColliderCon.matchName(colliders, cbParam.a.name);
                var colliderInfoB = ColliderCon.matchName(colliders, cbParam.b.name);

                if (colliderInfoA == null || colliderInfoB == null) // none found
                {
                    continue;                                       // Skip iteration
                }
                //
                var radialDistance = (colliderInfoA.radius + colliderInfoB.radius);
                var dist           = Vector3.Distance(colliderInfoA.position, colliderInfoB.position);
                if (dist < cbFunc.minDistance) // check if daddy loves me uwu
                {
                    cbFunc.fCallback.Call(Toy, dist, cbFunc, colliderInfoA, colliderInfoB, dist);
                }
                else
                {
                    cbFunc.fCallback.Call(Toy, -1, cbFunc, colliderInfoA, colliderInfoB, dist);
                }
            }
        }
Ejemplo n.º 3
0
        public static void renderElements()
        {
            ImGui.SetNextWindowPos(new Vector2(0, 0));
            ImGui.SetNextWindowSize(new Vector2(340, 200));
            ImGui.Begin("Bluetooth Control");
            {
                if (ImGui.Button("Rescan"))
                {
                    btw_rescanDevices();
                }

                if (devices != null)
                {
                    foreach (BluetoothDevice dev in devices)
                    {
                        if (ImGui.Button(dev.Name))
                        {
                            btw_Connect(dev);
                        }
                    }
                }
            }
            ImGui.End();


            ImGui.SetNextWindowPos(new Vector2(340, 0));
            ImGui.SetNextWindowSize(new Vector2(200, 200));
            ImGui.Begin("VRC Collider Detection");
            for (int i = 0; i < rootInit.Toys.Length; i++)
            {
                var toyt = rootInit.Toys[i];
                if (toyt != null)
                {
                    if (ImGui.Button(toyt.Model + " " + toyt.btDevice.Id))
                    {
                        currentEditToy = toyt;
                    }
                }
            }
            ImGui.End();



            ImGui.SetNextWindowPos(new Vector2(0, 200));
            ImGui.SetNextWindowSize(new Vector2(540, 400));
            ImGui.Begin("Controller Manager");
            if (currentEditToy != null)
            {
                ImGui.Text($"Current Controller {(currentEditToy.Controller == null ? "NOTHING" : currentEditToy.Controller.Name)}");
                var item  = 0;
                var items = rootInit.controllers.Keys.ToArray <string>();
                if (ImGui.Combo("Set new controller", ref item, items, items.Length))
                {
                    currentEditToy.Controller = rootInit.controllers[items[item]].copy();
                }
                if (currentEditToy.Controller != null)
                {
                    for (int bi = 0; bi < currentEditToy.Controller.Callbacks.Count; bi++)
                    {
                        var hnd   = currentEditToy.Controller.Callbacks[bi];
                        var param = currentEditToy.Controller.CallbackData[bi];
                        ImGui.Text(hnd.Name);
                        ImGui.Text($"A {(param.a == null ? "NOTHING" : param.a.name)}");


                        item  = 0;
                        items = new string[rootInit.colliders.Length];
                        for (int q = 0; q < items.Length; q++)
                        {
                            items[q] = rootInit.colliders[q].name;
                        }

                        if (ImGui.Combo("Set new collider A##" + bi, ref item, items, items.Length))
                        {
                            param.a = ColliderCon.matchName(rootInit.colliders, items[item]);
                        }

                        ImGui.Text($"B {(param.b == null ? "NOTHING" : param.b.name)}");
                        item = 0;
                        if (ImGui.Combo("Set new collider B##" + bi, ref item, items, items.Length))
                        {
                            param.b = ColliderCon.matchName(rootInit.colliders, items[item]);
                        }
                        if (ImGui.Button("Any##" + bi))
                        {
                            param.b = new ColliderData()
                            {
                                any = true, name = "ANY"
                            }
                        }
                        ;


                        ImGui.Spacing();
                    }
                }
            }

            ImGui.End();
        }
    }