the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3#include "AbstractProjectileDispenseBehavior.h"
4#include "DispenserTile.h"
5#include "Projectile.h"
6#include "Level.h"
7#include "LevelEvent.h"
8#include "ItemInstance.h"
9
10shared_ptr<ItemInstance> AbstractProjectileDispenseBehavior::execute(BlockSource *source, shared_ptr<ItemInstance> dispensed, eOUTCOME &outcome)
11{
12 Level *world = source->getWorld();
13 if ( world->countInstanceOf(eTYPE_PROJECTILE, false) >= Level::MAX_DISPENSABLE_PROJECTILES )
14 {
15 return DefaultDispenseItemBehavior::execute(source, dispensed, outcome);
16 }
17
18 Position *position = DispenserTile::getDispensePosition(source);
19 FacingEnum *facing = DispenserTile::getFacing(source->getData());
20
21 shared_ptr<Projectile> projectile = getProjectile(world, position);
22
23 delete position;
24
25 projectile->shoot(facing->getStepX(), facing->getStepY() + .1f, facing->getStepZ(), getPower(), getUncertainty());
26 world->addEntity(dynamic_pointer_cast<Entity>(projectile));
27
28 dispensed->remove(1);
29 return dispensed;
30}
31
32void AbstractProjectileDispenseBehavior::playSound(BlockSource *source, eOUTCOME outcome)
33{
34 if (outcome != LEFT_ITEM)
35 {
36 source->getWorld()->levelEvent(LevelEvent::SOUND_LAUNCH, source->getBlockX(), source->getBlockY(), source->getBlockZ(), 0);
37 }
38}
39
40float AbstractProjectileDispenseBehavior::getUncertainty()
41{
42 return 6.0f;
43}
44
45float AbstractProjectileDispenseBehavior::getPower()
46{
47 return 1.1f;
48}