-
Notifications
You must be signed in to change notification settings - Fork 11
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
Repeated object creation #74
Comments
Yes, that is correct |
Shouldn't RescuingWorkTypeDef be a single case? In this case, adding and removal are the same object |
Sorry but I don’t understand what you are saying. |
like this private static readonly Lazy<WorkTypeDef> Lazy = new(() => new()
{
defName = "Rescuing",
labelShort = "WorkType_Rescue_Label".Translate(),
pawnLabel = "WorkType_Rescue_PawnLabel".Translate(),
gerundLabel = "WorkType_Rescue_GerundLabel".Translate(),
description = "WorkType_Rescue_Description".Translate(),
verb = "Rescue",
naturalPriority = 1310,
alwaysStartActive = true,
workTags = WorkTags.Caring | WorkTags.Commoner | WorkTags.AllWork
});
public static WorkTypeDef RescuingWorkTypeDef => Lazy.Value; Each call of |
Why is it important to only have one instance? It’s a tiny object and will get garbage collected as soon as no references to it exist anymore. |
Achtung2/Source/DynamicWorkTypes.cs Lines 128 to 132 in 209d8fc
If there is only one instance, the remove operation don't need 130-132 code , right? |
Well, it’s not only about the worktab visuals. The def database has significant influence on mods and the base game |
Achtung2/Source/Tools.cs
Lines 33 to 45 in 209d8fc
Achtung2/Source/Settings.cs
Lines 132 to 135 in 209d8fc
Achtung2/Source/Main.cs
Lines 210 to 213 in 209d8fc
Tools.RescuingWorkTypeDef
Calling it multiple times will generated different object.The text was updated successfully, but these errors were encountered: