/// <summary> /// Handles an event from the EyeX Engine. /// </summary> /// <param name="event_">Event to be handled.</param> protected override void HandleEvent(InteractionEvent event_) { if (!RunOnMainThread(new Action(() => HandleEventInner(event_)))) { event_.Dispose(); } }
public string GetName(InteractionEvent interactionEvent) { return("Dispose Content"); }
private static void OnDown(InteractionEvent arg) { sprite.Scale.X = 0.3f; sprite.Scale.Y = 0.3f; }
/** * <summary>Gets all interactions attached to the game object from any source</summary> */ public static List <Interaction> GetAllInteractions(this GameObject gameObject, InteractionEvent e) { return(( // Collect interaction creators gameObject.GetComponents <InteractionCreator>() .Select(creator => creator.Generate(e)) .Aggregate <List <Interaction>, IEnumerable <Interaction> >(new List <Interaction>(), (a, b) => a.Concat(b)) // Collect interactions .Concat(gameObject.GetComponents <Interaction>()) ).ToList()); }
/// <summary> /// Invokes the event handler function. /// </summary> /// <param name="event">Event object.</param> public void HandleEvent(InteractionEvent event_) { if (_eventHandler != null) { _eventHandler(_id, event_); } }
/// <summary> /// Override this event handler to handle the events /// </summary> /// <param name="interactorId">The id of the interactor</param> /// <param name="event">The interaction event</param> protected abstract void OnEyeXEvent(string interactorId, InteractionEvent event_);
private void HandleEvent(string interactorid, InteractionEvent event_) { // Note that this method is called on a worker thread, so we MAY NOT access any game objects from here. // Therefore, we store the data in a variable and read from the variable in the Update() method. foreach (var behavior in event_.Behaviors) { if (behavior.BehaviorType == InteractionBehaviorType.GazePointData) { GazePointDataEventParams eventParams; if (behavior.TryGetGazePointDataEventParams(out eventParams)) { Last = new EyeXGazePoint((float)eventParams.X, (float)eventParams.Y, eventParams.Timestamp); } } else if (behavior.BehaviorType == InteractionBehaviorType.FixationData) { FixationDataEventParams fixationEventParams; if (behavior.TryGetFixationDataEventParams(out fixationEventParams)) { if (fixationEventParams.EventType == FixationDataEventType.Begin) { FixationCount++; } else if (fixationEventParams.EventType == FixationDataEventType.End) { // Do nothing right now } else { Last = new EyeXGazePoint((float)fixationEventParams.X, (float)fixationEventParams.Y, fixationEventParams.Timestamp); } } } } }
public Sprite GetIcon(InteractionEvent interactionEvent) { return(icon); }
public static bool RangeCheck(InteractionEvent interactionEvent) { Vector3 point = interactionEvent.Point; // Ignore range when there is no point if (point.sqrMagnitude < 0.001) { return(true); } var interactionRangeLimit = interactionEvent.Source.GetComponentInTree <IInteractionRangeLimit>(out IGameObjectProvider provider); if (interactionRangeLimit == null) { // No range limit return(true); } //Block interaction when point is on top of wall or above. if (IsWallTop(point, 0.1f)) { return(false); } Vector3 sourcePosition; if (provider is IInteractionOriginProvider origin) { // Object has a custom interaction origin sourcePosition = origin.InteractionOrigin; } else { // Use default game object origin sourcePosition = provider.GameObject.transform.position; } RangeLimit range = interactionEvent.Source.GetRange(); if (range.IsInRange(sourcePosition, point)) { return(true); } Collider targetCollider = interactionEvent.Target.GetComponent <Collider>(); if (targetCollider != null) { Vector3 closestPointOnCollider = targetCollider.ClosestPointOnBounds(sourcePosition); return(range.IsInRange(sourcePosition, closestPointOnCollider)); } Rigidbody targetRigidBody = interactionEvent.Target.GetComponent <Rigidbody>(); if (targetRigidBody != null) { Vector3 closestPointOnRigidBody = targetRigidBody.ClosestPointOnBounds(sourcePosition); return(range.IsInRange(sourcePosition, closestPointOnRigidBody)); } return(false); }
public bool HandleEvent(InteractionEvent event_) { if (string.Equals(Id, event_.InteractorId)) { var eventBehaviors = event_.Behaviors; foreach (var behavior in _behaviors) { behavior.HandleEvent(Control, eventBehaviors); } foreach (var eventBehavior in eventBehaviors) { eventBehavior.Dispose(); } return true; } else { return false; } }
public string GetName(InteractionEvent interactionEvent) { return("View " + containerDescriptor.containerName); }
public bool Handle(InteractionEvent e) { e.sender.GetComponent <Hands>().Pickup(gameObject); return(true); }
public string GetName(InteractionEvent interactionEvent) { return(((IGameObjectProvider)interactionEvent.Target).GameObject.GetComponent <Animator>().GetBool(OpenId) ? "Close" : "Open"); }
public bool Update(InteractionEvent interactionEvent, InteractionReference reference) { throw new System.NotImplementedException(); }
public override IEnumerator Handle(InteractionEvent e) { if (e.sender == null) { Debug.LogWarning($"Tried to paint null on ({name})"); yield break; } Painter painter = e.sender.GetComponent <Painter>(); if (painter == null) { Debug.LogError($"Tried to paint with {e.sender} without a Painter component.)"); yield break; } PlayerInteractor playerInteractor = e.player.GetComponent <PlayerInteractor>(); if (playerInteractor == null) { Debug.LogError($"Received event from player {e.player} without a PlayerInteractor component."); yield break; } var playerHands = e.player.GetComponent <Hands>(); if (playerHands == null) { Debug.LogWarning($"Player painting with object ({e.sender.name}) does not have a hands component"); yield break; } NetworkInteractionSpawner networkInteractionSpawner = e.player.GetComponent <NetworkInteractionSpawner>(); if (networkInteractionSpawner == null) { Debug.LogError($"Received paint event from player {e.player} without a NetworkInteractionSpawner component."); yield break; } var inventoryUi = FindObjectOfType <UIInventory>(); while (e.runWhile.Invoke(e)) { float remainingSupply = painter.GetRemainingSupplyPercentage(); //Update paint location if (!playerInteractor.GetWorldData(out var hit)) { yield break; } //Stop painting if surface no longer applicable InteractionReceiver receiver = hit.transform.GetComponent <InteractionReceiver>(); if (receiver == null || !receiver.IsListeningForContinuous(this)) { yield break; } //Update remaining supply bar on painter if (inventoryUi) { inventoryUi.SetHeldItemSupply(remainingSupply); } //Decrease supply and spawn new decal. Set to be slightly above collider to avoid clipping. playerInteractor.CmdDecreaseSupplyOfItem(painter.gameObject); Vector3 position = hit.point + hit.normal * 0.01f; Quaternion rotation = Quaternion.FromToRotation(Vector3.back, hit.normal); networkInteractionSpawner.CmdSpawnPainterDecal(painter.Properties.name, position, rotation); if (remainingSupply <= 0) { playerHands.DestroyItemInHand(); yield break; } yield return(new WaitForSeconds(0.01f)); } }
public IClientInteraction CreateClient(InteractionEvent interactionEvent) { return(null); }
public void HandleEvent(InteractionEvent event_) { var eventBehaviors = event_.Behaviors; foreach (var eventBehavior in eventBehaviors) { foreach (var behavior in _behaviors) { behavior.HandleEvent(Element, eventBehaviors); } eventBehavior.Dispose(); } foreach (var eventBehavior in eventBehaviors) { eventBehavior.Dispose(); } }
/// <summary> /// Handles an event from the EyeX Engine. /// Note that this method is called from a worker thread, so it may not access any WPF objects. /// </summary> /// <param name="@event">Event.</param> private void HandleEvent(InteractionEvent @event) { var interactorId = @event.InteractorId; foreach (var behavior in @event.Behaviors) { if (behavior.BehaviorType == InteractionBehaviorType.GazeAware) { GazeAwareEventParams r; if (behavior.TryGetGazeAwareEventParams(out r)) { Console.WriteLine(interactorId + " " + r.HasGaze); // marshal the event to the UI thread, where WPF objects may be accessed. this.Dispatcher.BeginInvoke(new Action<string, bool>(OnGaze), interactorId, r.HasGaze != EyeXBoolean.False); } } else if (behavior.BehaviorType == InteractionBehaviorType.GazePointData) { GazePointDataEventParams r; if (behavior.TryGetGazePointDataEventParams(out r)) { trackGaze(new Point(r.X, r.Y), paint, 200); //TODO Set keyhole size dynamically based on how bad the calibration is. this.Dispatcher.BeginInvoke(new Action(() => drawElipseOnCanvas(gaze, 100))); } } } }
private void MixerInteract(InteractionEvent interactionEvent, InteractionReference arg2) { SetActive(!mixerActive); }
protected bool HandleDataStreamEvent(InteractionEvent event_) { lock (_dataStreams) { var stream = _dataStreams.FirstOrDefault(x => string.Equals(event_.InteractorId, x.Id)); if (stream != null) { stream.HandleEvent(event_); return true; } return false; } }
public void CmdConstruct(int index, NetworkConnectionToClient client = null) { // Check if sending player is holding if (client != null && client.identity.GetComponent <Hands>().ItemInHand.gameObject != gameObject) { return; } Construction construction = constructions[index]; // TileDefinition tile = selectedTile.Tile; IInteraction interaction; if (construction.ObjectToConstruct) { interaction = new ItemConstructionInteraction { ObjectToConstruct = construction.ObjectToConstruct, LoadingBarPrefab = loadingBarPrefab, Delay = construction.buildTime, ObstacleMask = obstacleMask }; } /* * if (construction.turf) * { * interaction = new TurfConstructionInteraction * { * ObjectToConstruct = construction.turf, * ConstructIfTurf = construction.constructOverTurf, * LoadingBarPrefab = loadingBarPrefab, * Delay = construction.buildTime, * ObstacleMask = obstacleMask * }; * } * else if (construction.fixture) * { * interaction = new FixtureConstructionInteraction * { * Fixture = construction.fixture, * TileLayer = construction.tileLayer, * WallLayer = construction.wallLayer, * FloorLayer = construction.floorLayer, * FixtureType = construction.type, * LoadingBarPrefab = loadingBarPrefab, * Delay = construction.buildTime, * ObstacleMask = obstacleMask * }; * } */ else { Debug.LogError("Construction does not have a turf or fixture to construct"); return; } // Add material requirement interaction = new ItemRequirement(interaction, item.ItemId, construction.amount); var source = GetComponent <IInteractionSource>(); // Create interaction data var @event = new InteractionEvent(source, new InteractionTargetGameObject(selectedTile.gameObject), selectedTile.transform.position); // Check if interaction is possible if (!interaction.CanInteract(@event)) { return; } // Start interaction source.Interact(@event, interaction); }
protected override void callHandler(InteractionEvent interaction, ActionEvent action) { InteractionBehaviour[] behaviours = gameObject.GetComponents<InteractionBehaviour>() as InteractionBehaviour[]; foreach(InteractionBehaviour ib in behaviours){ interaction(ib); } base.callHandler(interaction, action); }
private bool CanTake(InteractionEvent interactionEvent) { Hands hands = (Hands)interactionEvent.Source.GetRootSource(); return(((IGameObjectProvider)interactionEvent.Target).GameObject.GetComponent <Container>().GetItem(0) != null); }
private void HandleEventInner(InteractionEvent event_) { using (event_) { try { if (!HandleDataStreamEvent(event_)) { foreach (var map in GetBehaviorMaps()) { if (map.HandleEvent(event_)) { break; } } } } catch (InteractionApiException ex) { Debug.WriteLine("EyeX event handler failed: " + ex.Message); } } }
public List <Interaction> Generate(InteractionEvent ev) => transform.parent.gameObject.GetAllInteractions(ev);
public InteractionManager(GameManager gameManager, InteractionEvent interactionEvent) { this.gameManager = gameManager; this.interactionEvent = interactionEvent; this.setInteraction(); }
public string GetName(InteractionEvent interactionEvent) { return("Spray"); }
public override void Cancel(InteractionEvent interactionEvent, InteractionReference reference) { }
public bool HandleEvent(InteractionEvent event_) { foreach (var interactor in _interactors) { if (interactor.HandleEvent(event_)) { return true; } } return false; }
private void ActiveInteract(InteractionEvent interactionEvent, InteractionReference arg2) { deviceActive = !deviceActive; }
public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent) { return(new IInteraction[] { new HonkInteraction() }); }
public void Cancel(InteractionEvent interactionEvent, InteractionReference reference) { throw new System.NotImplementedException(); }
public string GetName(InteractionEvent interactionEvent) { return("Honk"); }
public string GetName(InteractionEvent interactionEvent) { return("Pick up"); }
private bool CanDispenseCup(InteractionEvent interactionEvent) { return(NumberOfCups > 0 && interactionEvent.GetSourceItem() == null && interactionEvent.Source.GetHands() != null); }
public void HandleEvent(InteractionEvent event_) { if (string.Equals(Id, event_.InteractorId)) { var eventBehaviors = event_.Behaviors as Tobii.EyeX.Client.Behavior[] ?? event_.Behaviors.ToArray(); foreach (var behavior in _behaviors) { behavior.HandleEvent(Element, eventBehaviors); } foreach (var eventBehavior in eventBehaviors) { eventBehavior.Dispose(); } } }
public virtual IInteraction[] GenerateInteractions(InteractionEvent interactionEvent) { return(new IInteraction[] { new PickupInteraction { icon = sprite } }); }
public void onclickGround(InteractionEvent interactionEvent) { move(interactionEvent.targetPoint); }
public virtual string GetName(InteractionEvent interactionEvent) { return("Store in " + containerDescriptor.containerName); }
private void HandleEvent(InteractionEvent event_) { // NOTE: this method is called from a worker thread, so it must not access any game objects. try { // Route the event to the appropriate interactor, if any. var interactorId = event_.InteractorId; var interactor = GetInteractor(interactorId); if (interactor != null) { interactor.HandleEvent(event_); } else { var globalInteractor = GetGlobalInteractor(interactorId); if (globalInteractor != null) { globalInteractor.HandleEvent(event_); } } } catch (InteractionApiException ex) { print("EyeX event handler failed: " + ex.Message); } }
public override string GetName(InteractionEvent interactionEvent) { return("Construct " + ObjectToConstruct.nameString); }
protected virtual void HandleEvent(InteractionEvent event_) { using (event_) { // If you derive from this class, make sure to call HandleDataStreamEvent. HandleDataStreamEvent(event_); } }
public void OnTouched(InteractionEvent data) { onPressed.Invoke(); }
/// <summary> /// Invokes the event handler function. /// </summary> /// <param name="event_">Event object.</param> public void HandleEvent(InteractionEvent event_) { var eventBehaviors = event_.Behaviors; foreach (var behavior in EyeXBehaviors) { behavior.HandleEvent(_id, eventBehaviors); } foreach (var eventBehavior in eventBehaviors) { eventBehavior.Dispose(); } }
private void PumpInteract(InteractionEvent interactionEvent, InteractionReference arg2) { SetActive(!pumpActive); }
void onMouseEnterUnit(InteractionEvent e) { if (skillSelector.skillSelectMode == SkillSelectMode.Ground || skillSelector.skillSelectMode == SkillSelectMode.Unit) { Cursor.SetCursor(m_select, Vector2.zero, CursorMode.ForceSoftware); } else { if (PlayerManager.isOpponent(PlayerManager.currentPlayer, e.targetUnit.player)) { Cursor.SetCursor(m_attack, Vector2.zero, CursorMode.ForceSoftware); } else { Cursor.SetCursor(m_pointer, Vector2.zero, CursorMode.ForceSoftware); } } // Renderer renderer = e.target.GetComponentInChildren<Renderer>(); // Debug.Log("over:"+renderer.material.shader.name); // if (renderer) // { // hoveredTargetShader = renderer.material.shader; // renderer.material.shader = rimLight; // } }
public override string GetName(InteractionEvent interactionEvent) { return(Verb); }
protected virtual void callHandler(InteractionEvent interaction, ActionEvent action) { foreach (Frame b in DirectChildren) { if(b == null) continue; if (b.checkMouseOverElement()) { if (action != null) { action(b); } var behaviours = b.GetComponents<InteractionBehaviour>() as InteractionBehaviour[]; if (behaviours != null) { foreach (var ib in behaviours) { interaction(ib); } } } else { b.resetElement(); } } }
private void HandleEventInner(InteractionEvent event_) { using (event_) { try { if (!HandleDataStreamEvent(event_)) { var interactorId = event_.InteractorId; var interactor = GetInteractor(interactorId); if (interactor != null) { interactor.HandleEvent(event_); } } } catch (InteractionApiException ex) { Debug.WriteLine("EyeX event handler failed: " + ex.Message); } } }