Esempio n. 1
0
 public void Add(IInspectable inspectable)
 {
     if (!objects.Contains(inspectable))
     {
         objects.Add(inspectable);
     }
 }
Esempio n. 2
0
        protected override void DrawOverride(ref bool isGameViewFocused)
        {
            if (Context.SelectedObject != _currentSelectedObject)
            {
                _currentInspectable =
                    (Context.SelectedObject as IInspectable)
                    ?? new DefaultInspectable(Context.SelectedObject, Context);

                _currentSelectedObject = Context.SelectedObject;
            }

            if (_currentInspectable != null)
            {
                ImGui.Text(_currentInspectable.Name);

                ImGui.Separator();

                ImGui.PushItemWidth(ImGui.GetWindowWidth() * 0.55f);

                _currentInspectable.DrawInspector();

                ImGui.PopItemWidth();
            }
            else
            {
                ImGui.Text("Nothing selected");
            }
        }
Esempio n. 3
0
        private List <IInspectable> FindInspectablesInView(AICharacter character)
        {
            List <IInspectable> inspectables = new List <IInspectable> ();

            RaycastHit[] castStar = Physics.SphereCastAll(character.transform.position, 165, Vector3.forward, 50);
            foreach (RaycastHit raycastHit in castStar)
            {
                if (raycastHit.collider.GetComponentInChildren <AICharacter>() != character)
                {
                    IInspectable inspectable = null;
                    if (raycastHit.collider.GetComponentInChildren <IInspectable>() != null)
                    {
                        inspectable = raycastHit.collider.GetComponentInChildren <IInspectable> ();
                    }
                    else if (raycastHit.collider.GetComponentInParent <IInspectable>() != null)
                    {
                        inspectable = raycastHit.collider.GetComponentInParent <IInspectable> ();
                    }
                    if (inspectable != null && !inspectables.Contains(inspectable))
                    {
                        inspectables.Add(inspectable);
                    }
                }
            }
            return(inspectables);
        }
Esempio n. 4
0
 void DrawInspectable(
     VisualElement outputVisualElement,
     IInspectable inspectable,
     IPropertyDrawer propertyDrawerToUse = null)
 {
     InspectorUtils.GatherInspectorContent(m_PropertyDrawerList, outputVisualElement, inspectable, TriggerInspectorUpdate, propertyDrawerToUse);
 }
        private static void QueryInspectableInterfaces(IntPtr punk, HashSet <COMInterfaceInstance> list)
        {
            if (punk == IntPtr.Zero)
            {
                return;
            }
            object       obj         = Marshal.GetObjectForIUnknown(punk);
            IInspectable inspectable = obj as IInspectable;

            if (inspectable != null)
            {
                IntPtr iids = IntPtr.Zero;
                try
                {
                    int iid_count;
                    inspectable.GetIids(out iid_count, out iids);
                    for (int i = 0; i < iid_count; ++i)
                    {
                        byte[] buffer = new byte[16];
                        Marshal.Copy(iids + i * 16, buffer, 0, buffer.Length);
                        list.Add(new COMInterfaceInstance(new Guid(buffer)));
                    }
                }
                catch
                {
                }
                finally
                {
                    if (iids != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(iids);
                    }
                }
            }
        }
Esempio n. 6
0
        public void Execute(AICharacter character, IGoal goal)
        {
            List <IInspectable> inspectables = FindInspectablesInView(character);

            inspectables.Sort(delegate(IInspectable x, IInspectable y) {
                return((character.Position - x.Position).magnitude.CompareTo((character.Position - y.Position).magnitude));
            });
            IInspectable inspectable = inspectables.Find(delegate(IInspectable obj) {
                return(!character.Knows(obj));
            });

            if (inspectable == null)
            {
                NavMeshAgent agent = character.gameObject.GetComponent <NavMeshAgent> ();
                NavMeshHit   navHit;

                do
                {
                    NavMesh.SamplePosition(UnityEngine.Random.insideUnitSphere * agent.speed + character.Position, out navHit, agent.speed, -1);
                } while (character.ExploredArea.Contains(navHit.position));

                character.AddGoal(new Goal(new List <IRequirement> ()
                {
                    new AtPosition(navHit.position)
                }, goal));
            }
            else
            {
                character.AddGoal(new Goal(new List <IRequirement> ()
                {
                    new Inspected(inspectable)
                }, goal));
            }
        }
        private bool TryGetConstructFromInspectable(IInspectable inspectable, out ConstructData data)
        {
            switch (inspectable)
            {
            case InspectableCoordinate inspectableCoordinate:
                if (_currentMap.TryGet <Construct>(inspectableCoordinate.Coordinate, out var construct))
                {
                    data = construct?.Data;
                    return(true);
                }
                else if (_currentMap.TryGet <Stronghold>(inspectableCoordinate.Coordinate, out var stronghold))
                {
                    data = stronghold?.Data?.ConstructData;
                    return(true);
                }

                data = default;
                return(false);

            case PaletteData <Preset <ConstructData> > paletteData:
                data = paletteData.Data.Data;
                return(true);

            default:
                data = default;
                return(false);
            }
        }
