コード例 #1
0
        private static List <ItemDrop.ItemData> GetDropListItems(DropTable dropTable)
        {
            try
            {
                var context = DropLinkCache.GetLink(dropTable);

                var dropTemplates = DropConfigManager.GetPossibleDrops(context, dropTable);

#if DEBUG
                Log.LogDebug("Potential drops: " + dropTemplates.Count);
                foreach (var drop in dropTemplates)
                {
                    Log.LogDebug("\t" + drop.Drop.m_item.name);
                }
#endif

                if (dropTemplates.Count == 0)
                {
                    return(new(0));
                }

                return(DropTableManager.GetItemDrops(dropTable, context));
            }
            catch (Exception e)
            {
                Log.LogError("Error during calculation of item drops", e);
                return(new(0));
            }
        }
コード例 #2
0
    private static void CreateLink(DropTable dropTable, GameObject source)
    {
        try
        {
            if (dropTable is null || source is null)
            {
                return;
            }

            DropSourceTemplateLink link = new()
            {
                Source = source,
            };

            string sourceName = source.GetCleanedName();

            if (string.IsNullOrWhiteSpace(sourceName))
            {
                return;
            }

#if FALSE && DEBUG
            Log.LogTrace($"Linking entity to config: '{source}':'{sourceName}'");
#endif

            // Configs haven't arrived yet.
            if (ConfigurationManager.DropTableConfigs is null)
            {
                Log.LogDebug($"{source} woke before configs were loaded. Skipping config for '{source}'");
                return;
            }

            if (ConfigurationManager.DropTableConfigs.TryGet(sourceName, out var config))
            {
                link.EntityConfig = config;
            }

            DropLinkCache.SetLink(dropTable, link);
        }
        catch (Exception e)
        {
            Log.LogError($"Error while attempting to create associate drop table for object with config.", e);
        }
    }
コード例 #3
0
        private static List <GameObject> GetDropList(DropTable dropTable, int dropCount)
        {
            try
            {
                var context = DropLinkCache.GetLink(dropTable);

                var dropTemplates = DropConfigManager.GetPossibleDrops(context, dropTable);

                if (dropTemplates.Count == 0)
                {
                    return(new(0));
                }

                return(DropTableManager.GetDrops(dropTable, context));
            }
            catch (Exception e)
            {
                Log.LogError("Error during calculation of item drops", e);
                return(new(0));
            }
        }
コード例 #4
0
 private static bool UseOriginal(DropTable dropTable)
 {
     return(DropLinkCache.GetLink(dropTable)?.EntityConfig is null);
 }