/// <summary> /// Activates/Uses an object in control/possession of a user /// If the item has the IUse interface on one of its components we use the object in our hand /// </summary> /// <param name="user"></param> /// <param name="attacked"></param> public void UseInteraction(IEntity user, IEntity used) { var useMsg = new UseInHandMessage(user, used); RaiseEvent(useMsg); if (useMsg.Handled) { return; } List <IUse> usables = used.GetAllComponents <IUse>().ToList(); //Try to use item on any components which have the interface for (var i = 0; i < usables.Count; i++) { if (usables[i].UseEntity(new UseEntityEventArgs { User = user })) //If an attackby returns a status completion we finish our attack { return; } } }
/// <summary> /// Activates/Uses an object in control/possession of a user /// If the item has the IUse interface on one of its components we use the object in our hand /// </summary> public void UseInteraction(IEntity user, IEntity used) { if (used.TryGetComponent <UseDelayComponent>(out var delayComponent)) { if (delayComponent.ActiveDelay) { return; } else { delayComponent.BeginDelay(); } } var useMsg = new UseInHandMessage(user, used); RaiseEvent(useMsg); if (useMsg.Handled) { return; } var uses = used.GetAllComponents <IUse>().ToList(); // Try to use item on any components which have the interface foreach (var use in uses) { if (use.UseEntity(new UseEntityEventArgs { User = user })) { // If a Use returns a status completion we finish our attack return; } } }