Ejemplo n.º 1
0
 public void UpdateStaticDeposit()
 {
     if (isStatic)
     {
         if (_linkedDeposit == null)
         {
             _linkedDeposit = new ResourceDepositManager.ResourceDeposit();
         }
         else
         {
             _linkedDeposit._resources.Clear();
         }
         if (staticType == QuarryType.None)
         {
             _linkedDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, 1000, 0.3f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
             _linkedDeposit.Add(ItemManager.FindItemDefinition("metal.ore"), 1f, 1000, 5f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
             _linkedDeposit.Add(ItemManager.FindItemDefinition("sulfur.ore"), 1f, 1000, 7.5f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
             _linkedDeposit.Add(ItemManager.FindItemDefinition("hq.metal.ore"), 1f, 1000, 75f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
         }
         else if (staticType == QuarryType.Basic)
         {
             _linkedDeposit.Add(ItemManager.FindItemDefinition("metal.ore"), 1f, 1000, 2f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
             _linkedDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, 1000, 0.3f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
         }
         else if (staticType == QuarryType.Sulfur)
         {
             _linkedDeposit.Add(ItemManager.FindItemDefinition("sulfur.ore"), 1f, 1000, 2f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
         }
         else if (staticType == QuarryType.HQM)
         {
             _linkedDeposit.Add(ItemManager.FindItemDefinition("hq.metal.ore"), 1f, 1000, 30f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
         }
         _linkedDeposit.Add(ItemManager.FindItemDefinition("crude.oil"), 1f, 1000, 10f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, true);
     }
 }
 public ResourceDepositManager.ResourceDeposit GetFromPosition(Vector3 pos)
 {
     ResourceDepositManager.ResourceDeposit resourceDeposit = (ResourceDepositManager.ResourceDeposit)null;
     if (this._deposits.TryGetValue(ResourceDepositManager.GetIndexFrom(pos), out resourceDeposit))
     {
         return(resourceDeposit);
     }
     return((ResourceDepositManager.ResourceDeposit)null);
 }
Ejemplo n.º 3
0
 public static ResourceDepositManager.ResourceDeposit GetOrCreate(Vector3 pos)
 {
     ResourceDepositManager.ResourceDeposit fromPosition = ResourceDepositManager.Get().GetFromPosition(pos);
     if (fromPosition != null)
     {
         return(fromPosition);
     }
     return(ResourceDepositManager.Get().CreateFromPosition(pos));
 }
Ejemplo n.º 4
0
        //
        // Edit the stored resource deposits
        //
        void OnServerInitialized()
        {
            ValidateConfig();
            foreach (Deposit deposit in data.changedDeposits)
            {
                ResourceDepositManager.ResourceDeposit rd = ResourceDepositManager.GetOrCreate(GetVector3(deposit.origin));

                int oreCount = 0;
                foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry resource in rd._resources)
                {
                    switch (resource.type.shortname)
                    {
                    case "sulfur.ore":
                        oreCount++;
                        break;

                    case "metal.ore":
                        oreCount++;
                        break;

                    case "hq.metal.ore":
                        oreCount++;
                        break;

                    default:
                        break;
                    }
                }

                if (oreCount > 1)
                {
                    return;
                }

                ItemDefinition sulfur = ItemManager.itemList.Find(x => x.shortname == "sulfur.ore");
                ItemDefinition metal  = ItemManager.itemList.Find(x => x.shortname == "metal.ore");
                ItemDefinition hq     = ItemManager.itemList.Find(x => x.shortname == "hq.metal.ore");

                foreach (DepositEntry entry in deposit.entries)
                {
                    switch (entry.type)
                    {
                    case OreType.Metal:
                        rd.Add(metal, 1, entry.amount, entry.workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        break;

                    case OreType.Sulfur:
                        rd.Add(sulfur, 1, entry.amount, entry.workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private void OnResourceDepositCreated(ResourceDepositManager.ResourceDeposit resourceDeposit)
 {
     if (Random.Range(0f, 100f) >= oilCrateChance)
     {
         return;
     }
     if (!pumpjackSolid)
     {
         resourceDeposit._resources.Clear();
     }
     resourceDeposit.Add(ItemManager.FindItemDefinition("crude.oil"), 1f, 50000, Random.Range(oilGatherWorkNeededMin, oilGatherWorkNeededMax), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
 }
Ejemplo n.º 6
0
 public override void ServerInit()
 {
     base.ServerInit();
     if (!this.isStatic)
     {
         this._linkedDeposit = ResourceDepositManager.GetOrCreate(base.transform.position);
     }
     else
     {
         this.UpdateStaticDeposit();
     }
     this.SpawnChildEntities();
     this.engineSwitchPrefab.instance.SetFlag(BaseEntity.Flags.On, base.HasFlag(BaseEntity.Flags.On), false, true);
 }
Ejemplo n.º 7
0
 public override void ServerInit()
 {
     base.ServerInit();
     if (!isStatic)
     {
         ResourceDepositManager.ResourceDeposit resourceDeposit = (_linkedDeposit = ResourceDepositManager.GetOrCreate(base.transform.position));
     }
     else
     {
         UpdateStaticDeposit();
     }
     SpawnChildEntities();
     engineSwitchPrefab.instance.SetFlag(Flags.On, HasFlag(Flags.On));
 }
Ejemplo n.º 8
0
        void getDeposit(BasePlayer player, string command, string[] args)
        {
            if (!permission.UserHasPermission(player.UserIDString, $"oldschoolquarries.probe"))
            {
                PrintToChat(player, Lang("NoCommandPermission", player.UserIDString));
                return;
            }

            ResourceDepositManager.ResourceDeposit rd = ResourceDepositManager.GetOrCreate(player.transform.position);
            if (rd == null)
            {
                PrintToChat(player, Lang("NoResources", player.UserIDString));
                return;
            }

            PrintToChat(player, Lang("AnalysisHeader", player.UserIDString));
            float      num1     = 10f;
            float      num2     = 7.5f;
            List <int> fixIndex = new List <int>();
            int        index    = 0;

            foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry resource in rd._resources)
            {
                float num3 = (float)(60.0 / num1 * (num2 / (double)resource.workNeeded));
                if (float.IsInfinity(num3))
                {
                    fixIndex.Add(index);
                }
                if (config.Detailed_Analysis)
                {
                    PrintToChat(player, Lang("AnalysisDetailed", player.UserIDString, resource.type.displayName.translated, resource.amount, resource.workNeeded, Math.Round(num3, 1)));
                }
                else
                {
                    PrintToChat(player, Lang("Analysis", player.UserIDString, resource.type.displayName.translated, Math.Round(num3, 1)));
                }
                index++;
            }

            if (fixIndex.Count != 0)
            {
                foreach (int pos in fixIndex)
                {
                    rd._resources.RemoveAt(pos);
                }
            }

            PrintToChat(player, Lang("AnalysisFooter", player.UserIDString));
        }
Ejemplo n.º 9
0
    public ResourceDepositManager.ResourceDeposit CreateFromPosition(Vector3 pos)
    {
        Vector2i indexFrom = ResourceDepositManager.GetIndexFrom(pos);

        UnityEngine.Random.State state = UnityEngine.Random.state;
        UnityEngine.Random.InitState((int)(new Vector2((float)indexFrom.x, (float)indexFrom.y)).Seed(World.Seed + World.Salt));
        ResourceDepositManager.ResourceDeposit resourceDeposit = new ResourceDepositManager.ResourceDeposit()
        {
            origin = new Vector3((float)(indexFrom.x * 20), 0f, (float)(indexFrom.y * 20))
        };
        if (UnityEngine.Random.Range(0f, 1f) < 0.5f)
        {
            resourceDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, 100, 1f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
        }
        else if (0 == 0)
        {
            resourceDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, UnityEngine.Random.Range(30000, 100000), UnityEngine.Random.Range(0.3f, 0.5f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            float single = 0f;
            single = (!World.Procedural ? 0.1f : (TerrainMeta.BiomeMap.GetBiome(pos, 2) > 0.5f ? 1f : 0f) * 0.25f);
            if (UnityEngine.Random.Range(0f, 1f) >= 1f - single)
            {
                resourceDeposit.Add(ItemManager.FindItemDefinition("metal.ore"), 1f, UnityEngine.Random.Range(10000, 100000), UnityEngine.Random.Range(2f, 4f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            }
            float single1 = 0f;
            single1 = (!World.Procedural ? 0.1f : (TerrainMeta.BiomeMap.GetBiome(pos, 1) > 0.5f ? 1f : 0f) * (0.25f + 0.25f * (TerrainMeta.TopologyMap.GetTopology(pos, 8) ? 1f : 0f) + 0.25f * (TerrainMeta.TopologyMap.GetTopology(pos, 1) ? 1f : 0f)));
            if (UnityEngine.Random.Range(0f, 1f) >= 1f - single1)
            {
                resourceDeposit.Add(ItemManager.FindItemDefinition("sulfur.ore"), 1f, UnityEngine.Random.Range(10000, 100000), UnityEngine.Random.Range(4f, 4f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            }
            float single2 = 0f;
            if (!World.Procedural)
            {
                single2 += 0.15f;
            }
            else if (TerrainMeta.BiomeMap.GetBiome(pos, 8) > 0.5f || TerrainMeta.BiomeMap.GetBiome(pos, 4) > 0.5f)
            {
                single2 += 0.25f;
            }
            if (UnityEngine.Random.Range(0f, 1f) >= 1f - single2)
            {
                resourceDeposit.Add(ItemManager.FindItemDefinition("hq.metal.ore"), 1f, UnityEngine.Random.Range(5000, 10000), UnityEngine.Random.Range(30f, 50f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            }
        }
        this._deposits.Add(indexFrom, resourceDeposit);
        Interface.CallHook("OnResourceDepositCreated", resourceDeposit);
        UnityEngine.Random.state = state;
        return(resourceDeposit);
    }
    public ResourceDepositManager.ResourceDeposit CreateFromPosition(Vector3 pos)
    {
        Vector2i indexFrom = ResourceDepositManager.GetIndexFrom(pos);

        Random.State state = Random.get_state();
        Random.InitState((int)SeedEx.Seed(new Vector2((float)indexFrom.x, (float)indexFrom.y), World.Seed + World.Salt));
        ResourceDepositManager.ResourceDeposit resourceDeposit = new ResourceDepositManager.ResourceDeposit();
        resourceDeposit.origin = new Vector3((float)(indexFrom.x * 20), 0.0f, (float)(indexFrom.y * 20));
        if ((double)Random.Range(0.0f, 1f) < 0.5)
        {
            resourceDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, 100, 1f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
        }
        else if (true)
        {
            resourceDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, Random.Range(30000, 100000), Random.Range(0.3f, 0.5f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            if ((double)Random.Range(0.0f, 1f) >= 1.0 - (!World.Procedural ? 0.100000001490116 : ((double)TerrainMeta.BiomeMap.GetBiome(pos, 2) > 0.5 ? 1.0 : 0.0) * 0.25))
            {
                resourceDeposit.Add(ItemManager.FindItemDefinition("metal.ore"), 1f, Random.Range(10000, 100000), Random.Range(2f, 4f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            }
            if ((double)Random.Range(0.0f, 1f) >= 1.0 - (!World.Procedural ? 0.100000001490116 : ((double)TerrainMeta.BiomeMap.GetBiome(pos, 1) > 0.5 ? 1.0 : 0.0) * (0.25 + 0.25 * (TerrainMeta.TopologyMap.GetTopology(pos, 8) ? 1.0 : 0.0) + 0.25 * (TerrainMeta.TopologyMap.GetTopology(pos, 1) ? 1.0 : 0.0))))
            {
                resourceDeposit.Add(ItemManager.FindItemDefinition("sulfur.ore"), 1f, Random.Range(10000, 100000), Random.Range(4f, 4f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            }
            float num = 0.0f;
            if (World.Procedural)
            {
                if ((double)TerrainMeta.BiomeMap.GetBiome(pos, 8) > 0.5 || (double)TerrainMeta.BiomeMap.GetBiome(pos, 4) > 0.5)
                {
                    num += 0.25f;
                }
            }
            else
            {
                num += 0.15f;
            }
            if ((double)Random.Range(0.0f, 1f) >= 1.0 - (double)num)
            {
                resourceDeposit.Add(ItemManager.FindItemDefinition("hq.metal.ore"), 1f, Random.Range(5000, 10000), Random.Range(30f, 50f), ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
            }
        }
        this._deposits.Add(indexFrom, resourceDeposit);
        Interface.CallHook("OnResourceDepositCreated", (object)resourceDeposit);
        Random.set_state(state);
        return(resourceDeposit);
    }
Ejemplo n.º 11
0
    public void AnalysisComplete(BaseEntity.RPCMessage msg)
    {
        ResourceDepositManager.ResourceDeposit orCreate = ResourceDepositManager.GetOrCreate(base.transform.position);
        if (orCreate == null)
        {
            return;
        }
        Item item = ItemManager.CreateByName("note", 1, (ulong)0);

        item.text = "-Mineral Analysis-\n\n";
        float single  = 10f;
        float single1 = 7.5f;

        foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry _resource in orCreate._resources)
        {
            float single2 = 60f / single * (single1 / _resource.workNeeded);
            Item  item1   = item;
            item1.text = string.Concat(new string[] { item1.text, _resource.type.displayName.english, " : ", single2.ToString("0.0"), " pM\n" });
        }
        item.MarkDirty();
        msg.player.GiveItem(item, BaseEntity.GiveItemReason.PickedUp);
    }
Ejemplo n.º 12
0
    public void AnalysisComplete(BaseEntity.RPCMessage msg)
    {
        ResourceDepositManager.ResourceDeposit resourceDeposit = ResourceDepositManager.GetOrCreate(((Component)this).get_transform().get_position());
        if (resourceDeposit == null)
        {
            return;
        }
        Item byName = ItemManager.CreateByName("note", 1, 0UL);

        byName.text = "-Mineral Analysis-\n\n";
        float num1 = 10f;
        float num2 = 7.5f;

        foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry resource in resourceDeposit._resources)
        {
            float num3 = (float)(60.0 / (double)num1 * ((double)num2 / (double)resource.workNeeded));
            Item  obj  = byName;
            obj.text = obj.text + resource.type.displayName.english + " : " + num3.ToString("0.0") + " pM\n";
        }
        byName.MarkDirty();
        msg.player.GiveItem(byName, BaseEntity.GiveItemReason.PickedUp);
    }
Ejemplo n.º 13
0
 public void UpdateStaticDeposit()
 {
     if (!this.isStatic)
     {
         return;
     }
     if (this._linkedDeposit != null)
     {
         this._linkedDeposit._resources.Clear();
     }
     else
     {
         this._linkedDeposit = new ResourceDepositManager.ResourceDeposit();
     }
     if (this.staticType == MiningQuarry.QuarryType.None)
     {
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, 1000, 0.3f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("metal.ore"), 1f, 1000, 5f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("sulfur.ore"), 1f, 1000, 7.5f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("hq.metal.ore"), 1f, 1000, 75f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
     }
     else if (this.staticType == MiningQuarry.QuarryType.Basic)
     {
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("metal.ore"), 1f, 1000, 2f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("stones"), 1f, 1000, 0.3f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
     }
     else if (this.staticType == MiningQuarry.QuarryType.Sulfur)
     {
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("sulfur.ore"), 1f, 1000, 2f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
     }
     else if (this.staticType == MiningQuarry.QuarryType.HQM)
     {
         this._linkedDeposit.Add(ItemManager.FindItemDefinition("hq.metal.ore"), 1f, 1000, 30f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, false);
     }
     this._linkedDeposit.Add(ItemManager.FindItemDefinition("crude.oil"), 1f, 1000, 10f, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM, true);
 }
Ejemplo n.º 14
0
    public override void Explode()
    {
        RaycastHit raycastHit;

        base.Explode();
        if (WaterLevel.Test(base.transform.position))
        {
            return;
        }
        ResourceDepositManager.ResourceDeposit orCreate = ResourceDepositManager.GetOrCreate(base.transform.position);
        if (orCreate == null)
        {
            return;
        }
        if (Time.realtimeSinceStartup - orCreate.lastSurveyTime < 10f)
        {
            return;
        }
        orCreate.lastSurveyTime = Time.realtimeSinceStartup;
        if (!TransformUtil.GetGroundInfo(base.transform.position, out raycastHit, 0.3f, 8388608, null))
        {
            return;
        }
        Vector3             vector3  = raycastHit.point;
        Vector3             vector31 = raycastHit.normal;
        List <SurveyCrater> list     = Pool.GetList <SurveyCrater>();

        Vis.Entities <SurveyCrater>(base.transform.position, 10f, list, 1, QueryTriggerInteraction.Collide);
        bool count = list.Count > 0;

        Pool.FreeList <SurveyCrater>(ref list);
        if (count)
        {
            return;
        }
        bool flag  = false;
        bool flag1 = false;

        foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry _resource in orCreate._resources)
        {
            if (_resource.spawnType != ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM || _resource.isLiquid || _resource.amount < 1000)
            {
                continue;
            }
            int num  = Mathf.Clamp(Mathf.CeilToInt(2.5f / _resource.workNeeded * 10f), 0, 5);
            int num1 = 1;
            flag = true;
            if (_resource.isLiquid)
            {
                flag1 = true;
            }
            for (int i = 0; i < num; i++)
            {
                Item    item = ItemManager.Create(_resource.type, num1, (ulong)0);
                Vector3 modifiedAimConeDirection = AimConeUtil.GetModifiedAimConeDirection(20f, Vector3.up, true);
                item.Drop(base.transform.position + (Vector3.up * 1f), this.GetInheritedDropVelocity() + (modifiedAimConeDirection * UnityEngine.Random.Range(5f, 10f)), UnityEngine.Random.rotation).SetAngularVelocity(UnityEngine.Random.rotation.eulerAngles * 5f);
            }
        }
        if (flag)
        {
            string     str        = (flag1 ? this.craterPrefab_Oil.resourcePath : this.craterPrefab.resourcePath);
            BaseEntity baseEntity = GameManager.server.CreateEntity(str, vector3, Quaternion.identity, true);
            if (baseEntity)
            {
                baseEntity.Spawn();
            }
        }
    }
Ejemplo n.º 15
0
        //
        // Update salt map when resource deposit is tapped for the first time
        //
        void OnEntitySpawned(BaseNetworkable entity)
        {
            if (entity is SurveyCharge)
            {
                OreType ore = OreType.None;

                ResourceDepositManager.ResourceDeposit rd = ResourceDepositManager.GetOrCreate(entity.transform.position);

                if (data.changedDeposits.Exists(d => GetVector3(d.origin) == rd.origin))
                {
                    return;
                }

                ResourceDepositManager.ResourceDeposit.ResourceDepositEntry originalResource = null;

                int oreCount = 0;
                foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry resource in rd._resources)
                {
                    switch (resource.type.shortname)
                    {
                    case "sulfur.ore":
                        ore = OreType.Sulfur;
                        originalResource = resource;
                        oreCount++;
                        break;

                    case "metal.ore":
                        ore = OreType.Metal;
                        originalResource = resource;
                        oreCount++;
                        break;

                    case "hq.metal.ore":
                        ore = OreType.HighQuality;
                        originalResource = resource;
                        oreCount++;
                        break;

                    default:
                        break;
                    }
                }

                if (oreCount > 1)
                {
                    return;
                }

                ItemDefinition sulfur = ItemManager.itemList.Find(x => x.shortname == "sulfur.ore");
                ItemDefinition metal  = ItemManager.itemList.Find(x => x.shortname == "metal.ore");
                ItemDefinition hq     = ItemManager.itemList.Find(x => x.shortname == "hq.metal.ore");

                Deposit deposit = new Deposit {
                    origin = GetOrigin(rd.origin)
                };

                if (originalResource == null && rd._resources.Count != 0)
                {
                    originalResource = rd._resources.ToArray()[0];
                }

                System.Random rng        = new System.Random();
                float         workNeeded = (float)(rng.Next(0, 2) + rng.NextDouble());
                int           choice     = rng.Next(1, 100);
                int           amount     = 0;
                switch (ore)
                {
                case OreType.Sulfur:                          // Give a chance at some amount of metal ore
                    if (workNeeded > 1f)
                    {
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;

                case OreType.Metal:                         // Give a chance at some amount of sulfur ore
                    if (workNeeded > 1.75f)
                    {
                        amount = rng.Next(10000, 100000);
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;

                case OreType.HighQuality:                        // Give a chance at some amount of either metal, sulfur, or both ores
                    if (choice < 40)                             // Just sulfur
                    {
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else if (choice < 80)                             // Just metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else                             // Both sulfur and metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;

                default:                         // Give a chance at some amount of either metal, sulfur, or both ores
                    if (oreCount == 1)
                    {
                        return;
                    }
                    if (choice < 40)                             // Just sulfur
                    {
                        if (workNeeded > 1.75f)
                        {
                            return;
                        }
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else if (choice < 80)                             // Just metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else                             // Both sulfur and metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;
                }

                data.changedDeposits.Add(deposit);
                SaveData();
            }
        }
Ejemplo n.º 16
0
    public override void Explode()
    {
        base.Explode();
        if (WaterLevel.Test(((Component)this).get_transform().get_position()))
        {
            return;
        }
        ResourceDepositManager.ResourceDeposit resourceDeposit = ResourceDepositManager.GetOrCreate(((Component)this).get_transform().get_position());
        if (resourceDeposit == null || (double)Time.get_realtimeSinceStartup() - (double)resourceDeposit.lastSurveyTime < 10.0)
        {
            return;
        }
        resourceDeposit.lastSurveyTime = Time.get_realtimeSinceStartup();
        RaycastHit hitOut;

        if (!TransformUtil.GetGroundInfo(((Component)this).get_transform().get_position(), out hitOut, 0.3f, LayerMask.op_Implicit(8388608), (Transform)null))
        {
            return;
        }
        Vector3 point = ((RaycastHit) ref hitOut).get_point();

        ((RaycastHit) ref hitOut).get_normal();
        List <SurveyCrater> list = (List <SurveyCrater>)Pool.GetList <SurveyCrater>();

        Vis.Entities <SurveyCrater>(((Component)this).get_transform().get_position(), 10f, list, 1, (QueryTriggerInteraction)2);
        int num1 = list.Count > 0 ? 1 : 0;

        // ISSUE: cast to a reference type
        Pool.FreeList <SurveyCrater>((List <M0>&) ref list);
        if (num1 != 0)
        {
            return;
        }
        bool flag1 = false;
        bool flag2 = false;

        foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry resource in resourceDeposit._resources)
        {
            if (resource.spawnType == ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM && !resource.isLiquid && resource.amount >= 1000)
            {
                int num2    = Mathf.Clamp(Mathf.CeilToInt((float)(2.5 / (double)resource.workNeeded * 10.0)), 0, 5);
                int iAmount = 1;
                flag1 = true;
                if (resource.isLiquid)
                {
                    flag2 = true;
                }
                for (int index = 0; index < num2; ++index)
                {
                    Item       obj = ItemManager.Create(resource.type, iAmount, 0UL);
                    Vector3    aimConeDirection = AimConeUtil.GetModifiedAimConeDirection(20f, Vector3.get_up(), true);
                    Vector3    vPos             = Vector3.op_Addition(((Component)this).get_transform().get_position(), Vector3.op_Multiply(Vector3.get_up(), 1f));
                    Vector3    vVelocity        = Vector3.op_Addition(this.GetInheritedDropVelocity(), Vector3.op_Multiply(aimConeDirection, Random.Range(5f, 10f)));
                    Quaternion rotation1        = Random.get_rotation();
                    BaseEntity baseEntity       = obj.Drop(vPos, vVelocity, rotation1);
                    Quaternion rotation2        = Random.get_rotation();
                    Vector3    velocity         = Vector3.op_Multiply(((Quaternion) ref rotation2).get_eulerAngles(), 5f);
                    baseEntity.SetAngularVelocity(velocity);
                }
            }
        }
        if (!flag1)
        {
            return;
        }
        string     strPrefab = flag2 ? this.craterPrefab_Oil.resourcePath : this.craterPrefab.resourcePath;
        BaseEntity entity    = GameManager.server.CreateEntity(strPrefab, point, Quaternion.get_identity(), true);

        if (!Object.op_Implicit((Object)entity))
        {
            return;
        }
        entity.Spawn();
    }