Skip to content

Commit

Permalink
Update PartyComponentRegistry.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
EgardA committed Sep 29, 2024
1 parent 07a03e8 commit f4f9b6c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Party.PartyComponents;

Expand All @@ -12,6 +13,9 @@ namespace GameInterface.Services.PartyComponents;
/// </summary>
internal class PartyComponentRegistry : RegistryBase<PartyComponent>
{
private const string PartyComponentIdPrefix = "CoopPartyComponent";
private static int InstanceCounter = 0;

public PartyComponentRegistry(IRegistryCollection collection) : base(collection) { }

public override IEnumerable<Type> ManagedTypes { get; } = new Type[]
Expand All @@ -37,7 +41,8 @@ public override void RegisterAll()

protected override string GetNewId(PartyComponent party)
{
return Guid.NewGuid().ToString();
return $"{PartyComponentIdPrefix}_{Interlocked.Increment(ref InstanceCounter)}";

}
}

0 comments on commit f4f9b6c

Please sign in to comment.