Esempio n. 8
0
        internal static void GatherInspectorContent(
            List <Type> propertyDrawerList,
            VisualElement outputVisualElement,
            IInspectable inspectable,
            Action propertyChangeCallback,
            List <IPropertyDrawer> allPropertyDrawerInstances,
            IPropertyDrawer propertyDrawerToUse = null)
        {
            var dataObject = inspectable.GetObjectToInspect();

            if (dataObject == null)
            {
                throw new NullReferenceException("DataObject returned by Inspectable is null!");
            }

            var properties = inspectable.GetType().GetProperties(BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (properties == null)
            {
                throw new NullReferenceException("PropertyInfos returned by Inspectable is null!");
            }

            foreach (var propertyInfo in properties)
            {
                var attribute = propertyInfo.GetCustomAttribute <InspectableAttribute>();
                if (attribute == null)
                {
                    continue;
                }

                var propertyType = propertyInfo.GetGetMethod(true).Invoke(inspectable, new object[] { }).GetType();

                var propertyDrawerInstance = propertyDrawerToUse;
                if (propertyDrawerInstance == null)
                {
                    if (IsPropertyTypeHandled(propertyDrawerList, propertyType, out var propertyDrawerTypeToUse))
                    {
                        propertyDrawerInstance = (IPropertyDrawer)Activator.CreateInstance(propertyDrawerTypeToUse);
                    }
                }

                if (propertyDrawerInstance != null)
                {
                    // Assign the inspector update delegate so any property drawer can trigger an inspector update if it needs it
                    propertyDrawerInstance.inspectorUpdateDelegate = propertyChangeCallback;
                    // Supply any required data to this particular kind of property drawer
                    inspectable.SupplyDataToPropertyDrawer(propertyDrawerInstance, propertyChangeCallback);
                    var propertyGUI = propertyDrawerInstance.DrawProperty(propertyInfo, dataObject, attribute);
                    outputVisualElement.Add(propertyGUI);
                    if (allPropertyDrawerInstances != null)
                    {
                        allPropertyDrawerInstances.Add(propertyDrawerInstance);
                    }
                }
            }
        }
Esempio n. 9
0
 public static unsafe Guid[] GetIids(this IInspectable inspectable)
 {
     Marshal.ThrowExceptionForHR(inspectable.GetIids(out var count, out var ptr));
     Guid[] iids = new Guid[count];
     for (int i = 0; i < count; i++)
     {
         iids[i] = ((Guid *)ptr)[i];
     }
     return(iids);
 }
Esempio n. 10
0
        public void DeselectAll()
        {
            if (_selectedObject is StateNode node)
            {
                node.Deselect();
            }

            _selectedObject = null;

            Repaint();
        }
        private void OnInspectableUpdate(IInspectable inspectable)
        {
            if (inspectable is InspectableCoordinate inspectableCoordinate)
            {
                _currentCoordinate = inspectableCoordinate.Coordinate;

                UpdateStrongholdData();
                UpdateVisibility(IsNeedToInspectCurrentCoordinate());
            }
            else
            {
                UpdateVisibility(false);
            }
        }
Esempio n. 12
0
 private static int GetTrustLevel(IntPtr thisPtr, IntPtr trustLevel)
 {
     try
     {
         InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
         IInspectable      callback = (IInspectable)shadow.Callback;
         // Write full trust
         Marshal.WriteInt32(trustLevel, (int)TrustLevel.FullTrust);
     }
     catch (Exception exception)
     {
         return((int)Result.GetResultFromException(exception));
     }
     return(Result.Ok.Code);
 }
Esempio n. 13
0
        public MainPage()
        {
            this.InitializeComponent();

            var setup = new ScriptRuntimeSetup();

            setup.HostType = typeof(DlrHost);
            setup.AddRubySetup();

            var runtime = Ruby.CreateRuntime(setup);

            this.engine = Ruby.GetEngine(runtime);
            this.scope  = engine.CreateScope();
            this.scope.SetVariable("Main", this);

            runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly);
            runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly);
            runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly);

            string outputText = @"
box = main.find_name('OutputBox')
p box.text_alignment
box.text_alignment = Windows::UI::Xaml::TextAlignment.Right
p box.text_alignment
";

            InputBox.IsSpellCheckEnabled  = false;
            OutputBox.IsSpellCheckEnabled = false;
            InputBox.Document.SetText(TextSetOptions.None, outputText);

            // http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx

            IInspectable insp = (IInspectable)InputBox.Document;
            string       winTypeName;

            insp.GetRuntimeClassName(out winTypeName);
            Guid[] iids;
            int    iidCount;

            insp.GetIids(out iidCount, out iids);

            // winTypeName = "Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IMapView`2<Windows.Foundation.Collections.IVector`1<String>, String>>";

            var  parts = ParseWindowsTypeName(winTypeName);
            Type type  = MakeWindowsType(parts);
            var  guid  = type.GetTypeInfo().GUID;
        }
        public void Draw(Rect windowRect, IInspectable inspectable)
        {
            var position = new Vector2(LeftPadding, TopPadding);
            var size     = new Vector2(Width, Height);

            var boxRect = new Rect(position, size);

            var previousColor = GUI.color;

            GUI.color = Color.gray;
            GUILayout.BeginArea(boxRect, GUI.skin.window);
            GUI.color = previousColor;

            DrawTitle();
            inspectable?.DrawControls();
            GUILayout.EndArea();
        }
