diff options
| author | Sarah Bradley <git@sarahduck.ca> | 2023-12-18 19:51:26 -0800 |
|---|---|---|
| committer | Sarah Bradley <git@sarahduck.ca> | 2023-12-18 19:51:26 -0800 |
| commit | 4b7966ffda3b6ad34d355148ddccbe2959061730 (patch) | |
| tree | 8be290357abb5d7cf8c72a803f3be63b3e353d7e /MouseLocal.cs | |
| parent | fc3874657348bde6ce7e3fab625c92dfec91baaa (diff) | |
Networked Mice!!
Also combined Spritesheet + Username packets into one UserInfo packet.
Diffstat (limited to 'MouseLocal.cs')
| -rw-r--r-- | MouseLocal.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/MouseLocal.cs b/MouseLocal.cs new file mode 100644 index 0000000..6a84731 --- /dev/null +++ b/MouseLocal.cs @@ -0,0 +1,29 @@ +using System.Numerics; +using OnekoOnline.Net; +using LiteNetLib.Utils; +using Raylib_cs; + +namespace OnekoOnline; + +class MouseLocal : Mouse +{ + public MouseLocal() : base() + { + Client.UserConnected += user => { + MouseNet NewNetMouse = new(user); + }; + } + + public override void Update(float delta) + { + Visible = Raylib.IsCursorOnScreen() && Raylib.IsWindowFocused(); + Position = Raylib.GetMousePosition()/OnekoOnline.WindowScale; + + if (Visible && OnekoOnline.Client!.Connected) { + NetDataWriter writer = new(); + writer.Put(new PacketInfo(PacketType.MousePosition, OnekoOnline.Client.Id)); + writer.Put(Position); + OnekoOnline.Client?.ConnectedServer.Send(writer, LiteNetLib.DeliveryMethod.Unreliable); + } + } +}
\ No newline at end of file |
