Skip to content

Commit e8ab64c

Browse files
committed
made all item templates (#12)
1 parent fd8459e commit e8ab64c

File tree

10 files changed

+89
-188
lines changed

10 files changed

+89
-188
lines changed

data/items.yml

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,28 @@ branch:
2222
damage: 1
2323
sprite:
2424
c: '/'
25-
col: 5987163 # change
25+
col:
26+
red: 141
27+
green: 104
28+
blue: 21
2629

2730
vine:
2831
name: a thin, flexible branch
2932
sprite:
3033
c: 239
31-
col: 5987163 # change
34+
col:
35+
red: 36
36+
green: 122
37+
blue: 7
3238

3339
trunk:
3440
name: a fallen tree
3541
sprite:
36-
c: '-' # change
37-
col: 5987163 # change
42+
c: 22
43+
col:
44+
red: 141
45+
green: 104
46+
blue: 21
3847

3948
boulder:
4049
name: a big boulder
@@ -45,7 +54,20 @@ boulder:
4554
green: 88
4655
blue: 88
4756
shadowView: true
48-
obstacle: true
57+
obstacle: {}
58+
crushable: {}
59+
60+
tree:
61+
name: a mature tree
62+
sprite:
63+
c: T
64+
col:
65+
red: 0
66+
green: 205
67+
blue: 113
68+
shadowView: true
69+
obstacle: {}
70+
cuttable: {}
4971

5072
sharp-stone:
5173
name: a sharp stone
@@ -55,8 +77,11 @@ sharp-stone:
5577
damageType: SLASH
5678
damage: 2
5779
sprite:
58-
c: 'o' # change
59-
col: 5987163 # change
80+
c: 4
81+
col:
82+
red: 88
83+
green: 88
84+
blue: 88
6085

6186
small-sharp-stone:
6287
name: a small, sharp stone
@@ -66,8 +91,11 @@ small-sharp-stone:
6691
damageType: POINT
6792
damage: 2
6893
sprite:
69-
c: 'o' # change
70-
col: 5987163 # change
94+
c: 17
95+
col:
96+
red: 88
97+
green: 88
98+
blue: 88
7199

72100
stone-hammer:
73101
name: a stone hammer
@@ -77,8 +105,11 @@ stone-hammer:
77105
damageType: BLUNT
78106
damage: 4
79107
sprite:
80-
c: 'o' # change
81-
col: 5987163 # change
108+
c: 209
109+
col:
110+
red: 141
111+
green: 104
112+
blue: 21
82113

83114
stone-axe:
84115
name: a stone axe
@@ -88,8 +119,11 @@ stone-axe:
88119
damageType: SLASH
89120
damage: 4
90121
sprite:
91-
c: 'o' # change
92-
col: 5987163 # change
122+
c: 184
123+
col:
124+
red: 141
125+
green: 104
126+
blue: 21
93127

94128
stone-spear:
95129
name: a stone spear
@@ -99,5 +133,8 @@ stone-spear:
99133
damageType: POINT
100134
damage: 4
101135
sprite:
102-
c: 'o' # change
103-
col: 5987163 # change
136+
c: 244
137+
col:
138+
red: 141
139+
green: 104
140+
blue: 21

src/main/java/com/github/fabioticconi/alone/components/Tree.java renamed to src/main/java/com/github/fabioticconi/alone/components/Cuttable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
* Author: Fabio Ticconi
2525
* Date: 07/10/17
2626
*/
27-
public class Tree extends Component
27+
public class Cuttable extends Component
2828
{
2929
}

src/main/java/com/github/fabioticconi/alone/components/LightBlocker.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/java/com/github/fabioticconi/alone/components/Obstacle.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@
2222

2323
/**
2424
* Author: Fabio Ticconi
25-
* Date: 13/11/17
25+
* Date: 10/09/17
2626
*/
2727
public class Obstacle extends Component
2828
{
29-
public Obstacle(final boolean state)
30-
{
31-
32-
}
29+
// TODO eventually, we might need a parameter to say: "this only blocks light, not movement"
3330
}

src/main/java/com/github/fabioticconi/alone/systems/BootstrapSystem.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class BootstrapSystem extends PassiveSystem
5252
MapSystem sMap;
5353
TreeSystem sTree;
5454
CrushSystem sCrush;
55+
ItemSystem sItems;
5556
MapSystem map;
5657

5758
PlayerManager pManager;
@@ -297,7 +298,7 @@ protected void initialize()
297298
if (!map.obstacles.isEmpty(x, y))
298299
continue;
299300

300-
sTree.makeTree(x, y);
301+
sItems.makeItem("tree", x, y);
301302
}
302303
}
303304
}
@@ -319,7 +320,7 @@ protected void initialize()
319320
if (!map.obstacles.isEmpty(x, y))
320321
continue;
321322

