private async Task <bool> Valid(IEntity user, IEntity utilizing, bool anchoring) { if (!Owner.HasComponent <IPhysBody>()) { return(false); } BaseAnchoredAttemptEvent attempt = anchoring ? new AnchorAttemptEvent(user, utilizing) : new UnanchorAttemptEvent(user, utilizing); // Need to cast the event or it will be raised as BaseAnchoredAttemptEvent. if (anchoring) { Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, (AnchorAttemptEvent)attempt, false); } else { Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, (UnanchorAttemptEvent)attempt, false); } if (attempt.Cancelled) { return(false); } return(utilizing.TryGetComponent(out ToolComponent? tool) && await tool.UseTool(user, Owner, 0.5f + attempt.Delay, Tool)); }
private async Task <bool> Valid(IEntity user, IEntity utilizing, bool anchoring) { if (!Owner.HasComponent <IPhysBody>()) { return(false); } BaseAnchoredAttemptEvent attempt = anchoring ? new AnchorAttemptEvent(user, utilizing) : new UnanchorAttemptEvent(user, utilizing); Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, attempt, false); if (attempt.Cancelled) { return(false); } return(utilizing.TryGetComponent(out ToolComponent? tool) && await tool.UseTool(user, Owner, 0.5f, Tool)); }