public virtual void OnLoaded(ICoreAPI api)
        {
            if (api.Side == EnumAppSide.Client)
            {
                return;
            }

            ICoreServerAPI sapi = api as ICoreServerAPI;

            this.sapi = sapi;

            rockStrataGen = new GenRockStrataNew();
            rockStrataGen.setApi(sapi);
            rockStrataGen.initWorldGen();

            depositGen = new GenDeposits();
            depositGen.setApi(sapi);
            depositGen.initWorldGen(false);

            sapi.Event.ServerRunPhase(EnumServerRunPhase.RunGame, () =>
            {
                DepositVariant[] deposits = api.ModLoader.GetModSystem <GenDeposits>()?.Deposits;
                if (deposits == null)
                {
                    return;
                }

                for (int i = 0; i < deposits.Length; i++)
                {
                    DepositVariant variant = deposits[i];

                    if (variant.WithOreMap)
                    {
                        pageCodes[variant.Code]      = variant.HandbookPageCode;
                        depositsByCode[variant.Code] = variant;
                        if (variant.HandbookPageCode == null)
                        {
                            api.World.Logger.Warning("Deposit " + variant.Code + " has no handbook page code. Links created by the prospecting pick will not work without it.");
                        }
                    }

                    for (int k = 0; variant.ChildDeposits != null && k < variant.ChildDeposits.Length; k++)
                    {
                        DepositVariant childVariant = variant.ChildDeposits[k];
                        if (!childVariant.WithOreMap)
                        {
                            continue;
                        }

                        if (childVariant.HandbookPageCode == null)
                        {
                            api.World.Logger.Warning("Child Deposit " + childVariant.Code + " of deposit " + variant.Code + " has no handbook page code. Links created by the prospecting pick will not work without it.");
                        }

                        pageCodes[childVariant.Code]      = childVariant.HandbookPageCode;
                        depositsByCode[childVariant.Code] = childVariant;
                    }
                }
            });
        }
Ejemplo n.º 2
0
        public void OnLoaded(ICoreAPI api)
        {
            if (api.Side == EnumAppSide.Client)
            {
                return;
            }

            ICoreServerAPI sapi = api as ICoreServerAPI;

            this.sapi = sapi;

            rockStrataGen = new GenRockStrataNew();
            rockStrataGen.setApi(sapi);
            rockStrataGen.initWorldGen();

            sapi.Event.ServerRunPhase(EnumServerRunPhase.RunGame, () =>
            {
                DepositVariant[] deposits = api.ModLoader.GetModSystem <GenDeposits>()?.Deposits;
                if (deposits == null)
                {
                    return;
                }

                for (int i = 0; i < deposits.Length; i++)
                {
                    DepositVariant variant = deposits[i];

                    if (variant.WithOreMap)
                    {
                        if (absAvgQuantity.ContainsKey(variant.Code))
                        {
                            absAvgQuantity[variant.Code] += variant.GetAbsAvgQuantity();
                        }
                        else
                        {
                            absAvgQuantity[variant.Code] = variant.GetAbsAvgQuantity();
                            pageCodes[variant.Code]      = variant.HandbookPageCode;
                        }
                    }



                    for (int k = 0; variant.ChildDeposits != null && k < variant.ChildDeposits.Length; k++)
                    {
                        DepositVariant childVariant = variant.ChildDeposits[k];
                        if (!childVariant.WithOreMap)
                        {
                            continue;
                        }

                        absAvgQuantity[childVariant.Code] = childVariant.GetAbsAvgQuantity();
                        pageCodes[childVariant.Code]      = childVariant.HandbookPageCode;
                    }
                }
            });
        }