private GroupAndItemConfig CollectTreeLoot()
        {
            var config = new GroupAndItemConfig();

            foreach (var lt in Singleton <RuntimeHurtDB> .Instance.GetOrderedAssetsAssignableToType <LootTree>())
            {
                try
                {
                    if (lt.name.ToLower().Contains("testnode") || lt.name.ToLower().Contains("recipe") || lt.name.ToLower().Contains("cost") || lt.name.ToLower().Contains("spawn") || lt.name.ToLower().Contains("builder"))
                    {
                        PrintWarning($"{lt.name} не в лутконфиге игры");
                        continue;
                    }
                    var gc = new GroupAndItemConfig()
                    {
                        Note = lt.name
                    };
                    CollectTreeLootConfig(lt.Root, ref gc);
                    if (config.List == null)
                    {
                        config.List = new List <GroupAndItemConfig>();
                    }
                    config.List.Add(gc);
                }
                catch { }
            }
            return(config);
        }
Beispiel #2
0
        private GroupAndItemConfig CollectTreeLoot()
        {
            var config = new GroupAndItemConfig();

            foreach (var lt in Singleton <RuntimeHurtDB> .Instance.GetOrderedAssetsAssignableToType <LootTree>())
            {
                try
                {
                    if (lt.name.ToLower().Contains("testnode") || lt.name.ToLower().Contains("recipe") ||
                        lt.name.ToLower().Contains("cost") || lt.name.ToLower().Contains("spawn") ||
                        lt.name.ToLower().Contains("builder"))
                    {
                        PrintWarning($"{lt.name} is not part of the lootconfig in game.");
                        continue;
                    }

                    var gc = new GroupAndItemConfig()
                    {
                        Note = lt.name
                    };
                    CollectTreeLootConfig(lt.Root, ref gc);
                    if (config.Children == null)
                    {
                        config.Children = new List <GroupAndItemConfig>();
                    }
                    config.Children.Add(gc);
                }
                catch (Exception e)
                {
                    Puts(e.ToString());
                }
            }
            return(config);
        }
