//TODO: Actually shows all items/clothing/etc. private void HandleExamined(EntityUid uid, HandsComponent component, ExaminedEvent args) { foreach (var inhand in component.GetAllHeldItems()) { args.Message.AddText($"\n{Loc.GetString("comp-hands-examine", ("user", component.Owner), ("item", inhand.Owner))}"); } }
private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args) { if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled.Owner, uid)) { DebugTools.Assert("Unable to find available hand when starting pulling??"); } }
private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent args) { if (args.Handled) { return; } // Break any pulls if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled && TryComp(pulled, out SharedPullableComponent? pullable)) { _pullingSystem.TryStopPull(pullable); } if (_handsSystem.TryDrop(uid, component.ActiveHand !, null, checkActionBlocker: false)) { return; } var targetName = Name(args.Target); var msgOther = Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name(args.Source)), ("disarmed", targetName)); var msgUser = Loc.GetString("hands-component-disarm-success-message", ("disarmed", targetName)); var filter = Filter.Pvs(args.Source).RemoveWhereAttachedEntity(e => e == args.Source); _popupSystem.PopupEntity(msgOther, args.Source, filter); _popupSystem.PopupEntity(msgUser, args.Source, Filter.Entities(args.Source)); args.Handled = true; // no shove/stun. }
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptMessage args) { // Cancel pull if all hands full. if (component.Hands.All(hand => !hand.IsEmpty)) { args.Cancelled = true; } }
//TODO: Actually shows all items/clothing/etc. private void HandleExamined(EntityUid uid, HandsComponent component, ExaminedEvent args) { foreach (var inhand in component.GetAllHeldItems()) { if (EntityManager.HasComponent <HandVirtualItemComponent>(inhand.Owner)) { continue; } args.PushText(Loc.GetString("comp-hands-examine", ("user", component.Owner), ("item", inhand.Owner))); } }
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptMessage args) { if (args.Puller.Owner != uid) { return; } // Cancel pull if all hands full. if (component.Hands.All(hand => hand.HeldEntity != null)) { args.Cancelled = true; } }
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptMessage args) { if (args.Puller.Owner != uid) { return; } // Cancel pull if all hands full. if (!component.IsAnyHandFree()) { args.Cancelled = true; } }
private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message) { switch (message.Message) { case PDARequestUpdateInterfaceMessage _: { UpdatePDAUserInterface(); break; } case PDAToggleFlashlightMessage _: { ToggleLight(); break; } case PDAEjectIDMessage _: { HandleIDEjection(message.Session.AttachedEntity !); break; } case PDAEjectPenMessage _: { HandlePenEjection(message.Session.AttachedEntity !); break; } case PDAUplinkBuyListingMessage buyMsg: { if (message.Session.AttachedEntity == null) { break; } if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId, message.Session.AttachedEntity.Transform.Coordinates, out var entity)) { SendNetworkMessage(new PDAUplinkInsufficientFundsMessage(), message.Session.ConnectedClient); break; } HandsComponent.PutInHandOrDropStatic( message.Session.AttachedEntity, entity.GetComponent <ItemComponent>()); SendNetworkMessage(new PDAUplinkBuySuccessMessage(), message.Session.ConnectedClient); break; } } }
public Hand(HandsComponent parent, SharedHand hand, IEntityManager manager, HandButton?button = null) { Parent = parent; Index = hand.Index; Name = hand.Name; Location = hand.Location; Button = button; if (!hand.EntityUid.HasValue) { return; } manager.TryGetEntity(hand.EntityUid.Value, out var entity); Entity = entity; }
private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args) { // Try find hand that is doing this pull. // and clear it. foreach (var hand in component.Hands) { if (hand.HeldEntity == null || !hand.HeldEntity.TryGetComponent(out HandVirtualPullComponent? virtualPull) || virtualPull.PulledEntity != args.Pulled.Owner.Uid) { continue; } hand.HeldEntity.Delete(); break; } }
private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args) { if (args.Puller.Owner != uid) { return; } if (TryComp <SharedPullerComponent>(args.Puller.Owner, out var pullerComp) && !pullerComp.NeedsHands) { return; } if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled.Owner, uid)) { DebugTools.Assert("Unable to find available hand when starting pulling??"); } }
private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args) { // Try find hand that is doing this pull. // and clear it. foreach (var hand in component.Hands) { if (hand.HeldEntity == default || !EntityManager.TryGetComponent(hand.HeldEntity, out HandVirtualItemComponent? virtualItem) || virtualItem.BlockingEntity != args.Pulled.Owner) { continue; } EntityManager.DeleteEntity(hand.HeldEntity); break; } }
private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args) { foreach (var handName in component.ActivePriorityEnumerable()) { var hand = component.GetHand(handName); if (!hand.IsEmpty) { continue; } var pos = component.Owner.Transform.Coordinates; var virtualPull = EntityManager.SpawnEntity("HandVirtualPull", pos); var virtualPullComp = virtualPull.GetComponent <HandVirtualPullComponent>(); virtualPullComp.PulledEntity = args.Pulled.Owner.Uid; component.PutEntityIntoHand(hand, virtualPull); return; } DebugTools.Assert("Unable to find available hand when starting pulling??"); }
private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args) { if (args.Puller.Owner != uid) { return; } // Try find hand that is doing this pull. // and clear it. foreach (var hand in component.Hands.Values) { if (hand.HeldEntity == null || !TryComp(hand.HeldEntity, out HandVirtualItemComponent? virtualItem) || virtualItem.BlockingEntity != args.Pulled.Owner) { continue; } QueueDel(hand.HeldEntity.Value); break; } }
private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent args) { if (args.Handled || component.BreakPulls()) { return; } if (component.ActiveHand == null || !component.Drop(component.ActiveHand, false)) { return; } var targetName = Name(args.Target); var msgOther = Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name(args.Source)), ("disarmed", targetName)); var msgUser = Loc.GetString("hands-component-disarm-success-message", ("disarmed", targetName)); var filter = Filter.Pvs(args.Source).RemoveWhereAttachedEntity(e => e == args.Source); _popupSystem.PopupEntity(msgOther, args.Source, filter); _popupSystem.PopupEntity(msgUser, args.Source, Filter.Entities(args.Source)); args.Handled = true; // no shove/stun. }
public async Task BuckledDyingDropItemsTest() { await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); var server = pairTracker.Pair.Server; var testMap = await PoolManager.CreateTestMap(pairTracker); var coordinates = testMap.GridCoords; EntityUid human = default; BuckleComponent buckle = null; HandsComponent hands = null; SharedBodyComponent body = null; await server.WaitIdleAsync(); await server.WaitAssertion(() => { var entityManager = IoCManager.Resolve <IEntityManager>(); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); var chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Component sanity check Assert.True(entityManager.TryGetComponent(human, out buckle)); Assert.True(entityManager.HasComponent <StrapComponent>(chair)); Assert.True(entityManager.TryGetComponent(human, out hands)); Assert.True(entityManager.TryGetComponent(human, out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity(ItemDummyId, coordinates); Assert.True(EntitySystem.Get <SharedHandsSystem>().TryPickupAnyHand(human, akms)); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var hand in hands.Hands.Values) { Assert.NotNull(hands.ActiveHandEntity); } var legs = body.GetPartsOfType(BodyPartType.Leg); // Break our guy's kneecaps foreach (var leg in legs) { body.RemovePart(leg); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var hand in hands.Hands.Values) { Assert.Null(hands.ActiveHandEntity); } buckle.TryUnbuckle(human, true); }); await pairTracker.CleanReturnAsync(); }
public async Task BuckledDyingDropItemsTest() { var options = new ServerIntegrationOptions { ExtraPrototypes = PROTOTYPES }; var server = StartServer(options); IEntity human = null; BuckleComponent buckle = null; HandsComponent hands = null; IBody body = null; await server.WaitIdleAsync(); await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.GetGrid(gridId); var coordinates = grid.GridEntityId.ToCoordinates(); human = entityManager.SpawnEntity("BuckleDummy", coordinates); IEntity chair = entityManager.SpawnEntity("StrapDummy", coordinates); // Component sanity check Assert.True(human.TryGetComponent(out buckle)); Assert.True(chair.HasComponent <StrapComponent>()); Assert.True(human.TryGetComponent(out hands)); Assert.True(human.TryGetComponent(out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity("RifleAk", coordinates); // Equip items Assert.True(akms.TryGetComponent(out ItemComponent item)); Assert.True(hands.PutInHand(item)); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var slot in hands.Hands) { Assert.NotNull(hands.GetItem(slot)); } var legs = body.GetPartsOfType(BodyPartType.Leg); // Break our guy's kneecaps foreach (var leg in legs) { body.RemovePart(leg); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var slot in hands.Hands) { Assert.Null(hands.GetItem(slot)); } buckle.TryUnbuckle(human, true); }); }
private void GetComponentState(EntityUid uid, HandsComponent hands, ref ComponentGetState args) { args.State = new HandsComponentState(hands); }
public Hand(HandsComponent parent, string name, ContainerSlot container) { Parent = parent; Name = name; Container = container; }
public async Task BuckledDyingDropItemsTest() { var server = StartServer(); IEntity human = null; IEntity chair = null; BuckleComponent buckle = null; StrapComponent strap = null; HandsComponent hands = null; IDamageableComponent humanDamageable = null; server.Assert(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var mapId = new MapId(1); mapManager.CreateNewMapEntity(mapId); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.CreateGrid(mapId, gridId); var coordinates = new GridCoordinates((0, 0), gridId); var tileManager = IoCManager.Resolve <ITileDefinitionManager>(); var tileId = tileManager["underplating"].TileId; var tile = new Tile(tileId); grid.SetTile(coordinates, tile); human = entityManager.SpawnEntity("HumanMob_Content", coordinates); chair = entityManager.SpawnEntity("ChairWood", coordinates); // Component sanity check Assert.True(human.TryGetComponent(out buckle)); Assert.True(chair.TryGetComponent(out strap)); Assert.True(human.TryGetComponent(out hands)); Assert.True(human.TryGetComponent(out humanDamageable)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity("RifleAk", coordinates); // Equip items Assert.True(akms.TryGetComponent(out ItemComponent item)); Assert.True(hands.PutInHand(item)); } }); server.RunTicks(10); server.Assert(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var slot in hands.Hands) { Assert.NotNull(hands.GetItem(slot)); } // Banish our guy into the shadow realm humanDamageable.ChangeDamage(DamageClass.Brute, 1000000, true); }); server.RunTicks(10); server.Assert(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var slot in hands.Hands) { Assert.Null(hands.GetItem(slot)); } }); await server.WaitIdleAsync(); }
public async Task BuckledDyingDropItemsTest() { var server = StartServer(); IEntity human; IEntity chair; BuckleComponent buckle = null; HandsComponent hands = null; IBody body = null; await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var mapId = new MapId(1); mapManager.CreateNewMapEntity(mapId); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.CreateGrid(mapId, gridId); var coordinates = grid.GridEntityId.ToCoordinates(); var tileManager = IoCManager.Resolve <ITileDefinitionManager>(); var tileId = tileManager["underplating"].TileId; var tile = new Tile(tileId); grid.SetTile(coordinates, tile); human = entityManager.SpawnEntity("HumanMob_Content", coordinates); chair = entityManager.SpawnEntity("ChairWood", coordinates); // Component sanity check Assert.True(human.TryGetComponent(out buckle)); Assert.True(chair.HasComponent <StrapComponent>()); Assert.True(human.TryGetComponent(out hands)); Assert.True(human.TryGetComponent(out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity("RifleAk", coordinates); // Equip items Assert.True(akms.TryGetComponent(out ItemComponent item)); Assert.True(hands.PutInHand(item)); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var slot in hands.Hands) { Assert.NotNull(hands.GetItem(slot)); } var legs = body.GetPartsOfType(BodyPartType.Leg); // Break our guy's kneecaps foreach (var leg in legs) { body.RemovePart(leg); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var slot in hands.Hands) { Assert.Null(hands.GetItem(slot)); } }); }
public async Task BuckledDyingDropItemsTest() { var options = new ServerContentIntegrationOption { ExtraPrototypes = Prototypes }; var server = StartServer(options); EntityUid human = default; BuckleComponent buckle = null; HandsComponent hands = null; SharedBodyComponent body = null; await server.WaitIdleAsync(); await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var grid = GetMainGrid(mapManager); var coordinates = new EntityCoordinates(grid.GridEntityId, 0, 0); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); var chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Component sanity check Assert.True(entityManager.TryGetComponent(human, out buckle)); Assert.True(entityManager.HasComponent <StrapComponent>(chair)); Assert.True(entityManager.TryGetComponent(human, out hands)); Assert.True(entityManager.TryGetComponent(human, out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity(ItemDummyId, coordinates); // Equip items Assert.True(entityManager.TryGetComponent(akms, out SharedItemComponent item)); Assert.True(hands.PutInHand(item)); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var slot in hands.HandNames) { Assert.NotNull(hands.GetItem(slot)); } var legs = body.GetPartsOfType(BodyPartType.Leg); // Break our guy's kneecaps foreach (var leg in legs) { body.RemovePart(leg); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var slot in hands.HandNames) { Assert.Null(hands.GetItem(slot)); } buckle.TryUnbuckle(human, true); }); }