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