Start atlas
This commit is contained in:
@@ -4,11 +4,48 @@
|
||||
|
||||
#include "furnace.h"
|
||||
#include "tile.h"
|
||||
#include "../util/audio.h"
|
||||
|
||||
uint16_t getFurnaceNewItem(uint16_t sourceItem) {
|
||||
uint16_t realItemIndex = sourceItem - tileTypeIndex - 1;
|
||||
if (realItemIndex < 8) {
|
||||
return sourceItem + 1;
|
||||
const ItemType FurnaceRecipes[ITEMREGISTRY_SIZE] = {
|
||||
[IRON_ORE] = IRON_INGOT,
|
||||
[SILVER_ORE] = SILVER_INGOT,
|
||||
[GOLD_ORE] = GOLD_INGOT,
|
||||
[PLATINUM_ORE] = PLATINUM_INGOT
|
||||
};
|
||||
|
||||
|
||||
void updateFurnace(Tile *tile) {
|
||||
ItemOnBelt *inItem = &tile->items[FURNACE_INPUT_SLOT];
|
||||
ItemOnBelt *outItem = &tile->items[FURNACE_OUTPUT_SLOT];
|
||||
Item inItemType = ItemRegistry[inItem->type];
|
||||
|
||||
ItemType targetOutItemType = FurnaceRecipes[inItem->type];
|
||||
|
||||
Item targetOutItem = ItemRegistry[targetOutItemType];
|
||||
|
||||
if (targetOutItemType != TYPE_AIR) {
|
||||
if (tile->miscVal == 0) {
|
||||
tile->audioCh = getAvailableChannel();
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].volume = 1;
|
||||
audioData.synthVoices[tile->audioCh].phase = 0;
|
||||
audioData.synthVoices[tile->audioCh].sourceRect.x = TILE_SIZE * tile->x;
|
||||
audioData.synthVoices[tile->audioCh].sourceRect.y = TILE_SIZE * tile->y;
|
||||
audioData.synthVoices[tile->audioCh].waveform = WAVE_TRIANGLE;
|
||||
audioData.synthVoices[tile->audioCh].frequency = 99;
|
||||
}
|
||||
}
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].frequency++;
|
||||
}
|
||||
if (outItem->type == 0 && ++tile->miscVal >= targetOutItem.miscVal) {
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].volume = 0;
|
||||
}
|
||||
tile->miscVal = 0;
|
||||
inItem->type = 0;
|
||||
outItem->type = targetOutItemType;
|
||||
outItem->offset = -0.5f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user