322-
sCrush.makeBoulder(x, y);
323+
sItems.makeItem("boulder", x, y);
323324
}
324325
}
325326
}
@@ -341,7 +342,7 @@ protected void initialize()
341342
if (!map.items.isEmpty(x, y))
342343
continue;
343344

344-
sCrush.makeStone(x, y);
345+
sItems.makeItem("stone", x, y);
345346
}
346347
}
347348
}
@@ -360,9 +361,9 @@ protected void initialize()
360361
if (!map.items.isEmpty(x, y))
361362
continue;
362363

363-
sTree.makeTrunk(map.getFirstTotallyFree(x, y, -1));
364-
sTree.makeBranch(map.getFirstTotallyFree(x, y, -1));
365-
sTree.makeVine(map.getFirstTotallyFree(x, y, -1));
364+
sItems.makeItem("trunk", x, y);
365+
sItems.makeItem("branch", x, y);
366+
sItems.makeItem("vine", x, y);
366367
}
367368
}
368369
}

src/main/java/com/github/fabioticconi/alone/systems/BumpSystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class BumpSystem extends PassiveSystem
3838
static final Logger log = LoggerFactory.getLogger(BumpSystem.class);
3939

4040
ComponentMapper<Health> mHealth;
41-
ComponentMapper<Tree> mTree;
41+
ComponentMapper<Cuttable> mCuttable;
4242
ComponentMapper<Pushable> mPushable;
4343
ComponentMapper<Crushable> mCrushable;
4444
ComponentMapper<Position> mPos;
@@ -83,7 +83,7 @@ public float bumpAction(final int actorId, final Side direction)
8383
// if we were path-moving, now, whatever happens next, we stop
8484
mPath.remove(actorId);
8585

86-
if (mPlayer.has(actorId) && mTree.has(targetId))
86+
if (mPlayer.has(actorId) && mCuttable.has(targetId))
8787
{
8888
c = sTree.cut(actorId, targetId);
8989
}

src/main/java/com/github/fabioticconi/alone/systems/CrushSystem.java

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package com.github.fabioticconi.alone.systems;
2020

2121
import com.artemis.ComponentMapper;
22-
import com.artemis.EntityEdit;
2322
import com.github.fabioticconi.alone.components.*;
2423
import com.github.fabioticconi.alone.components.actions.ActionContext;
2524
import com.github.fabioticconi.alone.components.attributes.Strength;
@@ -29,9 +28,7 @@
2928
import net.mostlyoriginal.api.system.core.PassiveSystem;
3029
import org.slf4j.Logger;
3130
import org.slf4j.LoggerFactory;
32-
import rlforj.math.Point;
3331

34-
import java.awt.Color;
3532
import java.util.EnumSet;
3633

