OSDN Git Service

修正・変更
[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.Formula;
9 import pcc.chemicraft.util.ListHash;
10
11 /**
12  * ChemiCraftBaseのAPIを提供するクラスです。<br>
13  * ChemiCraftBaseを使用したAPIを作成する場合、このクラスを使用します。
14  * @author mozipi,ponkotate
15  */
16 public class ChemiCraftBaseAPI {
17
18         /**
19          * APIのインスタンス
20          */
21         private static ChemiCraftBaseAPI instance = new ChemiCraftBaseAPI();
22
23
24         /**
25          * APIのインスタンスを返します。
26          * @return APIのインスタンス
27          */
28         public static ChemiCraftBaseAPI instance(){
29                 return instance;
30         }
31
32         /**
33          * 鉱石別元素数リスト
34          */
35         private HashMap<String, Formula> atomOresFormulasHash = new HashMap<String, Formula>();
36
37
38         /**
39          * 鉱石リスト
40          */
41         private ArrayList<WorldGenAtomsOre> atomOresList = new ArrayList<WorldGenAtomsOre>();
42
43
44         /**
45          * 鉱石名リスト
46          */
47         private ListHash<String, String> atomOresNameListHash = new ListHash<String, String>();
48
49
50         /**
51          * 鉱石の英語名リスト
52          */
53         private ArrayList<String> atomOresEnglishList = new ArrayList<String>();
54
55         /**
56          * 鉱石を追加します。
57          * @param par1Name 鉱石名(Oreは自動で語尾につけられます)
58          * @param par2Formula 化学式
59          * @param par3Id 鉱石のID
60          * @param par4Size 鉱石の塊の大きさ
61          * @param par5Frequency 生成率(frequency/Chunk)
62          * @param par6PosY 鉱石が生成される高度(nowY < PosY == Generate)
63          */
64         public void addAtomOres(String par1Name, Formula par2Formula, int par3Id, int par4Size, int par5Frequency, int par6PosY){
65                 atomOresList.add(
66                                 new WorldGenAtomsOre(
67                                                 par3Id,
68                                                 getAtomOresMetaOfLastIndex(),
69                                                 par4Size,
70                                                 par5Frequency,
71                                                 par6PosY));
72
73                 atomOresFormulasHash.put(par1Name, par2Formula);
74
75                 String var7 = par1Name;
76                 if (!var7.contains(" Ore")) {
77                         var7 = var7.concat(" Ore");
78                 }
79
80                 this.atomOresEnglishList.add(var7);
81                 addAtomOresLanguage(var7, "en_US");
82         }
83
84
85
86         /**
87          * 鉱石を追加します。
88          * @param par1Name 鉱石名(Oreは自動で語尾につけられます)
89          * @param par2Formula 化学式
90          * @param par3Id 鉱石のID
91          * @param par4Enum 鉱石生成の情報が入ったEnum
92          */
93         public void addAtomOres(String par1Name, Formula par2Formula, int par3Id, EnumOreSpawnFrequency par4Enum){
94                 addAtomOres(
95                                 par1Name,
96                                 par2Formula,
97                                 par3Id,
98                                 par4Enum.getSize(),
99                                 par4Enum.getFrequency(),
100                                 par4Enum.getPosY()
101                                 );
102         }
103
104
105
106         /**
107          * 既に登録した鉱石の新しい名前・言語を追加します
108          * @param par1Name 英語名
109          * @param par2NewName 新しい名前
110          * @param par3Language 言語
111          */
112         public void addAtomOresLanguage(String par1Name, String par2Language){
113                 atomOresNameListHash.add(
114                                 par2Language,
115                                 par1Name
116                                 );
117         }
118
119
120
121         //以下システム関連//////////////////////////////////////////////////////
122
123         public ArrayList<WorldGenAtomsOre> getAtomOres(){
124                 return atomOresList;
125         }
126
127         public HashMap<String, Formula> getAtomOresFormulas(){
128                 return atomOresFormulasHash;
129         }
130
131
132
133         public int getAtomOresLastIndex(){
134                 return atomOresEnglishList.size() / 16;
135         }
136
137
138
139         public int getAtomOresMetaOfLastIndex(){
140                 return atomOresEnglishList.size() - getAtomOresLastIndex() * 16;
141         }
142
143
144
145         public ListHash<String, String> getAtomOresName(){
146                 return atomOresNameListHash;
147         }
148
149
150
151         public String getAtomOreEnglishName(int index) {
152                 return this.atomOresEnglishList.get(index);
153         }
154
155 }