Esempio n. 15
0
        protected override object CreateObject(IntPtr externalComObject, CreateObjectFlags flags)
        {
            IObjectReference objRef = ComWrappersSupport.GetObjectReferenceForInterface(externalComObject);

            if (objRef.TryAs <IInspectable.Vftbl>(out var inspectableRef) == 0)
            {
                IInspectable inspectable = new IInspectable(inspectableRef);

                string runtimeClassName = inspectable.GetRuntimeClassName(noThrow: true);
                if (runtimeClassName == null)
                {
                    // If the external IInspectable has not implemented GetRuntimeClassName,
                    // we use the Inspectable wrapper directly.
                    return(inspectable);
                }
                return(ComWrappersSupport.GetTypedRcwFactory(runtimeClassName)(inspectable));
            }
Esempio n. 16
0
        public void SelectTransition(TransitionConnection transition)
        {
            DeselectAll();

            for (int i = 0; i < _transitions.Count; i++)
            {
                var currentTransition = _transitions[i];

                if (currentTransition == transition)
                {
                    GUI.FocusControl(null);
                    _selectedObject = currentTransition;
                }
            }

            Repaint();
        }
Esempio n. 17
0
            private static unsafe int GetRuntimeClassName(IntPtr thisPtr, IntPtr *className)
            {
                try
                {
                    InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
                    IInspectable      callback = (IInspectable)shadow.Callback;
                    // Use the name of the callback class

                    string name = callback.GetType().FullName;
                    Win32.WinRTStrings.WindowsCreateString(name, (uint)name.Length, out IntPtr str);
                    *className = str;
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }
Esempio n. 18
0
        public void SelectNode(StateNode node)
        {
            DeselectAll();

            for (int i = 0; i < _nodes.Count; i++)
            {
                var currentNode = _nodes[i];

                if (currentNode == node)
                {
                    GUI.FocusControl(null);
                    _selectedObject = currentNode;
                    currentNode.Select();
                }
            }

            Repaint();
        }
Esempio n. 19
0
        private bool TryGetTileFromInspectable(IInspectable inspectable, out TileData data)
        {
            switch (inspectable)
            {
            case InspectableCoordinate inspectableCoordinate:
                var hasTile = _currentMap.TryGet <Tile>(inspectableCoordinate.Coordinate, out var tile);
                data = tile?.Data;

                return(hasTile);

            case PaletteData <Preset <TileData> > paletteData:
                data = paletteData.Data.Data;
                return(true);

            default:
                data = default;
                return(false);
            }
        }
        public static IAsyncOperation <UserConsentVerificationResult> RequestVerificationForWindowAsync(IntPtr hWnd, string Message)
        {
            //Use WinRT's GuidGenerator to get the correct guid
            var guid = GuidGenerator.CreateIID(typeof(IAsyncOperation <UserConsentVerificationResult>));

            //leverage winrt .As<> operator to cast winrt type to its interop interface
            IUserConsentVerifierInterop userConsentVerifierInterop = UserConsentVerifier.As <IUserConsentVerifierInterop>();

            //Handle marshalling the string to WinRT's HString
            var marshalStr = MarshalString.CreateMarshaler(Message);

            //Call the Interop api that pops a dialog, passing in the hWnd parameter
            IntPtr outPtr;

            userConsentVerifierInterop.RequestVerificationForWindowAsync(hWnd, MarshalString.GetAbi(marshalStr), ref guid, out outPtr);

            //Marshal the return object as an IAsyncOperation<>
            return((IAsyncOperation <UserConsentVerificationResult>)IInspectable.FromAbi(outPtr));
        }
Esempio n. 21
0
 // Update is called once per frame
 void Update()
 {
     if (debugModeManager.DebugModeActive)
     {
         IInspectable inspectable = LookForInspectable();
         if (inspectable != null)
         {
             if (inspectable.DeveloperComment != userInterfaceManager.DeveloperCommentText)
             {
                 userInterfaceManager.UpdateDeveloperComment(inspectable.DeveloperComment);
                 Debug.Log("IsLookingAtObject");
                 TargetObject.SetActive(true);
             }
         }
         else if (userInterfaceManager.DeveloperCommentPanelIsActive)
         {
             userInterfaceManager.HideDeveloperComment();
             TargetObject.SetActive(false);
         }
     }
 }
Esempio n. 22
0
            private static unsafe int GetIids(IntPtr thisPtr, int *iidCount, IntPtr *iids)
            {
                try
                {
                    InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
                    IInspectable      callback = (IInspectable)shadow.Callback;

                    ShadowContainer container = callback.Shadow;

                    int countGuids = container.Guids.Length;

                    // Copy GUIDs deduced from Callback
                    iids = (IntPtr *)Marshal.AllocCoTaskMem(IntPtr.Size * countGuids);
                    *iidCount = countGuids;

                    MemoryHelpers.CopyMemory((IntPtr)iids, new ReadOnlySpan <IntPtr>(container.Guids));
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }
 public static string Inspect(this IInspectable value)
 {
     return(JSON.Generate(value));
 }
Esempio n. 24
0
        public static object CreateRcw(IInspectable obj)
        {
            var pair = new KeyValuePair <K, V>(obj.As <Vftbl>());

            return((object)new global::System.Collections.Generic.KeyValuePair <K, V>(pair.Key, pair.Value));
        }
Esempio n. 25
0
 /// <summary>
 /// Return a pointer to the unmanaged version of this callback.
 /// </summary>
 /// <param name="callback">The callback.</param>
 /// <returns>A pointer to a shadow c++ callback</returns>
 public static IntPtr ToIntPtr(IInspectable callback)
 {
     return(ToCallbackPtr <IInspectable>(callback));
 }
Esempio n. 26
0
 /// <summary>
 /// Return a pointer to the unamanged version of this callback.
 /// </summary>
 /// <param name="callback">The callback.</param>
 /// <returns>A pointer to a shadow c++ callback</returns>
 public static IntPtr ToIntPtr(IInspectable callback)
 {
     return ToIntPtr<IInspectable>(callback);
 }
Esempio n. 27
0
 public static TrustLevel GetTrustLevel(this IInspectable inspectable)
 {
     Marshal.ThrowExceptionForHR(inspectable.GetTrustLevel(out var trustLevel));
     return(trustLevel);
 }
Esempio n. 28
0
 public static string GetRuntimeClassName(this IInspectable inspectable)
 {
     Marshal.ThrowExceptionForHR(inspectable.GetRuntimeClassName(out var name));
     return(name);
 }
Esempio n. 29
0
 public int Invoke(IToastNotification sender, IInspectable args)
 {
     return(InvokeCore(sender, args, (h, s, a) => h(s, null)));
 }
Esempio n. 30
0
	// Determins the Users movment and actions based on frame by frame input
	void Update () {

        Vector3 moveDir;
        Vector3 targetMoveAmount;
        //Camara Movment controls
        if (locked == true && targetMob != null)
        {
            transform.rotation = Quaternion.Euler(0,0,0);
            moveDir = (targetMob.position - transform.position).normalized;
            
            targetMoveAmount = moveDir * movementSpeed;
            moveAmount = Vector3.SmoothDamp(moveAmount, targetMoveAmount, ref smoothMoveVelocity, .2f);
            controller.Move(moveAmount);
        }
        else {
            moveDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
            targetMoveAmount = moveDir * movementSpeed;
            moveAmount = Vector3.SmoothDamp(moveAmount, targetMoveAmount, ref smoothMoveVelocity, .2f);
            controller.Move(moveAmount);
        }

       //Cross hair implementation
       /* Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Plane uiPlane = new Plane(Vector3.forward, ((Vector3.forward * 5)));
        float rayDistance;

        if (uiPlane.Raycast(ray, out rayDistance)) {
            Vector3 point = ray.GetPoint(rayDistance);
            crossHairs.position = point;
        }*/

        if (Input.GetMouseButton(1) && locked != true)
        {
                transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * Time.deltaTime * mouseSensitivityX);
        }

        if (Input.GetMouseButton(2))
        {
            verticalLookRotation += Input.GetAxis("Mouse Y") * Time.deltaTime * mouseSensitivityY;
            verticalLookRotation = Mathf.Clamp(verticalLookRotation, 30, 90);
            viewCamera.localEulerAngles = new Vector3(verticalLookRotation, viewCamera.localEulerAngles.y, viewCamera.localEulerAngles.z);
        }

        if (Input.GetMouseButtonUp(0))
        {
            foreach(GameObject DisplayItem in Displayobjects) { DisplayItem.SetActive(false); }
            RaycastHit lookHit = new RaycastHit();
            Ray lookRay = viewCamera.GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
            Debug.DrawRay(lookRay.origin, lookRay.direction, Color.green, 200f);
            if (Physics.Raycast(lookRay, out lookHit, 200f))
            {
                
                Debug.Log(lookHit.collider.gameObject.ToString() + "Locking on to this");
                currentlySelected = lookHit.collider.gameObject.GetComponent<IInspectable>();

                if (currentlySelected != null)
                {
                    selectionData = currentlySelected.BeInspected();
                    SimControls.UpdateSelection(selectionData);
                    StartCoroutine(UpdataSelectionData());
                }
                else {
                    currentlySelected = null;
                    selectionData = null;
                    SimControls.UpdateSelection(selectionData);
                }

                if (lookHit.collider.gameObject.GetComponent<LivingEntity>() == true)
                {
                    locked = true;

                    targetMob = lookHit.collider.gameObject.transform;

                    Displayobjects[0].SetActive(true);
                    Displayobjects[0].transform.localScale = targetMob.transform.localScale;
                    Displayobjects[0].GetComponent<Renderer>().material = targetMob.gameObject.GetComponent<Renderer>().material;
                    targetMob.GetComponent<LivingEntity>().OnDeath += onfllowingDeath;

                    transform.position = new Vector3(targetMob.position.x, transform.position.y, targetMob.position.z);
                    viewCamera.localEulerAngles = new Vector3(90, viewCamera.localEulerAngles.y, viewCamera.localEulerAngles.z);
                    transform.Rotate(Vector3.up);
                }
                else if (lookHit.collider.gameObject.GetComponent<AnimatEssence>() == true)
                {
                    Displayobjects[1].SetActive(true);
                }
                else if (lookHit.collider.gameObject.GetComponent<Terrain>() == true)
                {
                    Terrain currentTerrain = lookHit.collider.gameObject.GetComponent<Terrain>();
                    if (currentTerrain.isWater == true)
                    {
                        Displayobjects[2].SetActive(true);
                    }
                    else
                    {
                        Displayobjects[3].SetActive(true);
                    }
                }
                else if (lookHit.collider.gameObject.GetComponentInParent<PrimaryProducer>() == true)
                {
                    /*switch (lookHit.collider.gameObject.name) {
                        
                    }*/
                }
                else { locked = false; selectionData = null; }
            }
        }


        if (Input.GetKeyDown("p"))
        {
            TogglePause();
        }

        if (Input.GetKeyDown("-") || Input.GetAxis("Mouse ScrollWheel") > 0)
        {
            veiwheight -= 5;
            veiwheight = Mathf.Clamp(veiwheight, 10, 50);
            transform.position = new Vector3(transform.position.x, veiwheight, transform.position.z);
            //Camera.main.orthographicSize = veiwheight;
        }

        if (Input.GetKeyDown("+") || Input.GetAxis("Mouse ScrollWheel") < 0)
        {
            veiwheight += 5; ;
            veiwheight = Mathf.Clamp(veiwheight, 10, 50);
            transform.position = new Vector3(transform.position.x, veiwheight, transform.position.z);
            //Camera.main.orthographicSize = veiwheight;
        }

        if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0)
        {
            locked = false;
        }

    }
Esempio n. 31
0
 public int Invoke(IToastNotification sender, IInspectable args)
 {
     return(InvokeCore(sender, GetActivationString(args as IToastActivatedEventArgs), (h, s, a) => h(s, a)));
 }
Esempio n. 32
0
 public Inspect(IInspectable inspectable)
 {
     this.inspectable = inspectable;
 }