예제 #1
0
    public static PersistentId MakeUniquePersistentId(this CCCSystemBase system)
    {
        NextPersistentId nextPersistentId = system.GetOrCreateSingleton <NextPersistentId>();

        nextPersistentId.NextId.Value++;

        if (nextPersistentId.NextId == PersistentId.Invalid)
        {
            nextPersistentId.NextId.Value++;
        }

        system.SetOrCreateSingleton(nextPersistentId);

        return(nextPersistentId.NextId);
    }
예제 #2
0
    public static PersistentId MakeUniquePersistentId(this ISimWorldReadWriteAccessor accessor)
    {
        // we assume next persisten id exist
        NextPersistentId nextPersistentId = accessor.GetSingleton <NextPersistentId>();

        nextPersistentId.NextId.Value++;

        if (nextPersistentId.NextId == PersistentId.Invalid)
        {
            nextPersistentId.NextId.Value++;
        }

        accessor.SetOrCreateSingleton(nextPersistentId);

        return(nextPersistentId.NextId);
    }