forked from Digus/StardewValleyMods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeExtension.cs
68 lines (64 loc) · 1.91 KB
/
TreeExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
using StardewValley.TerrainFeatures;
namespace CropTransplantMod
{
public static class TreeExtension
{
public static int GetSeedSaplingIndex(this TerrainFeature value)
{
switch (value)
{
case Tree tree:
return GetSeedIndex(tree);
case FruitTree fruitTree:
return GetSaplingIndex(fruitTree);
case Bush bush:
return GetSaplingIndex(bush);
default:
return -1;
}
}
public static int GetSeedIndex(this Tree value)
{
int seedIndex = -1;
switch (value.treeType.Value)
{
case 1:
seedIndex = 309;
break;
case 2:
seedIndex = 310;
break;
case 3:
seedIndex = 311;
break;
case 8:
seedIndex = 292;
break;
case 7:
seedIndex = 891;
break;
case 6:
case 9:
seedIndex = 88;
break;
}
return seedIndex;
}
public static int GetSaplingIndex(this FruitTree value)
{
Dictionary<int, string> data = Game1.content.Load<Dictionary<int, string>>("Data\\fruitTrees");
int seedIndex = data.Where(t => Convert.ToInt32(t.Value.Split('/')[0]) == value.treeType.Value).Select(t=>t.Key).FirstOrDefault();
return seedIndex;
}
public static int GetSaplingIndex(this Bush value)
{
return 251;
}
}
}