Elin Decompiled Documentation EA 23.187 Stable
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 GetRandomMaterial(int lv, string group = null, bool tryLevelMatTier = false)
48 {
49 if (group == null)
50 {
51 group = ((EClass.rnd(2) == 0) ? "metal" : "leather");
52 }
53 if (!(group == "metal"))
54 {
55 if (group == "leather" && EClass.rnd(15) == 0)
56 {
57 group = "metal";
58 }
59 }
60 else if (EClass.rnd(15) == 0)
61 {
62 group = "leather";
63 }
65 int num = 0;
66 if (tryLevelMatTier)
67 {
68 num = Mathf.Clamp(lv / 15, 0, tierList.tiers.Length - 1);
69 num = Mathf.Clamp(num + EClass.rnd(2) - EClass.rnd(2), 0, tierList.tiers.Length - 1);
70 }
71 else
72 {
73 int min = ((lv >= 60) ? 2 : ((lv >= 25) ? 1 : 0));
74 num = Mathf.Clamp(EClass.rnd(EClass.rnd(EClass.rnd(lv / 10 + 2) + 1) + 1), min, tierList.tiers.Length - 1);
75 }
76 SourceMaterial.Tier obj = tierList.tiers[num];
77 SourceMaterial.Row result = obj.Select();
78 if (obj.list.Count == 0)
79 {
80 Debug.Log(lv + "/" + group + "/" + num + "/");
81 }
82 return result;
83 }
84
85 public static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
86 {
87 return GetRandomMaterialFromCategory(lv, new string[1] { cat }, fallback);
88 }
89
90 public static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string[] cat, SourceMaterial.Row fallback)
91 {
92 int min = ((lv >= 60) ? 2 : ((lv >= 25) ? 1 : 0));
93 int a2 = lv / 5 + 2;
94 int idTier = Mathf.Clamp(EClass.rnd(EClass.rnd(EClass.rnd(a2) + 1) + 1), min, 4);
95 List<SourceMaterial.Row> list = EClass.sources.materials.rows.Where((SourceMaterial.Row m) => cat.Contains(m.category) && m.tier <= idTier).ToList();
96 if (list.Count > 0)
97 {
98 return list.RandomItemWeighted((SourceMaterial.Row a) => a.chance * ((a.tier != idTier) ? 1 : 5));
99 }
100 return fallback;
101 }
102}
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:47
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
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:85
const byte soil
Definition: MATERIAL.cs:17
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string[] cat, SourceMaterial.Row fallback)
Definition: MATERIAL.cs:90
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