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);
 }
Example #2
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);
    }