Example #1
0
 private void OnComponentRemove(EntityUid uid, ItemCabinetComponent cabinet, ComponentRemove args)
 {
     _itemSlotsSystem.RemoveItemSlot(uid, cabinet.CabinetSlot);
 }
Example #2
0
 public FlashAttemptEvent(EntityUid target, EntityUid?user, EntityUid?used)
 {
     Target = target;
     User   = user;
     Used   = used;
 }
Example #3
0
 private void OnFlashableStartup(EntityUid uid, FlashableComponent component, ComponentStartup args)
 {
     _metaSystem.AddFlag(uid, MetaDataFlags.EntitySpecific);
 }
 public RequestCharacterInfoEvent(EntityUid entityUid)
 {
     EntityUid = entityUid;
 }
Example #5
0
 public void RemoveTimer(EntityUid uid)
 {
     EntityManager.RemoveComponent <ActiveSurveillanceCameraMonitorVisualsComponent>(uid);
 }
Example #6
0
 /// <summary>
 ///     Creates an instance of <see cref="FullInputCmdMessage"/> with an optional Entity reference.
 /// </summary>
 /// <param name="tick">Client tick this was created.</param>
 /// <param name="inputFunctionId">Function this command is changing.</param>
 /// <param name="state">New state of the Input Function.</param>
 /// <param name="coordinates">Local Coordinates of the pointer when the command was created.</param>
 /// <param name="uid">Entity that was under the pointer when the command was created.</param>
 public FullInputCmdMessage(uint tick, KeyFunctionId inputFunctionId, BoundKeyState state, GridCoordinates coordinates, ScreenCoordinates screenCoordinates, EntityUid uid)
     : base(tick, inputFunctionId)
 {
     State             = state;
     Coordinates       = coordinates;
     ScreenCoordinates = screenCoordinates;
     Uid = uid;
 }
 private void OnThrowDoHit(EntityUid uid, ForcefeedOnCollideComponent component, ThrowDoHitEvent args)
 {
     _foodSystem.ProjectileForceFeed(uid, args.Target, args.User);
 }
 private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
 {
     _damageableSystem.TryChangeDamage(args.Target.Uid, component.Damage, component.IgnoreResistances);
 }
Example #9
0
 public ThrowAttemptEvent(EntityUid uid)
 {
     Uid = uid;
 }
 public static void AttachToGrandparent(this EntityUid entity)
 {
     AttachToGrandparent(IoCManager.Resolve <IEntityManager>().GetComponent <TransformComponent>(entity));
 }
Example #11
0
 public EntitySlotHighlightedEventArgs(EntityUid entity, bool newHighlighted)
 {
     Entity         = entity;
     NewHighlighted = newHighlighted;
 }
Example #12
0
        /// <summary>
        ///     Places item in user's active hand to an inventory slot.
        /// </summary>
        private async void PlaceActiveHandItemInInventory(EntityUid user, string slot)
        {
            var userHands = _entities.GetComponent <HandsComponent>(user);
            var item      = userHands.GetActiveHand;
            var invSystem = EntitySystem.Get <InventorySystem>();

            bool Check()
            {
                if (!EntitySystem.Get <ActionBlockerSystem>().CanInteract(user))
                {
                    return(false);
                }

                if (item == null)
                {
                    user.PopupMessageCursor(Loc.GetString("strippable-component-not-holding-anything"));
                    return(false);
                }

                if (!userHands.CanDrop(userHands.ActiveHand !))
                {
                    user.PopupMessageCursor(Loc.GetString("strippable-component-cannot-drop"));
                    return(false);
                }

                if (!invSystem.HasSlot(Owner, slot))
                {
                    return(false);
                }

                if (invSystem.TryGetSlotEntity(Owner, slot, out _))
                {
                    user.PopupMessageCursor(Loc.GetString("strippable-component-item-slot-occupied", ("owner", Owner)));
                    return(false);
                }

                if (!invSystem.CanEquip(user, Owner, item.Owner, slot, out _))
                {
                    user.PopupMessageCursor(Loc.GetString("strippable-component-cannot-equip-message", ("owner", Owner)));
                    return(false);
                }

                return(true);
            }

            var doAfterSystem = EntitySystem.Get <DoAfterSystem>();

            var doAfterArgs = new DoAfterEventArgs(user, StripDelay, CancellationToken.None, Owner)
            {
                ExtraCheck        = Check,
                BreakOnStun       = true,
                BreakOnDamage     = true,
                BreakOnTargetMove = true,
                BreakOnUserMove   = true,
                NeedHand          = true,
            };

            var result = await doAfterSystem.WaitDoAfter(doAfterArgs);

            if (result != DoAfterStatus.Finished)
            {
                return;
            }

            userHands.Drop(item !.Owner, false);
            invSystem.TryEquip(user, Owner, item.Owner, slot);

            UpdateState();
        }
