Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Item Transfer System #476

Merged
merged 13 commits into from
Jul 6, 2024
Merged

Conversation

Spatison
Copy link
Contributor

@Spatison Spatison commented Jun 18, 2024

Description

This PR adds the ability to transfer objects from one player's hand to another player's hand, as in SS13.

I have little coding experience, so my solutions may not be ideal.


TODO

  • Make the code work
  • Add popup
  • Write a summary of the code
  • Сorrect inaccuracies

Media

https://youtu.be/zTQWTsYm1gw


Changelog

🆑

  • add: Added system

@github-actions github-actions bot added Changes: C# Changes any cs files Changes: Localization Changes any ftl files Changes: Sprite Changes any png or json in an RSI Changes: UI Changes any XAML files Changes: YML Changes any yml files labels Jun 18, 2024
Copy link
Contributor

github-actions bot commented Jun 18, 2024

RSI Diff Bot; head commit 5c7fab3 merging into 0269efc
This PR makes changes to 1 or more RSIs. Here is a summary of all changes:

Resources/Textures/Interface/Alerts/offer_item.rsi

State Old New Status
offer_item Added

Resources/Textures/Interface/Misc/give_item.rsi

State Old New Status
give_item Added

Edit: diff updated after 5c7fab3

@Spatison
Copy link
Contributor Author

I'm sorry, I accidentally deleted it while trying to rename the branch

@Spatison
Copy link
Contributor Author

Hello, DangerRevolution, yes, of course, you can edit my post, but I still don't know myself what I would like to write here.

@DangerRevolution DangerRevolution added Priority: 2-High Needs to be resolved as soon as possible Size: 3-Medium For medium issues/PRs Holy Shit Status: Needs Review Someone please review this Type: Feature Creation of or significant changes to a feature labels Jun 18, 2024
@DangerRevolution
Copy link
Contributor

Updated the description slightly.

@DangerRevolution DangerRevolution marked this pull request as draft June 18, 2024 21:53
@DangerRevolution DangerRevolution marked this pull request as ready for review June 18, 2024 21:53
Copy link
Contributor

@DangerRevolution DangerRevolution left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just playtested this:

Two issues, everything else is fine.

A) In Debug; someone receiving an item throws an exception. I can recreate it and send you the error if you don't manage to recreate it. It's something to do with the target not having the correct component to recieve.
B (Part 1) Giving yourself an item; switching hands and recieving it from yourself. Then, clicking on yourself again to hand it back to yourself locks the alert to your screen even if you walk away from the item.

image

In this screenshot I followed the steps with the Captain's ID you see in the picture.

B (Part 2): Receiving an item from a player; then clicking yourself with it will ALSO trigger the prompt to give and lock this alert to your screen, until you fuck around with it to stop the alert.

Otherwise; system is very nice. A cool addition. Just needs some minor changes.

@@ -110,3 +110,6 @@ alerts-revenant-essence-desc = The power of souls. It sustains you and is used f
alerts-revenant-corporeal-name = Corporeal
alerts-revenant-corporeal-desc = You have manifested physically. People around you can see and hurt you.
alerts-offer-name = Offer
alerts-offer-desc = Something offers you some kind of item
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
alerts-offer-desc = Something offers you some kind of item
alerts-offer-desc = Someone offers you an item.

offer-item-give-other = {$user} handed {THE($item)} to {$target}
offer-item-give-target = {$user} handed you a {THE($item)}

offer-item-no-give = You're no longer offer a {THE($item)} to {$target}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
offer-item-no-give = You're no longer offer a {THE($item)} to {$target}
offer-item-no-give = You're stop offering {THE($item)} to {$target}

@Spatison
Copy link
Contributor Author

In Debug; someone receiving an item throws an exception. I can recreate it and send you the error if you don't manage to recreate it. It's something to do with the target not having the correct component to recieve.

I think I fixed everything, but I'm not sure about the first one, I would appreciate it if you would send me the error.