3734
/**
@@ -42,10 +39,10 @@ public class CrushSystem extends PassiveSystem
4239
{
4340
static final Logger log = LoggerFactory.getLogger(CrushSystem.class);
4441

45-
ComponentMapper<Crushable> mCrushable;
42+
ComponentMapper<Crushable> mCrush;
4643
ComponentMapper<Speed> mSpeed;
47-
ComponentMapper<Strength> mStrength;
48-
ComponentMapper<Position> mPosition;
44+
ComponentMapper<Strength> mStr;
45+
ComponentMapper<Position> mPos;
4946
ComponentMapper<Weapon> mWeapon;
5047

5148
StaminaSystem sStamina;
@@ -64,38 +61,6 @@ public CrushAction crush(final int entityId, final int targetId)
6461
return c;
6562
}
6663

67-
public int makeStone(final Point p)
68-
{
69-
return makeStone(p.x, p.y);
70-
}
71-
72-
public int makeStone(final int x, final int y)
73-
{
74-
return sItem.makeItem("stone", x, y);
75-
}
76-
77-
public int makeBoulder(final Point p)
78-
{
79-
return makeBoulder(p.x, p.y);
80-
}
81-
82-
public int makeBoulder(final int x, final int y)
83-
{
84-
final int id = world.create();
85-
final EntityEdit edit = world.edit(id);
86-
87-
edit.create(Position.class).set(x, y);
88-
edit.create(Sprite.class).set('#', Color.DARK_GRAY.brighter(), true);
89-
edit.create(LightBlocker.class);
90-
edit.create(Pushable.class);
91-
edit.create(Crushable.class);
92-
edit.add(new Name("A big boulder", "boulder"));
93-
94-
map.obstacles.set(id, x, y);
95-
96-
return id;
97-
}
98-
9964
public class CrushAction extends ActionContext
10065
{
10166
@Override
@@ -106,7 +71,7 @@ public boolean tryAction()
10671

10772
final int targetId = targets.get(0);
10873

109-
if (targetId < 0 || !mCrushable.has(targetId))
74+
if (targetId < 0 || !mCrush.has(targetId))
11075
return false;
11176

11277
final int hammerId = sItem.getWeapon(actorId, EnumSet.of(WeaponType.BLUNT), true);
@@ -131,7 +96,7 @@ public boolean tryAction()
13196

13297
// FIXME further adjust delay and cost using the hammer power
13398
delay = mSpeed.get(actorId).value;
134-
cost = delay / (mStrength.get(actorId).value + 3f);
99+
cost = delay / (mStr.get(actorId).value + 3f);
135100

136101
return true;
137102
}
@@ -146,15 +111,15 @@ public void doAction()
146111

147112
msg.send(actorId, targetId, new CrushMsg());
148113

149-
final Position p = mPosition.get(targetId);
114+
final Position p = mPos.get(targetId);
150115

151116
// from a tree we get a trunk and two branches
152117
map.obstacles.del(p.x, p.y);
153118
world.delete(targetId);
154119

155120
for (int i = 0; i < 3; i++)
156121
{
157-
makeStone(map.getFirstTotallyFree(p.x, p.y, -1));
122+
sItem.makeItem("stone", p.x, p.y);
158123
}
159124

160125
// consume a fixed amount of stamina

src/main/java/com/github/fabioticconi/alone/systems/ItemSystem.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package com.github.fabioticconi.alone.systems;
2020

21-
import com.artemis.Component;
2221
import com.artemis.ComponentMapper;
2322
import com.artemis.EntityEdit;
2423
import com.artemis.annotations.Wire;
@@ -177,6 +176,10 @@ public int makeItem(final String tag)
177176
edit.add(template.sprite);
178177
if (template.obstacle != null)
179178
edit.add(template.obstacle);
179+
if (template.crushable != null)
180+
edit.add(template.crushable);
181+
if (template.cuttable != null)
182+
edit.add(template.cuttable);
180183

181184
return id;
182185
} catch (final IOException e)
@@ -192,10 +195,12 @@ public static class ItemTemplate
192195
public String name;
193196
public String tag;
194197

195-
public Wearable wearable;
196-
public Weapon weapon;
197-
public Sprite sprite;
198-
public Obstacle obstacle;
198+
public Wearable wearable;
199+
public Weapon weapon;
200+
public Sprite sprite;
201+
public Obstacle obstacle;
202+
public Crushable crushable;
203+
public Cuttable cuttable;
199204
}
200205

201206
public GetAction get(final int actorId)

0 commit comments

Comments
 (0)