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

Port Chat from Outdated branch #1426

Merged
merged 89 commits into from
Mar 5, 2024
Merged

Port Chat from Outdated branch #1426

merged 89 commits into from
Mar 5, 2024

Conversation

David-Goru
Copy link
Contributor

@David-Goru David-Goru commented Feb 18, 2024

Summary

This PR aims to have the chat from the outdated branch (#89) working. It also adds some more functionality, trying to replicate some of the mechanics of SS13

Currently, lobby and in-game chats (should) work. You can add new channels or modify existing ones at Content > Data > UI > Chat > Channels (Create > SS3D > UI > Chat > Chat Channel for a new channel). The Channels list (in Content > Data > UI > Chat) should be updated if removing/adding new channels

As on the original chat, channels can have abbreviations, colors and whether if they can be excluded from tabs or not (hidable). Messages sent to non-hidable channels will be always present in all chats/tabs. Currently the only non-hidable channel is System

On top of porting the original chat, this PR also adds the chat to the lobby and roles required to channels. Only players with same or higher role will be able to use specific channels, like System, which requires Administrator role or higher

Some things that are not done yet, but I'd like to include if possible (no promises, though):

  • A system to send messages from non-player entities (like a welcome message from the server, or info about round starting/ending)
  • This can be done calling the method ChatMessageSender.SendServerMessage if it should be seen by all players, or ChatMessageSender.SendServerMessageToCurrentPlayer if it should be sent only to the current client
  • Distance-based channels (like general/default physical chat, shout chat for more distance, whisper chat for less distance)
  • General/Shout/Whisper channels are distance-based. To create new distance-based channels, just enable "distanceBased" in the ChatChannel ScriptableObject, and set the "maxDistance" (using Unity units) at which messages will be audible for the rest of players
  • Walls/obstacles are not considered yet. Maybe in the future :P
  • A system to add/remove channels from a player on runtime (so it could be linked to the radios/headsets, for department-specific channels)
  • ChatChannels can have "requiredTraitInHeadset" set up in the ScriptableObject to link them to headsets. System can be expanded by modifying the InGameChatController script, which currently only checks for inventory changes and looks for headsets
  • Option to add text format on specific channels (like System)
  • If "canFormatText" is enabled in the ChatChannel ScriptableObject, any message sent to that channel will accept typical Unity texts formatting (like <size=30>Hello</size>). Currently is only enabled in System messages. When sending a formatted text, remember to close the tag!!
  • Chat log for the server (inside Game > Logs)
  • I've implemented a really simple chat log for now, as I don't think we need anything more complex at this state. That said, it should probably use a fancier system

PR checklist

  • The game builds properly without errors.
  • No unrelated changes are present.
  • No "trash" files are committed.
  • Relevant code is documented.
  • Update the related GitBook document, or create a new one if needed.

Pictures/Videos

Chat_basic_functionality_working.mp4
2024-02-18.13-54-33.mp4

Testing

Open several clients with different roles, and use the chat in the lobby and in-game. When in-game, use different channels

Networking checklist

  • Works from host in host mode.
  • Works from server in server mode.
  • Works on server in client mode.
  • Works and is syncronized across different clients.
  • Is persistent.

Changes

I decided to remove the "ChatRegister" from the original chat to make things easier. I'm using broadcasts messages for the chat. First time working with multiplayer on this level, so I may have done something really wrong - would appreciate if someone could check I'm not doing anything too silly

I've also modified Trait.cs to fix a bug where two equal traits were returning non-equal due to GetType() methods returning the base type for the first trait being compared, and the second trait was returning the specific type (for example, Security trait was returining Trait as type for the first object, and IDPermission (which inherits from Trait) for the second object, although they were exactly the same)

Related issues/PRs

Closes #1286

Assets/Scripts/SS3D/Systems/Chat/ChatWindow.cs Outdated Show resolved Hide resolved
@joaoburatto
Copy link
Contributor

Code fine, needs runtime testing.

@David-Goru
Copy link
Contributor Author

David-Goru commented Feb 24, 2024

Found a UI concept of how the chat should be (https://ss3d.gitbook.io/design/basic-game-mechanics/user-interface/game/player-hud) and decided to update both the UI visuals and how text is formatted to match a bit more that design

imagen

@stilnat
Copy link
Contributor

stilnat commented Feb 25, 2024

got some trouble with floating headset on clients but that's a minor issue we can make a small issue for it.
image

@David-Goru
Copy link
Contributor Author

got some trouble with floating headset on clients but that's a minor issue we can make a small issue for it. image

Should be fixed in my last commit!

@stilnat stilnat dismissed joaoburatto’s stale review March 5, 2024 11:15

all requested changes are done

Copy link
Contributor

@stilnat stilnat left a comment

Choose a reason for hiding this comment

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

great work

@stilnat stilnat merged commit dc6f212 into RE-SS3D:develop Mar 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Comms Tasks relating to the communication systems.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port Chat from Outdated branch
4 participants