Beispiel #3
0
        private bool SetLootTreeConfig(GroupAndItemConfig config, LootTree root)
        {
            depth++;

            bool modified = false;

            foreach (var ch in config.Children)
            {
                depth++;
                modified = SubSetLootTreeConfig(ch, root.Root);
                depth--;
            }
            depth--;
            return(false);
        }
        private void CollectTreeLootConfig(LootTreeNodeRollGroup root, ref GroupAndItemConfig lootconfig)
        {
            var gc = new GroupAndItemConfig()
            {
                GUID    = root.Guid,
                Note    = root.Note,
                RollAll = root.RollAll,
                RollWithoutReplacement = root.RollWithoutReplacement,
                RollCount          = root.RollCount,
                ProbabilityCache   = root.ProbabilityCache,
                SiblingProbability = root.SiblingProbability,
                FailsPerSuccess    = root.FailsPerSuccess,
            };

            foreach (var child in root.Children)
            {
                SubCollectTreeLootConfig(child, ref gc);
            }
            if (lootconfig.List == null)
            {
                lootconfig.List = new List <GroupAndItemConfig>();
            }
            lootconfig.List.Add(gc);
        }
        private bool SubSetLootTreeConfig(GroupAndItemConfig config, LootTreeNodeBase root)
        {
            var ltnrg = root as LootTreeNodeRollGroup;

            if (ltnrg != null)
            {
                if (config.GUID != ltnrg.Guid)
                {
                    return(false);
                }

                ltnrg.RollAll = config.RollAll;
                ltnrg.RollWithoutReplacement = config.RollWithoutReplacement;
                ltnrg.RollCount = config.RollCount;

                bool modified = false;
                if (config.List == null)
                {
                    return(modified);
                }
                foreach (var ch in config.List)
                {
                    foreach (var child in ltnrg.Children)
                    {
                        depth++;
                        bool m = SubSetLootTreeConfig(ch, child);
                        depth--;
                        modified |= m;
                        if (m)
                        {
                            break;
                        }
                    }
                }
                return(modified);
            }


            var ltnst = root as LootTreeNodeSubtree;

            if (ltnst != null)
            {
                if (config.GUID != ltnst.Guid)
                {
                    return(false);
                }

                ltnst.ProbabilityCache   = config.ProbabilityCache;
                ltnst.SiblingProbability = config.SiblingProbability;
                ltnst.FailsPerSuccess    = config.FailsPerSuccess;

                bool modified = false;
                if (config.List == null)
                {
                    return(modified);
                }
                foreach (var ch in config.List)
                {
                    depth++;
                    bool m = SubSetLootTreeConfig(ch, ltnst.LootTree.Root);
                    depth--;
                    modified |= m;
                    if (m)
                    {
                        break;
                    }
                }

                return(modified);
            }

            var ltniga = root as LootTreeNodeItemGeneratorAdvanced;

            if (ltniga != null)
            {
                if (config.GUID != ltniga.Guid)
                {
                    return(false);
                }
                var p = ltniga.StackSize as MutatorGeneratorFloatFromReferenceCurve;
                if (p != null)
                {
                    var value = config.Mutliplier * (config.Force ? 1 : _config.GlobalStackSizeMultiplier);
                    p.Mutliplier = value;
                }
                return(true);
            }

            var itemgenerator = root as LootTreeNodeItemGenerator;

            if (itemgenerator != null)
            {
                if (config.GUID != itemgenerator.Guid)
                {
                    return(false);
                }
                var value1 = Mathf.CeilToInt((float)config.MinDrop * (config.Force ? 1 : _config.GlobalStackSizeMultiplier));
                var value2 = Mathf.CeilToInt((float)config.MaxDrop * (config.Force ? 1 : _config.GlobalStackSizeMultiplier));
                itemgenerator.MinStack = value1;
                itemgenerator.MaxStack = value2;
                return(true);
            }
            return(false);
        }
        private void SubCollectTreeLootConfig(LootTreeNodeBase child, ref GroupAndItemConfig gconfig)
        {
            var ltnrg = child as LootTreeNodeRollGroup;

            if (ltnrg != null)
            {
                var gc = new GroupAndItemConfig()
                {
                    GUID    = ltnrg.Guid,
                    Note    = ltnrg.Note,
                    RollAll = ltnrg.RollAll,
                    RollWithoutReplacement = ltnrg.RollWithoutReplacement,
                    RollCount = ltnrg.RollCount
                };
                foreach (var ch in ltnrg.Children)
                {
                    SubCollectTreeLootConfig(ch, ref gc);
                }
                if (gconfig.List == null)
                {
                    gconfig.List = new List <GroupAndItemConfig>();
                }
                gconfig.List.Add(gc);
                return;
            }

            var ltnst = child as LootTreeNodeSubtree;

            if (ltnst != null)
            {
                var gc = new GroupAndItemConfig()
                {
                    GUID               = ltnst.Guid,
                    ProbabilityCache   = ltnst.ProbabilityCache,
                    SiblingProbability = ltnst.SiblingProbability,
                    FailsPerSuccess    = ltnst.FailsPerSuccess
                };
                SubCollectTreeLootConfig(ltnst.LootTree.Root, ref gc);
                if (gconfig.List == null)
                {
                    gconfig.List = new List <GroupAndItemConfig>();
                }
                gconfig.List.Add(gc);
                return;
            }

            var ltnitemgenerator = child as LootTreeNodeItemGeneratorContainer;

            if (ltnitemgenerator != null)
            {
                var gc = new GroupAndItemConfig()
                {
                    GUID               = ltnitemgenerator.Guid,
                    ProbabilityCache   = ltnitemgenerator.ProbabilityCache,
                    SiblingProbability = ltnitemgenerator.SiblingProbability,
                    FailsPerSuccess    = ltnitemgenerator.FailsPerSuccess,
                };
                SubCollectTreeLootConfig(ltnitemgenerator.ChildTree, ref gc);
                if (gconfig.List == null)
                {
                    gconfig.List = new List <GroupAndItemConfig>();
                }
                gconfig.List.Add(gc);
                return;
            }

            var ltsfn = child as LootTreeSourceFilterNode;

            if (ltsfn != null)
            {
                if (ltsfn.LootTree != null)
                {
                    var gc = new GroupAndItemConfig()
                    {
                        GUID               = ltsfn.Guid,
                        ProbabilityCache   = ltsfn.ProbabilityCache,
                        SiblingProbability = ltsfn.SiblingProbability,
                        FailsPerSuccess    = ltsfn.FailsPerSuccess,
                        LevelMin           = ltsfn.LevelMin,
                        LevelMax           = ltsfn.LevelMax,
                    };
                    SubCollectTreeLootConfig(ltsfn.LootTree, ref gc);
                    if (gconfig.List == null)
                    {
                        gconfig.List = new List <GroupAndItemConfig>();
                    }
                    gconfig.List.Add(gc);
                }
                return;
            }

            var ltniga = child as LootTreeNodeItemGeneratorAdvanced;

            if (ltniga != null)
            {
                var p = ltniga.StackSize as MutatorGeneratorFloatFromReferenceCurve;
                if (p != null)
                {
                    if (gconfig.List == null)
                    {
                        gconfig.List = new List <GroupAndItemConfig>();
                    }
                    gconfig.List.Add(new GroupAndItemConfig()
                    {
                        GUID       = ltniga.Guid,
                        Name       = ltniga.LootResult?.name,
                        Mutliplier = p.Mutliplier
                    });
                }
                return;
            }

            var itemgenerator = child as LootTreeNodeItemGenerator;

            if (itemgenerator != null)
            {
                if (gconfig.List == null)
                {
                    gconfig.List = new List <GroupAndItemConfig>();
                }
                gconfig.List.Add(new GroupAndItemConfig()
                {
                    GUID    = itemgenerator.Guid,
                    Name    = itemgenerator.LootResult?.name,
                    MinDrop = itemgenerator.MinStack,
                    MaxDrop = itemgenerator.MaxStack
                });
                return;
            }
        }
