Skip to content

Commit

Permalink
Consolidate events
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Nov 25, 2024
1 parent f57cc58 commit bfe7b8d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 60 deletions.
14 changes: 0 additions & 14 deletions Fika.Core/Modding/Events/FikaClientCreatedEvent.cs

This file was deleted.

14 changes: 0 additions & 14 deletions Fika.Core/Modding/Events/FikaClientDestroyedEvent.cs

This file was deleted.

14 changes: 14 additions & 0 deletions Fika.Core/Modding/Events/FikaNetworkManagerCreatedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Fika.Core.Networking;

namespace Fika.Core.Modding.Events
{
public class FikaNetworkManagerCreatedEvent : FikaEvent
{
public IFikaNetworkManager Manager { get; }

internal FikaNetworkManagerCreatedEvent(IFikaNetworkManager manager)
{
Manager = manager;
}
}
}
14 changes: 14 additions & 0 deletions Fika.Core/Modding/Events/FikaNetworkManagerDestroyedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Fika.Core.Networking;

namespace Fika.Core.Modding.Events
{
public class FikaNetworkManagerDestroyedEvent : FikaEvent
{
public IFikaNetworkManager Manager { get; }

public FikaNetworkManagerDestroyedEvent(IFikaNetworkManager server)
{
Manager = server;
}
}
}
14 changes: 0 additions & 14 deletions Fika.Core/Modding/Events/FikaServerCreatedEvent.cs

This file was deleted.

14 changes: 0 additions & 14 deletions Fika.Core/Modding/Events/FikaServerDestroyedEvent.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Fika.Core/Networking/FikaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public async void Init()
ServerConnection = netClient.Connect(ip, port, "fika.core");
}

FikaEventDispatcher.DispatchEvent(new FikaClientCreatedEvent(this));
FikaEventDispatcher.DispatchEvent(new FikaNetworkManagerCreatedEvent(this));
}

private void OnLoadingProfilePacketReceived(LoadingProfilePacket packet)
Expand Down Expand Up @@ -1208,7 +1208,7 @@ protected void OnDestroy()
Destroy(fikaChat);
}

FikaEventDispatcher.DispatchEvent(new FikaClientDestroyedEvent(this));
FikaEventDispatcher.DispatchEvent(new FikaNetworkManagerDestroyedEvent(this));
}

public void SendData<T>(ref T packet, DeliveryMethod deliveryMethod) where T : INetSerializable
Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Networking/FikaServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public async Task Init()

SetHostRequest body = new(Ips, port, FikaPlugin.UseNatPunching.Value, FikaBackendUtils.IsDedicatedGame);
FikaRequestHandler.UpdateSetHost(body);
FikaEventDispatcher.DispatchEvent(new FikaServerCreatedEvent(this));
FikaEventDispatcher.DispatchEvent(new FikaNetworkManagerCreatedEvent(this));
}

private void OnLoadingProfilePacketReceived(LoadingProfilePacket packet, NetPeer peer)
Expand Down Expand Up @@ -1214,7 +1214,7 @@ protected void OnDestroy()
Destroy(fikaChat);
}

FikaEventDispatcher.DispatchEvent(new FikaServerDestroyedEvent(this));
FikaEventDispatcher.DispatchEvent(new FikaNetworkManagerDestroyedEvent(this));
}

public void SendDataToAll<T>(ref T packet, DeliveryMethod deliveryMethod, NetPeer peerToExclude = null) where T : INetSerializable
Expand Down

0 comments on commit bfe7b8d

Please sign in to comment.