Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Commit

Permalink
Added CharacterSpawn event
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMog committed Feb 20, 2021
1 parent 774f14d commit 44a3dab
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Longship/Events/CharacterSpawnEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Longship.Events
{
public class CharacterSpawnEvent : CharacterEvent
{
public CharacterSpawnEvent(Character character) : base(character)
{
}
}
}
9 changes: 9 additions & 0 deletions Longship/Longship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Longship
{
public const string BuildTag = "0.0.1";
public static Longship Instance { get; private set; }
private static bool _debug = false;
public PluginManager PluginManager { get; }
public ConfigurationManager ConfigurationManager { get; }
public CommandsManager CommandsManager { get; }
Expand Down Expand Up @@ -41,6 +42,14 @@ public void Init()
Log($"Ready.");
}

public static void LogDebug(string message)
{
if (_debug)
{
System.Console.WriteLine($"[Longship][DEBUG] {message}");
}
}

public static void Log(string message)
{
System.Console.WriteLine($"[Longship][INFO] {message}");
Expand Down
2 changes: 2 additions & 0 deletions Longship/Longship.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<Compile Include="Events\CharacterEvent.cs" />
<Compile Include="Events\CharacterHealEvent.cs" />
<Compile Include="Events\CharacterMoveEvent.cs" />
<Compile Include="Events\CharacterSpawnEvent.cs" />
<Compile Include="Events\Event.cs" />
<Compile Include="Events\PlayerChatEvent.cs" />
<Compile Include="Events\PlayerEvent.cs" />
Expand All @@ -71,6 +72,7 @@
<Compile Include="Patches\PatchListenToCharacterDamaged.cs" />
<Compile Include="Patches\PatchListenToCharacterHeal.cs" />
<Compile Include="Patches\PatchListenToCharacterMovements.cs" />
<Compile Include="Patches\PatchListenToCharacterSpawn.cs" />
<Compile Include="Patches\PatchListenToChatMessages.cs" />
<Compile Include="Patches\PatchServerInfo.cs" />
<Compile Include="Patches\PatchZDOManDataPerSeconds.cs" />
Expand Down
14 changes: 14 additions & 0 deletions Longship/Patches/PatchListenToCharacterSpawn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using HarmonyLib;
using Longship.Events;

namespace Longship.Patches
{
[HarmonyPatch(typeof(Character), "Awake")]
public class PatchListenToCharacterSpawn
{
static void Postfix(Character __instance)
{
Longship.Instance.EventManager.DispatchEvent(new CharacterSpawnEvent(__instance));
}
}
}

0 comments on commit 44a3dab

Please sign in to comment.