コード例 #1
0
    private static LuerlockItemConnection NeedleConfiguration(ItemConnector connector, Transform hand, Interactable interactable)
    {
        Rigidbody targetRB = hand.GetComponent <Rigidbody>();
        Rigidbody needleRB = interactable.Interactors.Needle.Rigidbody;

        if (targetRB == null || needleRB == null)
        {
            throw new System.Exception("Both parties did not have rigidbody");
        }

        LuerlockItemConnection conn = interactable.gameObject.AddComponent <LuerlockItemConnection>();

        conn.Connector    = connector;
        conn.connectedRB  = needleRB;
        conn.interactable = interactable;

        Joint joint = JointConfiguration.AddJoint(targetRB.gameObject, needleRB.mass);

        joint.connectedBody = needleRB;

        conn.joint = joint;

        JointBreakSubscription.Subscribe(hand.gameObject, conn.JointBreak);

        return(conn);
    }
コード例 #2
0
    public static void GrabNeedleWhenAttachedItemIsGrabbed(ItemConnector connector, Transform target, Interactable addTo)
    {
        Needle needle = addTo as Needle;

        if (needle == null)
        {
            throw new System.Exception("Needle is null");
        }

        Interactable otherItem = needle.Connector.AttachedInteractable;

        Hand otherHand = Hand.GrabbingHand(otherItem);

        otherHand.Connector.Connection.Remove();

        HandSmoother smooth     = target.GetComponent <Hand>().Smooth;
        Transform    handOffset = smooth?.transform;

        target = handOffset ?? target;

        connector.Connection = ItemConnection.AddJointConnection(connector, target, addTo);
        smooth?.DisableInitMode();

        otherHand.InteractWith(otherItem, false);
    }
コード例 #3
0
        /// <summary>
        /// Update item in SharePoint.
        /// </summary>
        /// <returns>
        /// The result of command.
        /// </returns>
        public virtual EntityProperties Update()
        {
            var connector           = new ItemConnector(this.Context, this.WebUrl);
            EntityProperties result = connector.UpdateItem(this.Properties, this.ListName);

            FillProperty(result);

            return(result);
        }
コード例 #4
0
    public static ChildConnection Configuration(ItemConnector connector, Transform target, Interactable addTo)
    {
        ChildConnection conn = addTo.gameObject.AddComponent <ChildConnection>();

        conn.Connector = connector;
        conn.target    = target.transform;

        conn.Init();

        return(conn);
    }
コード例 #5
0
    public static LuerlockItemConnection Configuration(ItemConnector connector, Transform hand, Interactable interactable)
    {
        if (interactable.State == InteractState.LuerlockAttached)
        {
            return(LuerlockConfiguration(connector, hand, interactable));
        }
        else if (interactable.State == InteractState.NeedleAttached)
        {
            return(NeedleConfiguration(connector, hand, interactable));
        }

        throw new Exception("No such configuration type for InteractState");
    }
コード例 #6
0
    public static LuerlockLooseItemConnection LuerlockConfiguration(ItemConnector connector, Transform hand, Interactable interactable)
    {
        LuerlockLooseItemConnection conn = interactable.gameObject.AddComponent <LuerlockLooseItemConnection>();

        conn.Connector    = connector;
        conn.interactable = interactable;
        conn.hand         = hand.GetComponent <Hand>();
        conn.parentItem   = interactable.Interactors.LuerlockPair.Value;
        conn.startLocal   = interactable.transform.localPosition;
        conn.state        = InteractState.LuerlockAttached;

        return(conn);
    }
コード例 #7
0
    public static JointConnection Configuration(ItemConnector connector, Transform target, Interactable addTo)
    {
        NullCheck.Check(connector, target, addTo);

        Rigidbody targetRB = GetTargetRigidbody(target);

        JointConnection conn = addTo.gameObject.AddComponent <JointConnection>();

        conn.Connector       = connector;
        conn.target          = targetRB;
        conn.transformTarget = target;

        conn.SetJoint();

        return(conn);
    }