Copy link
Contributor

@DangerRevolution DangerRevolution left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error code:

Exception has occurred: CLR/Robust.Shared.Utility.DebugAssertException
An unhandled exception of type 'Robust.Shared.Utility.DebugAssertException' occurred in Robust.Shared.dll: 'Entity 2479 is not the owner of the component. Component: HandsComponent'
at Robust.Shared.Utility.DebugTools.AssertOwner(Nullable1 uid, IComponent component) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\Utility\DebugTools.cs:line 178 at Robust.Shared.GameObjects.EntitySystem.Resolve[TComp](EntityUid uid, TComp& component, Boolean logMissing) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntitySystem.Resolve.cs:line 22 at Content.Shared.Hands.EntitySystems.SharedHandsSystem.TryPickup(EntityUid uid, EntityUid entity, String handName, Boolean checkActionBlocker, Boolean animateUser, Boolean animate, HandsComponent handsComp, ItemComponent item) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Shared\Hands\EntitySystems\SharedHandsSystem.Pickup.cs:line 50 at Content.Server.OfferItem.OfferItemSystem.Receive(EntityUid uid, OfferItemComponent component) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Server\OfferItem\OfferItemSystem.cs:line 53 at Content.Server.Alert.Click.AcceptOffer.AlertClicked(EntityUid player) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Server\Alert\Click\AcceptingOffer.cs:line 21 at Content.Shared.Alert.AlertsSystem.HandleClickAlert(ClickAlertEvent msg, EntitySessionEventArgs args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Shared\Alert\AlertsSystem.cs:line 324 at Robust.Shared.GameObjects.EventBusExt.HandlerWrapper1.Invoke(EntitySessionMessage1 msg) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EventBusExt.cs:line 46 at Robust.Shared.GameObjects.EntityEventBus.<>c__DisplayClass4_01.b__0(Unit& ev) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 173
at Robust.Shared.GameObjects.EntityEventBus.ProcessSingleEventCore(EventSource source, Unit& unitRef, EventData subs) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 335
at Robust.Shared.GameObjects.EntityEventBus.ProcessSingleEvent(EventSource source, Unit& unitRef, Type eventType) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 324
at Robust.Shared.GameObjects.EntityEventBus.RaiseEvent(EventSource source, Object toRaise) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 267
at Robust.Server.GameObjects.ServerEntityManager.b__8_0(Object _, Object systemMsg) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\GameObjects\ServerEntityManager.cs:line 53
at Robust.Server.GameObjects.ServerEntityManager.DispatchEntityNetworkMessage(MsgEntity message) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\GameObjects\ServerEntityManager.cs:line 280
at Robust.Server.GameObjects.ServerEntityManager.TickUpdate(Single frameTime, Boolean noPredictions, Histogram histogram) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\GameObjects\ServerEntityManager.cs:line 191
at Robust.Server.BaseServer.Update(FrameEventArgs frameEventArgs) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\BaseServer.cs:line 729
at Robust.Server.BaseServer.b__66_1(Object sender, FrameEventArgs args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\BaseServer.cs:line 542
at Robust.Shared.Timing.GameLoop.Run() in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\Timing\GameLoop.cs:line 235
at Robust.Server.BaseServer.MainLoop() in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\BaseServer.cs:line 569
at Robust.Server.Program.ParsedMain(CommandLineArgs args, Boolean contentStart, ServerOptions options) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\Program.cs:line 76
at Robust.Server.Program.Start(String[] args, ServerOptions options, Boolean contentStart) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\Program.cs:line 44
at Robust.Server.ContentStart.Start(String[] args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\ContentStart.cs:line 10
at Content.Server.Program.Main(String[] args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Server\Program.cs:line 9`

offer-item-give-other = {$user} handed {THE($item)} to {$target}
offer-item-give-target = {$user} handed you a {THE($item)}

offer-item-no-give = You're stop offering {THE($item)} to {$target}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
offer-item-no-give = You're stop offering {THE($item)} to {$target}
offer-item-no-give = You stop offering {THE($item)} to {$target}

offer-item-full-hand = You don't have a free hand

offer-item-try-give = You offer the {THE($item)} to {$target}
offer-item-try-give-target = {$user} offer you a {THE($item)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
offer-item-try-give-target = {$user} offer you a {THE($item)}
offer-item-try-give-target = {$user} offers you a {THE($item)}

@@ -0,0 +1,13 @@
offer-item-empty-hand = You don't have anything in your hand to give!

offer-item-full-hand = You don't have a free hand
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
offer-item-full-hand = You don't have a free hand
offer-item-full-hand = Your hand isn't free to receive the item.

@Spatison
Copy link
Contributor Author

Exception has occurred: CLR/Robust.Shared.Utility.DebugAssertException
An unhandled exception of type 'Robust.Shared.Utility.DebugAssertException' occurred in Robust.Shared.dll: 'Entity 2479 is not the owner of the component. Component: HandsComponent'

done

Copy link
Contributor

@DangerRevolution DangerRevolution left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2 of errors; this seems to happen on the target of the giving.

Exception has occurred: CLR/Robust.Shared.Utility.DebugAssertException
An unhandled exception of type 'Robust.Shared.Utility.DebugAssertException' occurred in Robust.Shared.dll: 'Entity 2449 is not the owner of the component. Component: HandsComponent'
at Robust.Shared.Utility.DebugTools.AssertOwner(Nullable1 uid, IComponent component) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\Utility\DebugTools.cs:line 178 at Robust.Shared.GameObjects.EntitySystem.Resolve[TComp](EntityUid uid, TComp& component, Boolean logMissing) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntitySystem.Resolve.cs:line 22 at Content.Shared.Hands.EntitySystems.SharedHandsSystem.TryPickup(EntityUid uid, EntityUid entity, String handName, Boolean checkActionBlocker, Boolean animateUser, Boolean animate, HandsComponent handsComp, ItemComponent item) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Shared\Hands\EntitySystems\SharedHandsSystem.Pickup.cs:line 50 at Content.Server.OfferItem.OfferItemSystem.Receive(EntityUid uid, OfferItemComponent component) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Server\OfferItem\OfferItemSystem.cs:line 53 at Content.Server.Alert.Click.AcceptOffer.AlertClicked(EntityUid player) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Server\Alert\Click\AcceptingOffer.cs:line 21 at Content.Shared.Alert.AlertsSystem.HandleClickAlert(ClickAlertEvent msg, EntitySessionEventArgs args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Shared\Alert\AlertsSystem.cs:line 324 at Robust.Shared.GameObjects.EventBusExt.HandlerWrapper1.Invoke(EntitySessionMessage1 msg) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EventBusExt.cs:line 46 at Robust.Shared.GameObjects.EntityEventBus.<>c__DisplayClass4_01.b__0(Unit& ev) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 173
at Robust.Shared.GameObjects.EntityEventBus.ProcessSingleEventCore(EventSource source, Unit& unitRef, EventData subs) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 335
at Robust.Shared.GameObjects.EntityEventBus.ProcessSingleEvent(EventSource source, Unit& unitRef, Type eventType) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 324
at Robust.Shared.GameObjects.EntityEventBus.RaiseEvent(EventSource source, Object toRaise) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\GameObjects\EntityEventBus.Broadcast.cs:line 267
at Robust.Server.GameObjects.ServerEntityManager.b__8_0(Object _, Object systemMsg) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\GameObjects\ServerEntityManager.cs:line 53
at Robust.Server.GameObjects.ServerEntityManager.DispatchEntityNetworkMessage(MsgEntity message) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\GameObjects\ServerEntityManager.cs:line 280
at Robust.Server.GameObjects.ServerEntityManager.TickUpdate(Single frameTime, Boolean noPredictions, Histogram histogram) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\GameObjects\ServerEntityManager.cs:line 191
at Robust.Server.BaseServer.Update(FrameEventArgs frameEventArgs) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\BaseServer.cs:line 729
at Robust.Server.BaseServer.b__66_1(Object sender, FrameEventArgs args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\BaseServer.cs:line 542
at Robust.Shared.Timing.GameLoop.Run() in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Shared\Timing\GameLoop.cs:line 235
at Robust.Server.BaseServer.MainLoop() in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\BaseServer.cs:line 569
at Robust.Server.Program.ParsedMain(CommandLineArgs args, Boolean contentStart, ServerOptions options) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\Program.cs:line 76
at Robust.Server.Program.Start(String[] args, ServerOptions options, Boolean contentStart) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\Program.cs:line 44
at Robust.Server.ContentStart.Start(String[] args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\RobustToolbox\Robust.Server\ContentStart.cs:line 10
at Content.Server.Program.Main(String[] args) in C:\Users\user\Documents\GitHub\Forks\EE\Einstein-Engines\Content.Server\Program.cs:line 9

@Spatison
Copy link
Contributor Author

Round 2 of errors

which command should I use to run this check?

@DangerRevolution
Copy link
Contributor

Round 2 of errors

which command should I use to run this check?

it happens in any debug build.

should be dotnet build --configuration Debug
then just launch the game

Copy link
Member

@Pspritechologist Pspritechologist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very surface level stuff, will give a deeper review later but looks very cool 👍

offer-item-give-target = {$user} handed you a {THE($item)}

offer-item-no-give = You stop offering {THE($item)} to {$target}
offer-item-no-give-target = {$user} is no longer offer a {THE($item)} to you
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
offer-item-no-give-target = {$user} is no longer offer a {THE($item)} to you
offer-item-no-give-target = {$user} is no longer offer a {THE($item)} to you

@@ -52,7 +52,8 @@ public enum AlertType : byte
SuitPower,
BorgHealth,
BorgCrit,
BorgDead
BorgDead,
Offer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Offer
Offer,

Always use trailing commas, so the diffs look better in the future

@@ -255,6 +255,10 @@ binds:
type: State
key: V
mod1: Shift
- function: OfferItem
type: State
key: V
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what a good bind would be, but Ctrl+V is wild

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now F, I hope it will be better this way.

@Spatison
Copy link
Contributor Author

Spatison commented Jul 1, 2024

Exception has occurred: CLR/Robust.Shared.Utility.DebugAssertException
An unhandled exception of type 'Robust.Shared.Utility.DebugAssertException' occurred in Robust.Shared.dll: 'Entity 2449 is not the owner of the component. Component: HandsComponent'

Fixed it, I hope now for sure.

Copy link
Contributor

@DangerRevolution DangerRevolution left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool; need to do final test when I'm home regarding the exception but otherwise approved :)

Copy link
Member

@VMSolidus VMSolidus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is pretty good, but I have a slight problem with the system, and it's one I think will be an issue with players. I actually completely intentionally loaded this system in a dev environment, without reading any documentation whatsoever on how to do it, and I was incapable of figuring out how to do the Give-Item action until I gave up and read the code. This was done by me to simulate a "New Player" discovering the system organically. I had assumed based on experience with this game that it would be a context-sensitive verb that appears in a right click menu.

The keyboard shortcut method works well, I just wish there were better ways of revealing to the player that a system such as this exists. In the future I would like to see a context-sensitive right click verb being implemented as an optional way to use this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes: C# Changes any cs files Changes: Localization Changes any ftl files Changes: Sprite Changes any png or json in an RSI Changes: UI Changes any XAML files Changes: YML Changes any yml files Holy Shit Priority: 2-High Needs to be resolved as soon as possible Size: 3-Medium For medium issues/PRs Status: Needs Review Someone please review this Type: Feature Creation of or significant changes to a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants