the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "Material.h"
3#include "DecorationMaterial.h"
4#include "GasMaterial.h"
5#include "LiquidMaterial.h"
6#include "PortalMaterial.h"
7#include "WebMaterial.h"// 4J added, Java version just does a local alteration when instantiating the Material for webs to get the same thing
8
9Material *Material::air = NULL;
10Material *Material::grass = NULL;
11Material *Material::dirt = NULL;
12Material *Material::wood = NULL;
13Material *Material::stone = NULL;
14Material *Material::metal = NULL;
15Material *Material::heavyMetal = NULL;
16Material *Material::water = NULL;
17Material *Material::lava = NULL;
18Material *Material::leaves = NULL;
19Material *Material::plant = NULL;
20Material *Material::replaceable_plant = NULL;
21Material *Material::sponge = NULL;
22Material *Material::cloth = NULL;
23Material *Material::fire = NULL;
24Material *Material::sand = NULL;
25Material *Material::decoration = NULL;
26Material *Material::clothDecoration = NULL;
27Material *Material::glass = NULL;
28Material *Material::buildable_glass = NULL;
29Material *Material::explosive = NULL;
30Material *Material::coral = NULL;
31Material *Material::ice = NULL;
32Material *Material::topSnow = NULL;
33Material *Material::snow = NULL;
34Material *Material::cactus = NULL;
35Material *Material::clay = NULL;
36Material *Material::vegetable = NULL;
37Material *Material::egg = NULL;
38Material *Material::portal = NULL;
39Material *Material::cake = NULL;
40Material *Material::piston = NULL;
41Material *Material::web = NULL;
42
43void Material::staticCtor()
44{
45 Material::air = new GasMaterial(MaterialColor::none);
46 Material::grass = new Material(MaterialColor::grass);
47 Material::dirt = new Material(MaterialColor::dirt);
48 Material::wood = (new Material(MaterialColor::wood))->flammable();
49 Material::stone = (new Material(MaterialColor::stone))->notAlwaysDestroyable();
50 Material::metal = (new Material(MaterialColor::metal))->notAlwaysDestroyable();
51 Material::heavyMetal = (new Material(MaterialColor::metal))->notAlwaysDestroyable()->notPushable();
52 Material::water = (new LiquidMaterial(MaterialColor::water))->destroyOnPush();
53 Material::lava = (new LiquidMaterial(MaterialColor::fire))->destroyOnPush();
54 Material::leaves = (new Material(MaterialColor::plant))->flammable()->neverBuildable()->destroyOnPush();
55 Material::plant = (new DecorationMaterial(MaterialColor::plant))->destroyOnPush();
56 Material::replaceable_plant = (new DecorationMaterial(MaterialColor::plant))->flammable()->destroyOnPush()->replaceable();
57 Material::sponge = new Material(MaterialColor::cloth);
58 Material::cloth = (new Material(MaterialColor::cloth))->flammable();
59 Material::fire = (new GasMaterial(MaterialColor::none))->destroyOnPush();
60 Material::sand = new Material(MaterialColor::sand);
61 Material::decoration = (new DecorationMaterial(MaterialColor::none))->destroyOnPush();
62 Material::clothDecoration = (new DecorationMaterial(MaterialColor::cloth))->flammable();
63 Material::glass = (new Material(MaterialColor::none))->neverBuildable()->makeDestroyedByHand();
64 Material::buildable_glass = (new Material(MaterialColor::none))->makeDestroyedByHand();
65 Material::explosive = (new Material(MaterialColor::fire))->flammable()->neverBuildable();
66 Material::coral = (new Material(MaterialColor::plant))->destroyOnPush();
67 Material::ice = (new Material(MaterialColor::ice))->neverBuildable()->makeDestroyedByHand();
68 Material::topSnow = (new DecorationMaterial(MaterialColor::snow))->replaceable()->neverBuildable()->notAlwaysDestroyable()->destroyOnPush();
69 Material::snow = (new Material(MaterialColor::snow))->notAlwaysDestroyable();
70 Material::cactus = (new Material(MaterialColor::plant))->neverBuildable()->destroyOnPush();
71 Material::clay = (new Material(MaterialColor::clay));
72 Material::vegetable = (new Material(MaterialColor::plant))->destroyOnPush();
73 Material::egg = ( new Material(MaterialColor::plant))->destroyOnPush();
74 Material::portal = (new PortalMaterial(MaterialColor::none))->notPushable();
75 Material::cake = (new Material(MaterialColor::none))->destroyOnPush();
76 // 4J added WebMaterial, Java version just does a local alteration when instantiating the Material for webs to get the same thing
77 Material::web = (new WebMaterial(MaterialColor::cloth))->notAlwaysDestroyable()->destroyOnPush();
78 Material::piston = (new Material(MaterialColor::stone))->notPushable();
79}
80
81Material::Material(MaterialColor *color)
82{
83 this->color = color;
84
85 // 4J Stu - Default inits
86 _flammable = false;
87 _replaceable = false;
88 _neverBuildable = false;
89 _isAlwaysDestroyable = true;
90 pushReaction = 0;
91 destroyedByHand = false;
92}
93
94bool Material::isLiquid()
95{
96 return false;
97}
98
99bool Material::letsWaterThrough()
100{
101 return (!isLiquid() && !isSolid());
102}
103
104bool Material::isSolid()
105{
106 return true;
107}
108
109bool Material::blocksLight()
110{
111 return true;
112}
113
114bool Material::blocksMotion()
115{
116 return true;
117}
118
119Material *Material::neverBuildable()
120{
121 this->_neverBuildable = true;
122 return this;
123}
124
125Material *Material::notAlwaysDestroyable()
126{
127 this->_isAlwaysDestroyable = false;
128 return this;
129}
130
131Material *Material::flammable()
132{
133 this->_flammable = true;
134 return this;
135}
136
137bool Material::isFlammable()
138{
139 return _flammable;
140}
141
142Material *Material::replaceable()
143{
144 this->_replaceable = true;
145 return this;
146}
147
148bool Material::isReplaceable()
149{
150 return _replaceable;
151}
152
153bool Material::isSolidBlocking()
154{
155 if (_neverBuildable) return false;
156 return blocksMotion();
157}
158
159bool Material::isAlwaysDestroyable()
160{
161 // these materials will always drop resources when destroyed, regardless
162 // of player's equipment
163 return _isAlwaysDestroyable;
164}
165
166int Material::getPushReaction()
167{
168 return pushReaction;
169}
170
171Material *Material::makeDestroyedByHand()
172{
173 this->destroyedByHand = true;
174 return this;
175}
176
177bool Material::isDestroyedByHand()
178{
179 return destroyedByHand;
180}
181
182Material *Material::destroyOnPush()
183{
184 pushReaction = PUSH_DESTROY;
185 return this;
186}
187
188Material *Material::notPushable()
189{
190 pushReaction = PUSH_BLOCK;
191 return this;
192}