コード例 #8
0
        public void InsertItem()
        {
            ItemConnector     itemCn = new ItemConnector();
            CategoryConnector CateCn = new CategoryConnector();

            CateCn.InsertCategory("books", 4);
            itemCn.InsertItem("1231231", "hello", "books");
            Item item1 = itemCn.SelectItem("1231231");


            Assert.AreEqual("books", item1.ItemCategory.CategoryName, "correct");
            Assert.AreEqual("1231231", item1.Barcode, "correct");
            Assert.AreEqual("hello", item1.ItemDescription, "correct");
            Assert.AreEqual(true, item1.Status, "correct");
            //Assert.AreEqual("book", item1.ItemCategory, "correct");
            itemCn.DeleteItem("1231231");
            CateCn.DeleteCategory("books");
            Item item2 = itemCn.SelectItem("1231231");

            Assert.AreEqual(null, item2.Barcode, "correct");
        }
コード例 #9
0
    // Verify for Luerlock/Needle
    public static void GrabLuerlockWhenAttachedItemsAreGrabbed(ItemConnector connector, Transform target, Interactable addTo)
    {
        LuerlockAdapter luerlock = addTo as LuerlockAdapter;

        if (luerlock == null)
        {
            throw new System.Exception("Luerlock is null");
        }

        Interactable otherItem;

        if (luerlock.LeftConnector.HasAttachedObject && luerlock.LeftConnector.AttachedInteractable.State == InteractState.Grabbed)
        {
            otherItem = luerlock.LeftConnector.AttachedInteractable;
        }
        else if (luerlock.RightConnector.HasAttachedObject && luerlock.RightConnector.AttachedInteractable.State == InteractState.Grabbed)
        {
            otherItem = luerlock.RightConnector.AttachedInteractable;
        }
        else
        {
            Logger.Error("Could not find the other grabbed item");
            return;
        }

        Hand otherHand = Hand.GrabbingHand(otherItem);

        otherHand.Connector.Connection.Remove();

        HandSmoother smooth     = target.GetComponent <Hand>().Smooth;
        Transform    handOffset = smooth.transform;

        target = handOffset ?? target;

        connector.Connection = ItemConnection.AddJointConnection(connector, target, addTo);
        smooth?.DisableInitMode();

        otherHand.InteractWith(otherItem, false);
    }
コード例 #10
0
    void Start()
    {
        if (!connector)
        {
            Debug.LogError("Connector prefab for " + name + " not set");
        }

        connector             = Instantiate(connector);
        connectorData         = connector.GetComponent <ItemConnector>();
        connectorData.station = this;

        if (!connector)
        {
            Debug.LogError("Failed to create connector for " + name);
        }
        if (!connectorData)
        {
            Debug.LogError("Failed to get connector data for " + name);
        }

        rope = Instantiate(rope, transform);

        clamp = Support.FindRecursive(transform, "Clamp");
    }
コード例 #11
0
 public static void GrabItem(ItemConnector connector, Transform target, Interactable addTo)
 {
     connector.Connection = ItemConnection.AddJointConnection(connector, target, addTo);
 }
コード例 #12
0
 public static void GrabLuerlockAttachedItemWhenOtherLuerlockAttachedItemIsGrabbed(ItemConnector connector, Transform target, Interactable addTo)
 {
     connector.Connection = ItemConnection.AddLuerlockLooseItemConnection(connector, target, addTo);
 }
コード例 #13
0
 public static void GrabLuerlockAttachedItem(ItemConnector connector, Transform target, Interactable addTo)
 {
     connector.Connection = ItemConnection.AddLuerlockItemConnection(connector, target, addTo);
 }
コード例 #14
0
        /// <summary>
        /// Delete ListItem from SharePoint.
        /// </summary>
        public virtual void Delete()
        {
            var connector = new ItemConnector(this.Context, this.WebUrl);

            connector.DeleteItem(this.Properties, this.ListName);
        }
コード例 #15
0
 public static JointConnection AddJointConnection(ItemConnector connector, Transform target, Interactable addTo)
 {
     return(JointConnection.Configuration(connector, target, addTo));
 }
コード例 #16
0
 public static LuerlockLooseItemConnection AddLuerlockLooseItemConnection(ItemConnector connector, Transform target, Interactable addTo)
 {
     return(LuerlockLooseItemConnection.Configuration(connector, target, addTo));
 }