Elin Decompiled Documentation EA 23.245 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
37 public const int MaxRandomTier = 4;
38
39 public const int MaxTier = 7;
40
42
44
46
48
50
51 public static SourceMaterial.Row FromElement(int id)
52 {
53 return EClass.sources.materials.alias["rubinus"];
54 }
55
56 public static SourceMaterial.Row GetRandomMaterial(int lv, string group = null, bool tryLevelMatTier = false)
57 {
58 if (group == null)
59 {
60 group = ((EClass.rnd(2) == 0) ? "metal" : "leather");
61 }
62 if (!(group == "metal"))
63 {
64 if (group == "leather" && EClass.rnd(15) == 0)
65 {
66 group = "metal";
67 }
68 }
69 else if (EClass.rnd(15) == 0)
70 {
71 group = "leather";
72 }
74 int num = 0;
75 if (tryLevelMatTier)
76 {
77 num = Mathf.Clamp(lv / 15, 0, 4);
78 num = Mathf.Clamp(num + EClass.rnd(2) - EClass.rnd(2), 0, 4);
79 }
80 else
81 {
82 num = Mathf.Clamp(min: (lv >= 60) ? 2 : ((lv >= 25) ? 1 : 0), value: EClass.rnd(EClass.rnd(EClass.rnd(lv / 10 + 2) + 1) + 1), max: 4);
83 }
84 SourceMaterial.Tier obj = tierList.tiers[num];
85 SourceMaterial.Row result = obj.Select();
86 if (obj.list.Count == 0)
87 {
88 Debug.Log(lv + "/" + group + "/" + num + "/");
89 }
90 return result;
91 }
92
93 public static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
94 {
95 return GetRandomMaterialFromCategory(lv, new string[1] { cat }, fallback);
96 }
97
98 public static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string[] cat, SourceMaterial.Row fallback)
99 {
100 int min = ((lv >= 60) ? 2 : ((lv >= 25) ? 1 : 0));
101 int a2 = lv / 5 + 2;
102 int idTier = Mathf.Clamp(EClass.rnd(EClass.rnd(EClass.rnd(a2) + 1) + 1), min, 4);
103 List<SourceMaterial.Row> list = EClass.sources.materials.rows.Where((SourceMaterial.Row m) => cat.Contains(m.category) && m.tier <= idTier).ToList();
104 if (list.Count > 0)
105 {
106 return list.RandomItemWeighted((SourceMaterial.Row a) => a.chance * ((a.tier != idTier) ? 1 : 5));
107 }
108 return fallback;
109 }
110}
Definition: EClass.cs:6
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
Definition: MATERIAL.cs:56
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:47
static SourceMaterial.Row FromElement(int id)
Definition: MATERIAL.cs:51
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:93
const byte soil
Definition: MATERIAL.cs:17
const int MaxTier
Definition: MATERIAL.cs:39
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string[] cat, SourceMaterial.Row fallback)
Definition: MATERIAL.cs:98
const int MaxRandomTier
Definition: MATERIAL.cs:37
static SourceMaterial.Row sourceSnow
Definition: MATERIAL.cs:41
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:43
const byte gold
Definition: MATERIAL.cs:27
static SourceMaterial.Row sourceGold
Definition: MATERIAL.cs:45
const byte process
Definition: MATERIAL.cs:31
const byte mud
Definition: MATERIAL.cs:13
static SourceMaterial.Row sourceWaterSea
Definition: MATERIAL.cs:49
const byte water
Definition: MATERIAL.cs:21
SourceMaterial materials
static Dictionary< string, TierList > tierMap