Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Subscription cleanup #1200

Merged
merged 14 commits into from
Oct 25, 2019
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ public void AddCallbackManager(TIndex index, TManager manager)

public List<TManager> GetManagers()
{
foreach (var indexToAdd in indexesToAdd)
if (indexesToAdd.Count > 0)
zeroZshadow marked this conversation as resolved.
Show resolved Hide resolved
{
callbackManagers.Add(indexToCallbackManager[indexToAdd]);
}
foreach (var indexToAdd in indexesToAdd)
{
callbackManagers.Add(indexToCallbackManager[indexToAdd]);
}

indexesToAdd.Clear();
indexesToAdd.Clear();
}

return callbackManagers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class CommandCallbackSystem : ComponentSystem
private readonly GuardedCallbackManagerSet<Type, ICallbackManager> callbackManagers =
new GuardedCallbackManagerSet<Type, ICallbackManager>();

private readonly Dictionary<ulong, (ulong, ICallbackManager)> keyToInternalKeyAndManager =
new Dictionary<ulong, (ulong, ICallbackManager)>();
private readonly Dictionary<ulong, (ulong key, ICallbackManager manager)> keyToInternalKeyAndManager =
new Dictionary<ulong, (ulong key, ICallbackManager manager)>();

private ulong callbacksRegistered = 1;

Expand Down Expand Up @@ -56,7 +56,7 @@ public bool UnregisterCommandRequestCallback(ulong callbackKey)
return false;
}

return keyAndManager.Item2.UnregisterCallback(keyAndManager.Item1);
return keyAndManager.manager.UnregisterCallback(keyAndManager.key);
}

internal void InvokeCallbacks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,21 @@ protected override void OnUpdate()

componentCallbackSystem.InvokeNoLossImminent();

foreach (var behaviour in behavioursToEnable)
if (behavioursToEnable.Count > 0)
{
if (behaviour == null)
foreach (var behaviour in behavioursToEnable)
{
continue;
if (behaviour == null)
{
continue;
}

behaviour.enabled = true;
}

behaviour.enabled = true;
behavioursToEnable.Clear();
}

behavioursToEnable.Clear();

componentCallbackSystem.InvokeLossImminent();

commandCallbackSystem.InvokeCallbacks();
Expand Down