Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
MATERIAL.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4
5public class MATERIAL : EClass
6{
7 public const byte oak = 1;
8
9 public const byte granite = 3;
10
11 public const byte mud = 4;
12
13 public const byte sand = 8;
14
15 public const byte soil = 45;
16
17 public const byte snow = 48;
18
19 public const byte water = 66;
20
21 public const byte water_fresh = 67;
22
23 public const byte ice = 61;
24
25 public const byte gold = 12;
26
27 public const byte water_sea = 88;
28
29 public const byte process = 94;
30
31 public const byte sand_sea = 97;
32
34
36
38
40
42
43 public static SourceMaterial.Row GetRandomMaterial(int lv, string group = null, bool tryLevelMatTier = false)
44 {
45 if (group == null)
46 {
47 group = ((EClass.rnd(2) == 0) ? "metal" : "leather");
48 }
49 if (!(group == "metal"))
50 {
51 if (group == "leather" && EClass.rnd(15) == 0)
52 {
53 group = "metal";
54 }
55 }
56 else if (EClass.rnd(15) == 0)
57 {
58 group = "leather";
59 }
61 int num = 0;
62 if (tryLevelMatTier)
63 {
64 num = Mathf.Clamp(lv / 15, 0, tierList.tiers.Length - 1);
65 num = Mathf.Clamp(num + EClass.rnd(2) - EClass.rnd(2), 0, tierList.tiers.Length - 1);
66 }
67 else
68 {
69 int min = ((lv >= 60) ? 2 : ((lv >= 25) ? 1 : 0));
70 num = Mathf.Clamp(EClass.rnd(EClass.rnd(EClass.rnd(lv / 10 + 2) + 1) + 1), min, tierList.tiers.Length - 1);
71 }
72 SourceMaterial.Tier obj = tierList.tiers[num];
73 SourceMaterial.Row result = obj.Select();
74 if (obj.list.Count == 0)
75 {
76 Debug.Log(lv + "/" + group + "/" + num + "/");
77 }
78 return result;
79 }
80
81 public static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
82 {
83 return GetRandomMaterialFromCategory(lv, new string[1] { cat }, fallback);
84 }
85
86 public static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string[] cat, SourceMaterial.Row fallback)
87 {
88 int min = ((lv >= 60) ? 2 : ((lv >= 25) ? 1 : 0));
89 int a2 = lv / 5 + 2;
90 int idTier = Mathf.Clamp(EClass.rnd(EClass.rnd(EClass.rnd(a2) + 1) + 1), min, 4);
91 List<SourceMaterial.Row> list = EClass.sources.materials.rows.Where((SourceMaterial.Row m) => cat.Contains(m.category) && m.tier <= idTier).ToList();
92 if (list.Count > 0)
93 {
94 return list.RandomItemWeighted((SourceMaterial.Row a) => a.chance * ((a.tier != idTier) ? 1 : 5));
95 }
96 return fallback;
97 }
98}
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static SourceManager sources
Definition: EClass.cs:42
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
Definition: MATERIAL.cs:43
const byte ice
Definition: MATERIAL.cs:23
const byte water_sea
Definition: MATERIAL.cs:27
const byte sand_sea
Definition: MATERIAL.cs:31
static SourceMaterial.Row sourceOak
Definition: MATERIAL.cs:39
const byte snow
Definition: MATERIAL.cs:17
const byte oak
Definition: MATERIAL.cs:7
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
Definition: MATERIAL.cs:81
const byte soil
Definition: MATERIAL.cs:15
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string[] cat, SourceMaterial.Row fallback)
Definition: MATERIAL.cs:86
static SourceMaterial.Row sourceSnow
Definition: MATERIAL.cs:33
const byte water_fresh
Definition: MATERIAL.cs:21
const byte granite
Definition: MATERIAL.cs:9
const byte sand
Definition: MATERIAL.cs:13
static SourceMaterial.Row sourceIce
Definition: MATERIAL.cs:35
const byte gold
Definition: MATERIAL.cs:25
static SourceMaterial.Row sourceGold
Definition: MATERIAL.cs:37
const byte process
Definition: MATERIAL.cs:29
const byte mud
Definition: MATERIAL.cs:11
static SourceMaterial.Row sourceWaterSea
Definition: MATERIAL.cs:41
const byte water
Definition: MATERIAL.cs:19
SourceMaterial materials
static Dictionary< string, TierList > tierMap