Beispiel #7
0
        private bool SubSetLootTreeConfig(GroupAndItemConfig config, LootTreeNodeBase root)
        {
            var rollGroup = root as LootTreeNodeRollGroup;

            if (rollGroup != null)
            {
                if (config.GUID != rollGroup.Guid)
                {
                    return(false);
                }

                rollGroup.RollAll = config.RollAll;
                rollGroup.RollWithoutReplacement = config.RollWithoutReplacement;
                rollGroup.RollCount = config.RollCount;

                bool modified = false;
                if (config.Children == null)
                {
                    return(modified);
                }
                foreach (var ch in config.Children)
                {
                    foreach (var child in rollGroup.Children)
                    {
                        depth++;
                        bool m = SubSetLootTreeConfig(ch, child);
                        depth--;
                    }
                }
                return(modified);
            }


            var subtree = root as LootTreeNodeSubtree;

            if (subtree != null)
            {
                if (config.GUID != subtree.Guid)
                {
                    return(false);
                }

                subtree.ProbabilityCache   = config.ProbabilityCache;
                subtree.SiblingProbability = config.SiblingProbability;
                subtree.FailsPerSuccess    = config.FailsPerSuccess;

                bool modified = false;
                if (config.Children == null)
                {
                    return(modified);
                }
                foreach (var ch in config.Children)
                {
                    depth++;
                    bool m = SubSetLootTreeConfig(ch, subtree.LootTree.Root);
                    depth--;
                }

                return(modified);
            }

            var itemGeneratorAdvanced = root as LootTreeNodeItemGeneratorAdvanced;

            if (itemGeneratorAdvanced != null)
            {
                if (config.GUID != itemGeneratorAdvanced.Guid)
                {
                    return(false);
                }
                var p = itemGeneratorAdvanced.StackSize as MutatorGeneratorFloatFromReferenceCurve;
                if (p != null)
                {
                    var value = config.Mutliplier * (config.Force ? 1 : _pluginConfig.GlobalStackSizeMultiplier);
                    p.Mutliplier = value;
                }
                return(true);
            }

            var itemGenerator = root as LootTreeNodeItemGenerator;

            if (itemGenerator != null)
            {
                if (config.GUID != itemGenerator.Guid)
                {
                    return(false);
                }
                var value1 = Mathf.CeilToInt((float)config.MinDrop * (config.Force ? 1 : _pluginConfig.GlobalStackSizeMultiplier));
                var value2 = Mathf.CeilToInt((float)config.MaxDrop * (config.Force ? 1 : _pluginConfig.GlobalStackSizeMultiplier));
                itemGenerator.MinStack           = value1;
                itemGenerator.MaxStack           = value2;
                itemGenerator.FailsPerSuccess    = config.FailsPerSuccess;
                itemGenerator.SiblingProbability = config.SiblingProbability;
                itemGenerator.ProbabilityCache   = config.ProbabilityCache;
                itemGenerator.SiblingProbability = config.SiblingProbability;
                if (GlobalItemManager.Instance.ItemGenerators.ContainsKey(config.ItemID))
                {
                    itemGenerator.LootResult = GlobalItemManager.Instance.ItemGenerators[config.ItemID];
                    config.Name = itemGenerator.LootResult?.ToString();
                }

                else if (config.ItemID != 0)
                {
                    Puts($"itemID \"{config.ItemID}\" doesn't exist for {config.Name} with GUID {config.GUID}.");
                }

                return(true);
            }
            return(false);
        }