/// <summary> /// Triggers while trying to examine an activator to see if it's used /// </summary> private void OnCreatorExamine(EntityUid uid, GuardianCreatorComponent component, ExaminedEvent args) { if (component.Used) { args.PushMarkup(Loc.GetString("guardian-activator-empty-examine")); } }
private void OnCreatorInteract(EntityUid uid, GuardianCreatorComponent component, AfterInteractEvent args) { if (args.Handled || args.Target == null || !args.CanReach) { return; } args.Handled = true; UseCreator(args.User, args.Target.Value, component); }
/// <summary> /// Adds the guardian host component to the user and spawns the guardian inside said component /// </summary> private void OnCreatorUse(EntityUid uid, GuardianCreatorComponent component, UseInHandEvent args) { if (args.Handled) { return; } args.Handled = true; UseCreator(args.User, args.User, component); }
private void UseCreator(EntityUid user, EntityUid target, GuardianCreatorComponent component) { if (component.Used) { _popupSystem.PopupEntity(Loc.GetString("guardian-activator-empty-invalid-creation"), user, Filter.Entities(user)); return; } // Can only inject things with the component... if (!HasComp <CanHostGuardianComponent>(target)) { _popupSystem.PopupEntity(Loc.GetString("guardian-activator-invalid-target"), user, Filter.Entities(user)); return; } // If user is already a host don't duplicate. if (HasComp <GuardianHostComponent>(target)) { _popupSystem.PopupEntity(Loc.GetString("guardian-already-present-invalid-creation"), user, Filter.Entities(user)); return; } // Can't work without actions EntityManager.EnsureComponent <ServerActionsComponent>(target); if (component.Injecting) { return; } component.Injecting = true; _doAfterSystem.DoAfter(new DoAfterEventArgs(user, component.InjectionDelay, target: target) { BroadcastFinishedEvent = new GuardianCreatorInjectedEvent(user, target, component), BroadcastCancelledEvent = new GuardianCreatorInjectCancelledEvent(target, component), BreakOnTargetMove = true, BreakOnUserMove = true, }); }
public GuardianCreatorInjectCancelledEvent(EntityUid target, GuardianCreatorComponent component) { Target = target; Component = component; }
public GuardianCreatorInjectedEvent(EntityUid user, EntityUid target, GuardianCreatorComponent component) { User = user; Target = target; Component = component; }