Browse Source

Fix double event call, jankily

tags/v1.2.0
NGnius (Graham) 4 years ago
parent
commit
d2c9cde1d2
2 changed files with 14 additions and 0 deletions
  1. +1
    -0
      GamecraftModdingAPI/Events/MenuActivatedPatch.cs
  2. +13
    -0
      GamecraftModdingAPI/Events/SimpleEventHandlerEngine.cs

+ 1
- 0
GamecraftModdingAPI/Events/MenuActivatedPatch.cs View File

@@ -31,6 +31,7 @@ namespace GamecraftModdingAPI.Events
{
firstLoad = false;
FullGameFields.Init(__instance);
//Application.Application.SetFullGameCompositionRoot(__instance);
Logging.Log("Dispatching App Init event");
EventManager.GetEventEmitter("GamecraftModdingAPIApplicationInitializedEventEmitter").Emit();
}


+ 13
- 0
GamecraftModdingAPI/Events/SimpleEventHandlerEngine.cs View File

@@ -20,6 +20,10 @@ namespace GamecraftModdingAPI.Events

private bool isActivated = false;

private bool jankActivateFix = false;

private bool jankDestroyFix = false;

private readonly Action<EntitiesDB> onActivated;

private readonly Action<EntitiesDB> onDestroyed;
@@ -32,6 +36,8 @@ namespace GamecraftModdingAPI.Events
{
if (entityView.type.Equals(this.type))
{
jankActivateFix = !jankActivateFix;
if (jankActivateFix) return;
isActivated = true;
onActivatedInvokeCatchError(entitiesDB);
}
@@ -51,12 +57,19 @@ namespace GamecraftModdingAPI.Events
}
}

public void Deactivate()
{
isActivated = false;
}

public void Ready() { }

public void Remove(ref ModEventEntityStruct entityView, EGID egid)
{
if (entityView.type.Equals(this.type) && isActivated)
{
jankDestroyFix = !jankDestroyFix;
if (jankDestroyFix) return;
isActivated = false;
onDestroyedInvokeCatchError(entitiesDB);
}


Loading…
Cancel
Save