|
|
@@ -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); |
|
|
|
} |
|
|
|