Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prefab requests array and lock cache dictionary #525

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed unnecessary lock statement
The game is single threaded, so the lock does nothing.
  • Loading branch information
Metious committed Jan 2, 2024
commit 86d134bd357c84f13eaa0c3f5fab706d353a9b7d
33 changes: 15 additions & 18 deletions Nautilus/Assets/ModPrefabCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,31 @@ public void EnterPrefabIntoCache(GameObject prefab)
{
var prefabIdentifier = prefab.GetComponent<PrefabIdentifier>();

if(prefabIdentifier == null)
if (prefabIdentifier == null)
{
InternalLogger.Warn($"ModPrefabCache: prefab {prefab.name} is missing a PrefabIdentifier component! Unable to add to cache.");
return;
}

lock (Entries)
if (!Entries.ContainsKey(prefabIdentifier.classId))
{
if(!Entries.ContainsKey(prefabIdentifier.classId))
Entries.Add(prefabIdentifier.classId, prefab);
InternalLogger.Debug($"ModPrefabCache: added prefab {prefab}");
// Proper prefabs can never exist in the scene, so parenting them is dangerous and pointless.
if (prefab.IsPrefab())
{
Entries.Add(prefabIdentifier.classId, prefab);
InternalLogger.Debug($"ModPrefabCache: added prefab {prefab}");
// Proper prefabs can never exist in the scene, so parenting them is dangerous and pointless.
if (prefab.IsPrefab())
{
InternalLogger.Debug($"Game Object: {prefab} is a proper prefab. Skipping parenting for cache.");
}
else
{
prefab.transform.parent = _prefabRoot;
prefab.SetActive(true);
}
InternalLogger.Debug($"Game Object: {prefab} is a proper prefab. Skipping parenting for cache.");
}
else // this should never happen
else
{
InternalLogger.Debug($"ModPrefabCache: prefab {prefabIdentifier.classId} already existed in cache!");
}
prefab.transform.parent = _prefabRoot;
prefab.SetActive(true);
}
}
else
{
InternalLogger.Debug($"ModPrefabCache: prefab {prefabIdentifier.classId} already existed in cache!");
}
}

public void RemoveCachedPrefab(string classId)
Expand Down