/// <summary> /// Uses an empty hand on an entity /// Finds components with the AttackHand interface and calls their function /// </summary> public void Interaction(IEntity user, IEntity attacked) { var message = new AttackHandMessage(user, attacked); RaiseEvent(message); if (message.Handled) { return; } var attackHands = attacked.GetAllComponents <IAttackHand>().ToList(); var attackHandEventArgs = new AttackHandEventArgs { User = user }; foreach (var attackHand in attackHands) { if (attackHand.AttackHand(attackHandEventArgs)) { // If an AttackHand returns a status completion we finish our attack return; } } // Else we run Activate. InteractionActivate(user, attacked); }
/// <summary> /// Uses an empty hand on an entity /// Finds components with the InteractHand interface and calls their function /// </summary> public void Interaction(IEntity user, IEntity attacked) { var message = new AttackHandMessage(user, attacked); RaiseLocalEvent(message); if (message.Handled) { return; } var attackHands = attacked.GetAllComponents <IInteractHand>().ToList(); var attackHandEventArgs = new InteractHandEventArgs { User = user, Target = attacked }; // all attackHands should only fire when in range / unbostructed if (InteractionChecks.InRangeUnobstructed(attackHandEventArgs)) { foreach (var attackHand in attackHands) { if (attackHand.InteractHand(attackHandEventArgs)) { // If an InteractHand returns a status completion we finish our attack return; } } } // Else we run Activate. InteractionActivate(user, attacked); }
/// <summary> /// Uses an empty hand on an entity /// Finds interactable components with the Attackhand interface and calls their function /// </summary> /// <param name="user"></param> /// <param name="attacked"></param> public void Interaction(IEntity user, IEntity attacked) { var message = new AttackHandMessage(user, attacked); RaiseEvent(message); if (message.Handled) { return; } List <IAttackHand> interactables = attacked.GetAllComponents <IAttackHand>().ToList(); for (var i = 0; i < interactables.Count; i++) { if (interactables[i].AttackHand(new AttackHandEventArgs { User = user })) //If an attackby returns a status completion we finish our attack { return; } } //Else check damage component to see if we damage if not attackby, and if so can we attack object }
private void HandleAttackHand(EntityUid uid, BuckleComponent component, AttackHandMessage args) { args.Handled = component.TryUnbuckle(args.User); }