Example #13
0
        /// <summary>
        ///     Takes an item from a hand and places it in the user's active hand.
        /// </summary>
        private async void TakeItemFromHands(EntityUid user, string hand)
        {
            var hands     = _entities.GetComponent <HandsComponent>(Owner);
            var userHands = _entities.GetComponent <HandsComponent>(user);

            bool Check()
            {
                if (!EntitySystem.Get <ActionBlockerSystem>().CanInteract(user))
                {
                    return(false);
                }

                if (!hands.HasHand(hand))
                {
                    return(false);
                }

                if (!hands.TryGetItem(hand, out var heldItem))
                {
                    user.PopupMessageCursor(Loc.GetString("strippable-component-item-slot-free-message", ("owner", Owner)));
                    return(false);
                }

                if (_entities.HasComponent <HandVirtualItemComponent>(heldItem.Owner))
                {
                    return(false);
                }

                if (!hands.CanDrop(hand, false))
                {
                    user.PopupMessageCursor(Loc.GetString("strippable-component-cannot-drop-message", ("owner", Owner)));
                    return(false);
                }

                return(true);
            }

            var doAfterSystem = EntitySystem.Get <DoAfterSystem>();

            var doAfterArgs = new DoAfterEventArgs(user, StripDelay, CancellationToken.None, Owner)
            {
                ExtraCheck        = Check,
                BreakOnStun       = true,
                BreakOnDamage     = true,
                BreakOnTargetMove = true,
                BreakOnUserMove   = true,
            };

            var result = await doAfterSystem.WaitDoAfter(doAfterArgs);

            if (result != DoAfterStatus.Finished)
            {
                return;
            }

            var item = hands.GetItem(hand);

            hands.Drop(hand, false);
            userHands.PutInHandOrDrop(item !);
            UpdateState();
        }
Example #14
0
 private void OnComponentStartup(EntityUid uid, ItemCabinetComponent cabinet, ComponentStartup args)
 {
     UpdateAppearance(uid, cabinet);
     _itemSlotsSystem.SetLock(uid, cabinet.CabinetSlot, !cabinet.Opened);
 }
Example #15
0
        public void PopupDirections(EntityUid entity)
        {
            var directions = string.Join(", ", ConnectableDirections());

            Owner.PopupMessage(entity, Loc.GetString("disposal-tube-component-popup-directions-text", ("directions", directions)));
        }
 private void OnCompInit(EntityUid uid, StrippableComponent component, ComponentInit args)
 {
     SendUpdate(uid, component);
 }
Example #17
0
 /// <summary>
 ///     Creates an instance of <see cref="PointerInputCmdMessage"/> with an optional Entity reference.
 /// </summary>
 /// <param name="tick">Client tick this was created.</param>
 /// <param name="inputFunctionId">Function this command is changing.</param>
 /// <param name="coordinates">Local Coordinates of the pointer when the command was created.</param>
 /// <param name="uid">Entity that was under the pointer when the command was created.</param>
 public PointerInputCmdMessage(uint tick, KeyFunctionId inputFunctionId, GridCoordinates coordinates, EntityUid uid)
     : base(tick, inputFunctionId)
 {
     Coordinates = coordinates;
     Uid         = uid;
 }
 private void OnDidEquip(EntityUid uid, StrippableComponent component, DidEquipEvent args)
 {
     SendUpdate(uid, component);
 }
Example #19
0
        private void UpdateActionSlot(EntityUid item, ItemActionType itemActionType, ActionSlot actionSlot,
                                      ActionAssignment?assignedActionType)
        {
            if (!_entityManager.EntityExists(item))
            {
                return;
            }
            if (_actionManager.TryGet(itemActionType, out var action))
            {
                actionSlot.Assign(action, item, true);
            }
            else
            {
                Logger.ErrorS("action", "unrecognized actionType {0}", assignedActionType);
                actionSlot.Clear();
                return;
            }

            if (!_actionsComponent.TryGetItemActionState(itemActionType, item, out var actionState))
            {
                // action is no longer tied to an item, this should never happen as we
                // check this at the start of this method. But just to be safe
                // we will restore our assignment here to the correct state
                Logger.ErrorS("action", "coding error, expected actionType {0} to have" +
                              " a state but it didn't", assignedActionType);
                _actionsComponent.Assignments.AssignSlot(SelectedHotbar, actionSlot.SlotIndex,
                                                         ActionAssignment.For(itemActionType));
                actionSlot.Assign(action);
                return;
            }

            if (!actionState.Enabled)
            {
                // just disabled an action we were trying to target with, stop targeting
                if (SelectingTargetFor?.Action != null && SelectingTargetFor.Action == action)
                {
                    StopTargeting();
                }

                actionSlot.DisableAction();
            }
            else
            {
                // action is currently granted
                actionSlot.EnableAction();

                // if we are targeting with an action now on cooldown, stop targeting if we should
                if (SelectingTargetFor?.Action != null && SelectingTargetFor.Action == action &&
                    SelectingTargetFor.Item == item &&
                    actionState.IsOnCooldown(_gameTiming) && action.DeselectOnCooldown)
                {
                    StopTargeting();
                }
            }
            actionSlot.Cooldown = actionState.Cooldown;

            // check if we need to toggle it
            if (action.BehaviorType == BehaviorType.Toggle)
            {
                actionSlot.ToggledOn = actionState.ToggledOn;
            }
        }
