Most texure work
This commit is contained in:
@@ -6,58 +6,20 @@
|
||||
#include "tile.h"
|
||||
#include "../util/audio.h"
|
||||
|
||||
const ItemType FurnaceRecipes[ITEMREGISTRY_SIZE] = {
|
||||
[IRON_ORE] = IRON_INGOT,
|
||||
[SILVER_ORE] = SILVER_INGOT,
|
||||
[GOLD_ORE] = GOLD_INGOT,
|
||||
[PLATINUM_ORE] = PLATINUM_INGOT
|
||||
|
||||
const MachineRecipe FurnaceRecipes[] = {
|
||||
{IRON_ORE, TYPE_AIR, IRON_INGOT, 60},
|
||||
{SILVER_ORE, TYPE_AIR, SILVER_INGOT, 70},
|
||||
{GOLD_ORE, TYPE_AIR, GOLD_INGOT, 80},
|
||||
{PLATINUM_ORE, TYPE_AIR, PLATINUM_INGOT, 90}
|
||||
};
|
||||
|
||||
void initFurnaceTile() {
|
||||
initMachineTile(TYPE_FURNACE, FurnaceRecipes, sizeof(FurnaceRecipes) / sizeof(FurnaceRecipes[0]),
|
||||
1, /* start frame */
|
||||
8 /* frame divisor */);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (outItem->type != TYPE_AIR) {
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].volume = 0;
|
||||
}
|
||||
tile->fixedFrame = 1;
|
||||
return;
|
||||
}
|
||||
tile->audioCh = getAvailableChannel();
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].volume = 255;
|
||||
audioData.synthVoices[tile->audioCh].phase = 0;
|
||||
audioData.synthVoices[tile->audioCh].sourceRect.x = TILE_SIZE * tile->rect.x;
|
||||
audioData.synthVoices[tile->audioCh].sourceRect.y = TILE_SIZE * tile->rect.y;
|
||||
audioData.synthVoices[tile->audioCh].waveform = WAVE_SINE;
|
||||
audioData.synthVoices[tile->audioCh].frequency = 200;
|
||||
}
|
||||
tile->fixedFrame = 0;
|
||||
}
|
||||
++audioData.synthVoices[tile->audioCh].frequency;
|
||||
if (audioData.synthVoices[tile->audioCh].volume < 255) {
|
||||
audioData.synthVoices[tile->audioCh].volume++;
|
||||
}
|
||||
if (outItem->type == 0 && ++tile->miscVal >= targetOutItem.miscVal) {
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].volume = 0;
|
||||
}
|
||||
tile->fixedFrame = 1;
|
||||
tile->miscVal = 0;
|
||||
inItem->type = 0;
|
||||
outItem->type = targetOutItemType;
|
||||
outItem->offset = -0.5f;
|
||||
}
|
||||
} else {
|
||||
tile->fixedFrame = 1;
|
||||
}
|
||||
updateMachine(tile, FurnaceRecipes, sizeof(FurnaceRecipes) / sizeof(FurnaceRecipes[0]), WAVE_SINE, 200, 1);
|
||||
}
|
Reference in New Issue
Block a user