protected override void GetData(IEntity user, ExpendableLightComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } if (component.CurrentState == ExpendableLightState.BrandNew) { data.Text = "Activate"; data.Visibility = VerbVisibility.Visible; } else { data.Visibility = VerbVisibility.Invisible; } }
protected override void GetData(IEntity user, StunbatonComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } if (component.Cell == null) { data.Text = "Eject cell (cell missing)"; data.Visibility = VerbVisibility.Disabled; } else { data.Text = "Eject cell"; } }
protected override void GetData(IEntity user, ServerBatteryBarrelComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user) || !component._powerCellRemovable) { data.Visibility = VerbVisibility.Invisible; return; } if (component.PowerCell == null) { data.Text = Loc.GetString("Eject cell (cell missing)"); data.Visibility = VerbVisibility.Disabled; } else { data.Text = Loc.GetString("Eject cell"); } }
protected override void GetData(IEntity user, BaseCharger component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } if (component._container.ContainedEntity == null) { data.Text = Loc.GetString("Eject"); data.Visibility = VerbVisibility.Disabled; return; } var containerItemName = Loc.GetString(component._container.ContainedEntity.Name); data.Text = Loc.GetString("Eject {0}", containerItemName); }
private void AddVerbs(EntityUid uid, SurveillanceCameraComponent component, GetVerbsEvent <AlternativeVerb> verbs) { if (!_actionBlocker.CanInteract(verbs.User, uid)) { return; } if (component.NameSet && component.NetworkSet) { return; } AlternativeVerb verb = new(); verb.Text = Loc.GetString("surveillance-camera-setup"); verb.Act = () => OpenSetupInterface(uid, verbs.User, component); verbs.Verbs.Add(verb); }
protected override void GetData(IEntity user, RevolverBarrelComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } data.Text = Loc.GetString("Spin"); if (component.Capacity <= 1) { data.Visibility = VerbVisibility.Invisible; return; } data.Visibility = component.ShotsLeft > 0 ? VerbVisibility.Visible : VerbVisibility.Disabled; data.IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png"; }
public void Activate(ActivateEventArgs eventArgs) { if (!eventArgs.User.TryGetComponent(out IActorComponent? actor)) { return; } if (!Powered) { return; } if (!ActionBlockerSystem.CanInteract(actor.playerSession.AttachedEntity)) { return; } UserInterface?.Toggle(actor.playerSession); RegisterPlayerSession(actor.playerSession); }
protected override void GetData(IEntity user, HandheldLightComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } if (component.Cell == null) { data.Text = Loc.GetString("Eject cell (cell missing)"); data.Visibility = VerbVisibility.Disabled; } else { data.Text = Loc.GetString("Eject cell"); } }
private void OnUncuffAttempt(UncuffAttemptEvent args) { if (args.Cancelled) { return; } if (!EntityManager.TryGetEntity(args.User, out var userEntity)) { // Should this even be possible? args.Cancel(); return; } // If the user is the target, special logic applies. // This is because the CanInteract blocking of the cuffs prevents self-uncuff. if (args.User == args.Target) { // This UncuffAttemptEvent check should probably be In MobStateSystem, not here? if (userEntity.TryGetComponent <IMobStateComponent>(out var state)) { // Manually check this. if (state.IsIncapacitated()) { args.Cancel(); } } else { // Uh... let it go through??? // TODO CUFFABLE/STUN add UncuffAttemptEvent subscription to StunSystem } } else { // Check if the user can interact. if (!_actionBlockerSystem.CanInteract(userEntity)) { args.Cancel(); } } if (args.Cancelled) { _popupSystem.PopupEntity(Loc.GetString("cuffable-component-cannot-interact-message"), args.Target, Filter.Entities(userEntity.Uid)); } }
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage obj) { if (!ConsolePowered) { return; } if (obj.Session.AttachedEntity == null || !ActionBlockerSystem.CanInteract(obj.Session.AttachedEntity)) { return; } if (_wireInterfaceBlocked) { return; } switch (obj.Message) { case ParticleAcceleratorSetEnableMessage enableMessage: if (enableMessage.Enabled) { SwitchOn(); } else { SwitchOff(); } break; case ParticleAcceleratorSetPowerStateMessage stateMessage: SetStrength(stateMessage.State); break; case ParticleAcceleratorRescanPartsMessage _: RescanParts(); break; } UpdateUI(); }
// This needs some improvements... public void Resist() { if (!OnFire || !ActionBlockerSystem.CanInteract(Owner) || _resisting || !Owner.TryGetComponent(out StunnableComponent stunnable)) { return; } _resisting = true; Owner.PopupMessage(Loc.GetString("You stop, drop, and roll!")); stunnable.Paralyze(2f); Timer.Spawn(2000, () => { _resisting = false; FireStacks -= 2f; UpdateAppearance(); }); }
protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } data.Text = Loc.GetString("Eject magazine"); if (component.MagNeedsOpenBolt) { data.Visibility = component.HasMagazine && component.BoltOpen ? VerbVisibility.Visible : VerbVisibility.Disabled; return; } data.Visibility = component.HasMagazine ? VerbVisibility.Visible : VerbVisibility.Disabled; }
private void OnUncuffAttempt(UncuffAttemptEvent args) { if (args.Cancelled) { return; } if (!EntityManager.EntityExists(args.User)) { // Should this even be possible? args.Cancel(); return; } // If the user is the target, special logic applies. // This is because the CanInteract blocking of the cuffs prevents self-uncuff. if (args.User == args.Target) { // This UncuffAttemptEvent check should probably be In MobStateSystem, not here? if (EntityManager.TryGetComponent <MobStateComponent?>(args.User, out var state)) { // Manually check this. if (state.IsIncapacitated()) { args.Cancel(); } } else { // TODO Find a way for cuffable to check ActionBlockerSystem.CanInteract() without blocking itself } } else { // Check if the user can interact. if (!_actionBlockerSystem.CanInteract(args.User, args.Target)) { args.Cancel(); } } if (args.Cancelled) { _popupSystem.PopupEntity(Loc.GetString("cuffable-component-cannot-interact-message"), args.Target, Filter.Entities(args.User)); } }
protected override void GetData(IEntity user, ServerBatteryBarrelComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user) || !component._powerCellRemovable) { data.Visibility = VerbVisibility.Invisible; return; } if (component.PowerCell == null) { data.Text = Loc.GetString("No cell"); data.Visibility = VerbVisibility.Disabled; } else { data.Text = Loc.GetString("Eject cell"); data.IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png"; } }
public void AfterInteract(AfterInteractEventArgs eventArgs) { if (eventArgs.Target == null) { return; } if (!eventArgs.Target.TryGetComponent(out IBodyManagerComponent body)) { return; } if (!ActionBlockerSystem.CanInteract(eventArgs.User)) { return; } if (eventArgs.User != eventArgs.Target) { var interactionSystem = EntitySystem.Get <SharedInteractionSystem>(); var from = eventArgs.User.Transform.MapPosition; var to = eventArgs.Target.Transform.MapPosition; bool Ignored(IEntity entity) => entity == eventArgs.User || entity == eventArgs.Target; var inRange = interactionSystem.InRangeUnobstructed(from, to, predicate: Ignored); if (!inRange) { return; } } if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1)) { return; } foreach (var(type, amount) in Heal) { body.ChangeDamage(type, -amount, true); } }
protected override void GetData(IEntity user, ConstructionComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } if (((component.Target != null) && (component.Target.Name == component.DeconstructionNodeIdentifier)) || ((component.Node != null) && (component.Node.Name == component.DeconstructionNodeIdentifier))) { data.Visibility = VerbVisibility.Invisible; return; } data.CategoryData = VerbCategories.Construction; data.Text = Loc.GetString("Begin deconstructing"); data.IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.96dpi.png"; }
/// <summary> /// Whether the table exists, and the player can interact with it. /// </summary> /// <param name="playerEntity">The player entity to check.</param> /// <param name="table">The table entity to check.</param> protected bool CanSeeTable(EntityUid playerEntity, EntityUid?table) { if (table == null) { return(false); } if (EntityManager.GetComponent <TransformComponent>(table.Value).Parent?.Owner is not { } parent) { return(false); } if (!EntityManager.HasComponent <MapComponent>(parent) && !EntityManager.HasComponent <IMapGridComponent>(parent)) { return(false); } return(playerEntity.InRangeUnobstructed(table.Value) && _actionBlockerSystem.CanInteract(playerEntity)); }
/// <summary> /// Checks whether the player entity is able to use the chem dispenser. /// </summary> /// <param name="playerEntity">The player entity.</param> /// <returns>Returns true if the entity can use the dispenser, and false if it cannot.</returns> private bool PlayerCanUseDispenser(IEntity playerEntity) { //Need player entity to check if they are still able to use the dispenser if (playerEntity == null) { return(false); } //Check if player can interact in their current state if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity)) { return(false); } //Check if device is powered if (!Powered) { return(false); } return(true); }
private void HandleInteract(EntityUid uid, LightReplacerComponent component, InteractUsingMessage eventArgs) { // standard interaction checks if (!ActionBlockerSystem.CanInteract(eventArgs.User)) { return; } if (eventArgs.ItemInHand != null) { // want to insert a new light bulb? if (eventArgs.ItemInHand.TryGetComponent(out LightBulbComponent? bulb)) { component.TryInsertBulb(bulb, eventArgs.User, true); } // add bulbs from storage? else if (eventArgs.ItemInHand.TryGetComponent(out ServerStorageComponent? storage)) { component.TryInsertBulb(storage, eventArgs.User); } } }
protected override void GetData(IEntity user, StrapComponent component, VerbData data) { data.Visibility = VerbVisibility.Invisible; if (!ActionBlockerSystem.CanInteract(component.Owner) || !user.TryGetComponent(out BuckleComponent buckle) || buckle.BuckledTo != null && buckle.BuckledTo != component || user == component.Owner) { return; } var parent = component.Owner.Transform.Parent; while (parent != null) { if (parent == user.Transform) { return; } parent = parent.Parent; } var userPosition = user.Transform.MapPosition; var strapPosition = component.Owner.Transform.MapPosition; var range = SharedInteractionSystem.InteractionRange / 2; var inRange = EntitySystem.Get <SharedInteractionSystem>() .InRangeUnobstructed(userPosition, strapPosition, range, predicate: entity => entity == user || entity == component.Owner); if (!inRange) { return; } data.Visibility = VerbVisibility.Visible; data.Text = buckle.BuckledTo == null?Loc.GetString("Buckle") : Loc.GetString("Unbuckle"); }
protected override void GetData(IEntity user, BaseCharger component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } if (!user.TryGetComponent(out HandsComponent handsComponent)) { data.Visibility = VerbVisibility.Invisible; return; } if (component._container.ContainedEntity != null || handsComponent.GetActiveHand == null) { data.Visibility = VerbVisibility.Disabled; data.Text = "Insert"; return; } data.Text = $"Insert {handsComponent.GetActiveHand.Owner.Name}"; }
async Task <bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { if (!ActionBlockerSystem.CanInteract(eventArgs.User)) { return(false); } if (eventArgs.Using.HasTag("BotanySharp")) { for (var i = 0; i < 2; i++) { var plank = Owner.EntityManager.SpawnEntity("MaterialWoodPlank1", Owner.Transform.Coordinates); plank.RandomOffset(0.25f); } Owner.QueueDelete(); return(true); } return(false); }
/// <summary> /// Checks if the user can vault the target /// </summary> /// <param name="user">The entity that wants to vault</param> /// <param name="target">The object that is being vaulted</param> /// <param name="reason">The reason why it cant be dropped</param> /// <returns></returns> private bool CanVault(IEntity user, IEntity target, out string reason) { if (!ActionBlockerSystem.CanInteract(user)) { reason = Loc.GetString("You can't do that!"); return(false); } if (!user.HasComponent <ClimbingComponent>()) { reason = Loc.GetString("You are incapable of climbing!"); return(false); } var bodyManager = user.GetComponent <BodyManagerComponent>(); if (bodyManager.GetBodyPartsOfType(Shared.GameObjects.Components.Body.BodyPartType.Leg).Count == 0 || bodyManager.GetBodyPartsOfType(Shared.GameObjects.Components.Body.BodyPartType.Foot).Count == 0) { reason = Loc.GetString("You are unable to climb!"); return(false); } var userPosition = user.Transform.MapPosition; var climbablePosition = target.Transform.MapPosition; var interaction = EntitySystem.Get <SharedInteractionSystem>(); bool Ignored(IEntity entity) => (entity == target || entity == user); if (!interaction.InRangeUnobstructed(userPosition, climbablePosition, _range, predicate: Ignored)) { reason = Loc.GetString("You can't reach there!"); return(false); } reason = string.Empty; return(true); }
/// <summary> /// This function gets called when the user clicked on an item in the storage UI. This will either place the /// item in the user's hand if it is currently empty, or interact with the item using the user's currently /// held item. /// </summary> private void OnInteractWithItem(EntityUid uid, ServerStorageComponent storageComp, StorageInteractWithItemEvent args) { // TODO move this to shared for prediction. if (args.Session.AttachedEntity is not EntityUid player) { return; } if (!_actionBlockerSystem.CanInteract(player, args.InteractedItemUID)) { return; } if (storageComp.Storage == null || !storageComp.Storage.Contains(args.InteractedItemUID)) { return; } // Does the player have hands? if (!TryComp(player, out HandsComponent? hands) || hands.Count == 0) { return; } // If the user's active hand is empty, try pick up the item. if (hands.ActiveHandEntity == null) { if (_sharedHandsSystem.TryPickupAnyHand(player, args.InteractedItemUID, handsComp: hands) && storageComp.StorageRemoveSound != null) { SoundSystem.Play(storageComp.StorageRemoveSound.GetSound(), Filter.Pvs(uid, entityManager: EntityManager), uid, AudioParams.Default); } return; } // Else, interact using the held item _interactionSystem.InteractUsing(player, hands.ActiveHandEntity.Value, args.InteractedItemUID, Transform(args.InteractedItemUID).Coordinates, checkCanInteract: false); }
protected override void GetData(IEntity user, SolutionContainerComponent component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user) || !user.TryGetComponent <HandsComponent>(out var hands) || hands.GetActiveHand == null || hands.GetActiveHand.Owner == component.Owner || !hands.GetActiveHand.Owner.TryGetComponent <SolutionContainerComponent>(out var solution) || !solution.CanRemoveSolutions || !component.CanAddSolutions) { data.Visibility = VerbVisibility.Invisible; return; } var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>"; var myName = component.Owner.Prototype?.Name ?? "<Item>"; var locHeldEntityName = Loc.GetString(heldEntityName); var locMyName = Loc.GetString(myName); data.Visibility = VerbVisibility.Visible; data.Text = Loc.GetString("Transfer liquid from [{0}] to [{1}].", locHeldEntityName, locMyName); }
/// <summary> /// Uses a item/object on an entity /// Finds components with the InteractUsing interface and calls their function /// NOTE: Does not have an InRangeUnobstructed check /// </summary> public async Task InteractUsing(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation) { if (!_actionBlockerSystem.CanInteract(user)) { return; } if (InteractDoBefore(user, used, target, clickLocation, true)) { return; } // all interactions should only happen when in range / unobstructed, so no range check is needed var interactUsingEvent = new InteractUsingEvent(user, used, target, clickLocation); RaiseLocalEvent(target, interactUsingEvent); if (interactUsingEvent.Handled) { return; } var interactUsingEventArgs = new InteractUsingEventArgs(user, clickLocation, used, target); var interactUsings = EntityManager.GetComponents <IInteractUsing>(target).OrderByDescending(x => x.Priority); foreach (var interactUsing in interactUsings) { // If an InteractUsing returns a status completion we finish our interaction if (await interactUsing.InteractUsing(interactUsingEventArgs)) { return; } } // If we aren't directly interacting with the nearby object, lets see if our item has an after interact we can do await InteractDoAfter(user, used, target, clickLocation, true); }
public override void Update(float frameTime) { base.Update(frameTime); var toRemove = new RemQueue <PilotComponent>(); foreach (var comp in EntityManager.EntityQuery <PilotComponent>()) { if (comp.Console == null) { continue; } if (!_blocker.CanInteract(comp.Owner, comp.Console.Owner)) { toRemove.Add(comp); } } foreach (var comp in toRemove) { RemovePilot(comp); } }
void IActivate.Activate(ActivateEventArgs eventArgs) { if (!eventArgs.User.TryGetComponent(out IActorComponent? actor)) { return; } if (!Powered) { return; } if (!ActionBlockerSystem.CanInteract(actor.playerSession.AttachedEntity)) { return; } if (_wiresComponent?.IsPanelOpen == true) { _wiresComponent.OpenInterface(actor.playerSession); } else { UserInterface?.Toggle(actor.playerSession); } }
protected override void GetData(IEntity user, BaseCharger component, VerbData data) { if (!ActionBlockerSystem.CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } if (!user.TryGetComponent(out HandsComponent? handsComponent)) { data.Visibility = VerbVisibility.Invisible; return; } if (component._container.ContainedEntity != null || handsComponent.GetActiveHand == null) { data.Visibility = VerbVisibility.Disabled; data.Text = Loc.GetString("Insert"); return; } var heldItemName = Loc.GetString(handsComponent.GetActiveHand.Owner.Name); data.Text = Loc.GetString("Insert {0}", heldItemName); }
async Task <bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) { if (eventArgs.Target == null) { return(false); } if (!eventArgs.Target.TryGetComponent(out IDamageableComponent damageable)) { return(true); } if (!ActionBlockerSystem.CanInteract(eventArgs.User)) { return(true); } if (eventArgs.User != eventArgs.Target && !eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) { return(true); } if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1)) { return(true); } foreach (var(type, amount) in Heal) { damageable.ChangeDamage(type, -amount, true); } return(true); }