Example #20
0
        private void OnRefreshMovespeed(EntityUid uid, SharedHungerComponent component, RefreshMovementSpeedModifiersEvent args)
        {
            float mod = component.CurrentHungerThreshold == HungerThreshold.Starving ? 0.75f : 1.0f;

            args.ModifySpeed(mod, mod);
        }
        private void ProcessGases(EntityUid uid, RespiratorComponent respirator,
                                  BloodstreamComponent?bloodstream,
                                  SharedBodyComponent?body)
        {
            if (!Resolve(uid, ref bloodstream, ref body, false))
            {
                return;
            }

            var lungs = _bodySystem.GetComponentsOnMechanisms <LungComponent>(uid, body).ToArray();

            var needs = NeedsAndDeficit(respirator);
            var used  = 0f;

            foreach (var(lung, mech) in lungs)
            {
                _lungSystem.UpdateLung(lung.Owner, lung, mech);
            }

            foreach (var(gas, amountNeeded) in needs)
            {
                var bloodstreamAmount = bloodstream.Air.GetMoles(gas);
                var deficit           = 0f;

                if (bloodstreamAmount < amountNeeded)
                {
                    // Panic inhale
                    foreach (var(lung, mech) in lungs)
                    {
                        _lungSystem.Gasp((lung).Owner, lung, mech);
                    }

                    bloodstreamAmount = bloodstream.Air.GetMoles(gas);

                    deficit = Math.Max(0, amountNeeded - bloodstreamAmount);

                    if (deficit > 0)
                    {
                        bloodstream.Air.SetMoles(gas, 0);
                    }
                    else
                    {
                        bloodstream.Air.AdjustMoles(gas, -amountNeeded);
                    }
                }
                else
                {
                    bloodstream.Air.AdjustMoles(gas, -amountNeeded);
                }

                respirator.DeficitGases[gas] = deficit;

                used += (amountNeeded - deficit) / amountNeeded;
            }

            var produced = GasProduced(respirator, used / needs.Count);

            foreach (var(gas, amountProduced) in produced)
            {
                bloodstream.Air.AdjustMoles(gas, amountProduced);
            }

            ClampDeficit(respirator);
        }
 public override void PopupEntity(string message, EntityUid uid, Filter filter, PopupType type = PopupType.Small)
 {
     RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), filter);
 }
Example #23
0
    public void AddTimer(EntityUid uid, Action onFinish)
    {
        var comp = EnsureComp <ActiveSurveillanceCameraMonitorVisualsComponent>(uid);

        comp.OnFinish = onFinish;
    }
Example #24
0
 public UnequippedEventBase(EntityUid equipee, EntityUid equipment, SlotDefinition slotDefinition)
 {
     Equipee   = equipee;
     Equipment = equipment;
     Slot      = slotDefinition.Name;
 }
Example #25
0
 public void AddThresholdsToList(EntityUid _, DestructibleComponent comp, DamageThresholdReached args)
 {
     ThresholdsReached.Add(args);
 }
Example #26
0
 public DidUnequipEvent(EntityUid equipee, EntityUid equipment, SlotDefinition slotDefinition) : base(equipee, equipment, slotDefinition)
 {
 }
Example #27
0
 private void OnPlayerAttached(EntityUid uid, FlashableComponent component, PlayerAttachedEvent args)
 {
     Dirty(component);
 }
Example #28
0
 public GotUnequippedEvent(EntityUid equipee, EntityUid equipment, SlotDefinition slotDefinition) : base(equipee, equipment, slotDefinition)
 {
 }
Example #29
0
 private void OnFlashableShutdown(EntityUid uid, FlashableComponent component, ComponentShutdown args)
 {
     _metaSystem.RemoveFlag(uid, MetaDataFlags.EntitySpecific);
 }
Example #30
0
 private void OnComponentInit(EntityUid uid, ItemCabinetComponent cabinet, ComponentInit args)
 {
     _itemSlotsSystem.AddItemSlot(uid, cabinet.Name, cabinet.CabinetSlot);
 }