OSDN Git Service

5d17a5b08f85a1e0f450ae0ecfbe13a7f7c324b3
[chemicraft/chemicraft.git] / common / pcc / chemicraft / base / ChemiCraftBaseAPI.java
1 package pcc.chemicraft.base;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5
6 import pcc.chemicraft.base.gen.EnumOreSpawnFrequency;
7 import pcc.chemicraft.base.gen.WorldGenAtomsOre;
8 import pcc.chemicraft.util.AtomInfo;
9 import pcc.chemicraft.util.Formula;
10 import pcc.chemicraft.util.ListHash;
11
12 public class ChemiCraftBaseAPI
13 {
14
15         private static ChemiCraftBaseAPI instance = new ChemiCraftBaseAPI();
16
17
18         public static ChemiCraftBaseAPI instance(){
19                 return instance;
20         }
21
22         /**
23          * 鉱石別元素数リスト
24          */
25         private HashMap<String, Formula> atomOresFormulasHash = new HashMap<String, Formula>();
26
27
28         /**
29          * 鉱石の言語リスト
30          */
31         private ListHash<String, String> atomOresLangListHash = new ListHash<String, String>();
32
33
34         /**
35          * 鉱石リスト
36          */
37         private ArrayList<WorldGenAtomsOre> atomOresList = new ArrayList<WorldGenAtomsOre>();
38
39
40         /**
41          * 鉱石名リスト
42          */
43         private ListHash<String, String> atomOresNameListHash = new ListHash<String, String>();
44
45
46
47         /**
48          * 鉱石を追加します。
49          * @param par1Name
50          * @param par2Formula
51          * @param par3Id
52          * @param par4Size
53          * @param par5Frequency
54          * @param par6PosY
55          */
56         public void addAtomOres(String par1Name, Formula par2Formula, int par3Id, int par4Size, int par5Frequency, int par6PosY){
57                 atomOresList.add(
58                                 new WorldGenAtomsOre(
59                                                 par3Id,
60                                                 getAtomOresMetaOfLastIndex(),
61                                                 par4Size,
62                                                 par5Frequency,
63                                                 par6PosY));
64                 atomOresFormulasHash.put(par1Name, par2Formula);
65
66                 String var7 = par1Name;
67                 if (!var7.contains(" Ore")){
68                         var7 = var7.concat(" Ore");
69                 }
70                 addAtomOresLanguage(par1Name, var7, "en_US");
71         }
72
73
74
75         public void addAtomOres(String par1Name, Formula par2Formula, int par3Id, EnumOreSpawnFrequency par4Enum){
76                 addAtomOres(
77                                 par1Name,
78                                 par2Formula,
79                                 par3Id,
80                                 par4Enum.getSize(),
81                                 par4Enum.getFrequency(),
82                                 par4Enum.getPosY()
83                                 );
84         }
85
86
87
88         /**
89          * 既に登録した鉱石の新しい名前・言語を追加します
90          * @param par1Name 英語名
91          * @param par2NewName 新しい名前
92          * @param par3Language 言語
93          */
94         public void addAtomOresLanguage(String par1Name, String par2NewName, String par3Language){
95                 atomOresNameListHash.add(par1Name,
96                                 par2NewName);
97                 atomOresLangListHash.add(par1Name,
98                                 par3Language);
99         }
100
101
102
103         //以下システム関連//////////////////////////////////////////////////////
104
105         public ArrayList<WorldGenAtomsOre> getAtomOres(){
106                 return atomOresList;
107         }
108
109         public HashMap<String, Formula> getAtomOresFormulas(){
110                 return atomOresFormulasHash;
111         }
112
113
114
115         public ListHash<String, String> getAtomOresLanguage(){
116                 return atomOresLangListHash;
117         }
118
119
120
121         public int getAtomOresLastIndex(){
122                 return atomOresNameListHash.sizeKeysList() / 16;
123         }
124
125
126
127         public int getAtomOresMetaOfLastIndex(){
128                 return atomOresNameListHash.sizeKeysList() - getAtomOresLastIndex() * 16;
129         }
130
131
132
133         public ListHash<String, String> getAtomOresName(){
134                 return atomOresNameListHash;
135         }
136
137 }