コード例 #1
0
    private bool ClientCheckUse(Ray ray, bool press)
    {
        RaycastHit hit;

        Facepunch.MonoBehaviour implementor;
        if (Physics.Raycast(ray, out hit, this.raycastLength, -201523205))
        {
            UnityEngine.MonoBehaviour behaviour2;
            NetEntityID      yid;
            NetEntityID.Kind kind;
            Transform        component = hit.transform;
            for (Transform transform2 = component.parent; (((int)(kind = NetEntityID.Of(component, out yid, out behaviour2))) == 0) && (transform2 != null); transform2 = component.parent)
            {
                component = transform2;
            }
            if (((int)kind) == 0)
            {
                implementor = null;
            }
            else
            {
                Contextual contextual;
                if (Contextual.ContextOf(behaviour2, out contextual))
                {
                    implementor = contextual.implementor;
                    if (press)
                    {
                        Context.BeginQuery(contextual);
                    }
                }
                else
                {
                    implementor = null;
                }
            }
        }
        else
        {
            implementor = null;
        }
        if (implementor != this.lastUseHighlight)
        {
            this.lastUseHighlight = implementor;
            if (implementor != null)
            {
                IContextRequestableText text = implementor as IContextRequestableText;
                if (text != null)
                {
                    RPOS.UseHoverTextSet(base.controllable, text);
                }
                else
                {
                    RPOS.UseHoverTextSet(implementor.name);
                }
            }
            else
            {
                RPOS.UseHoverTextClear();
            }
        }
        return((bool)implementor);
    }
コード例 #2
0
ファイル: ContextProbe.cs プロジェクト: sknchan/LegacyRust
    private bool ClientCheckUse(Ray ray, bool press)
    {
        RaycastHit raycastHit;

        Facepunch.MonoBehaviour   monoBehaviour;
        UnityEngine.MonoBehaviour monoBehaviour1;
        NetEntityID netEntityID;

        NetEntityID.Kind kind;
        Contextual       contextual;

        if (!Physics.Raycast(ray, out raycastHit, this.raycastLength, -201523205))
        {
            monoBehaviour = null;
        }
        else
        {
            Transform transforms  = raycastHit.transform;
            Transform transforms1 = transforms.parent;
            while (true)
            {
                NetEntityID.Kind kind1 = NetEntityID.Of(transforms, out netEntityID, out monoBehaviour1);
                kind = kind1;
                if ((int)kind1 != 0 || !transforms1)
                {
                    break;
                }
                transforms  = transforms1;
                transforms1 = transforms.parent;
            }
            if ((int)kind == 0)
            {
                monoBehaviour = null;
            }
            else if (!Contextual.ContextOf(monoBehaviour1, out contextual))
            {
                monoBehaviour = null;
            }
            else
            {
                monoBehaviour = contextual.implementor;
                if (press)
                {
                    Context.BeginQuery(contextual);
                }
            }
        }
        if (monoBehaviour != this.lastUseHighlight)
        {
            this.lastUseHighlight = monoBehaviour;
            if (!monoBehaviour)
            {
                RPOS.UseHoverTextClear();
            }
            else
            {
                IContextRequestableText contextRequestableText = monoBehaviour as IContextRequestableText;
                if (contextRequestableText == null)
                {
                    RPOS.UseHoverTextSet(monoBehaviour.name);
                }
                else
                {
                    RPOS.UseHoverTextSet(base.controllable, contextRequestableText);
                }
            }
        }
        return(monoBehaviour);
    }