private void HandleContainerModified(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args) { if (handComp.Hands.TryGetValue(args.Container.ID, out var hand)) { UpdateHandVisuals(uid, args.Entity, hand); } }
protected override void HandleContainerModified(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args) { if (handComp.TryGetHand(args.Container.ID, out var hand)) { UpdateHandVisuals(uid, args.Entity, hand); } }
private void HandleContainerInserted(EntityUid uid, SharedHandsComponent component, EntInsertedIntoContainerMessage args) { // un-rotate entities. needed for things like directional flashlights Transform(args.Entity).LocalRotation = 0; HandleContainerModified(uid, component, args); }
protected override void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args) { if (uid == _playerManager.LocalPlayer?.ControlledEntity) { GuiStateUpdated?.Invoke(); } }
private void HandleEntityRemoved(EntityUid uid, SharedHandsComponent component, EntRemovedFromContainerMessage args) { if (!Deleted(args.Entity) && TryComp(args.Entity, out HandVirtualItemComponent? @virtual)) { _virtualSystem.Delete(@virtual, uid); } }
private void DropHandItems(SharedHandsComponent handsComponent, bool doMobChecks = true) { var msg = new DropHandItemsAttemptEvent(); var entity = handsComponent.Owner; var uid = entity.Uid; var eventBus = EntityManager.EventBus; eventBus.RaiseLocalEvent(uid, msg); if (msg.Cancelled) { return; } if (entity.TryGetContainerMan(out var containerManager)) { var parentMsg = new ContainedEntityDropHandItemsAttemptEvent(uid); eventBus.RaiseLocalEvent(containerManager.Owner.Uid, parentMsg); if (parentMsg.Cancelled) { return; } } DropAllItemsInHands(entity, doMobChecks); }
protected virtual void HandleContainerModified( EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args) { component.Dirty(); }
private void OnPrefixChanged(EntityUid uid, SharedHandsComponent component, ItemPrefixChangeEvent args) { // update hands visuals if this item is in a hand (rather then inventory or other container). if (component.HasHand(args.ContainerId)) { UpdateHandVisuals(uid, component); } }
protected override void HandleContainerRemoved(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args) { if (!Deleted(args.Entity) && TryComp(args.Entity, out HandVirtualItemComponent? @virtual)) { _virtualSystem.Delete(@virtual, uid); } base.HandleContainerRemoved(uid, component, args); }
//TODO: Actually shows all items/clothing/etc. private void HandleExamined(EntityUid uid, SharedHandsComponent handsComp, ExaminedEvent args) { foreach (var inhand in EnumerateHeld(uid, handsComp)) { if (HasComp <HandVirtualItemComponent>(inhand)) { continue; } args.PushText(Loc.GetString("comp-hands-examine", ("user", handsComp.Owner), ("item", inhand))); } }
protected abstract void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args);
protected virtual void HandleContainerRemoved(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args) { HandleContainerModified(uid, component, args); }
private void HandleContainerModified(EntityUid uid, SharedHandsComponent hands, ContainerModifiedMessage args) { UpdateHandVisuals(uid, hands); }
protected virtual void HandleContainerModified(EntityUid uid, SharedHandsComponent hands, ContainerModifiedMessage args) { // client updates hand visuals here. }
public HandsComponentState(SharedHandsComponent handComp) { Hands = new(handComp.Hands.Values); HandNames = handComp.SortedHands; ActiveHand = handComp.ActiveHand?.Name; }
/// <summary> /// Get a list of hands that are currently holding nothing. This is a LinQ method, not a property, so cache /// it instead of accessing this multiple times. /// </summary> public static IEnumerable <string> GetFreeHandNames(this SharedHandsComponent component) => GetFreeHands(component).Select(hand => hand.Name);
/// <summary> /// Get a list of hands that are currently holding nothing. This is a LinQ method, not a property, so cache /// it instead of accessing this multiple times. /// </summary> public static IEnumerable <Hand> GetFreeHands(this SharedHandsComponent component) => component.Hands.Values.Where(hand => !hand.IsEmpty);
/// <summary> /// Get the number of hands that are not currently holding anything. This is a LinQ method, not a property, so /// cache it instead of accessing this multiple times. /// </summary> public static int CountFreeHands(this SharedHandsComponent component) => component.Hands.Values.Count(hand => hand.IsEmpty);
/// <summary> /// Returns true if any hand is free. This is a LinQ method, not a property, so /// cache it instead of accessing this multiple times. /// </summary> public static bool IsAnyHandFree(this SharedHandsComponent component) => component.Hands.Values.Any(hand => hand.IsEmpty);
protected override void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args) { component.HandsModified(); }