Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
Piece of sh- quarry
Browse files Browse the repository at this point in the history
  • Loading branch information
JerichoFletcher committed Jun 19, 2020
1 parent 83129a8 commit 1a5e326
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 10 deletions.
2 changes: 2 additions & 0 deletions bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ block.mechanical-warfare-seism.description = A more powerful version of Quake, w
// Region Production
block.mechanical-warfare-chemical-drill.name = Chemical Drill
block.mechanical-warfare-chemical-drill.description = A drill that employs corrosive acid. Capable of mining uranium.
block.mechanical-warfare-quarry.name = Quarry
block.mechanical-warfare-quarry.description = Extracts lumps of cobblestone. Must be placed on stone tiles.
// End Region Production
// Region Defense
Expand Down
2 changes: 2 additions & 0 deletions bundles/bundle_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ block.mechanical-warfare-ghost.description = Une tourelle anti-aérienne avancé
block.mechanical-warfare-chemical-drill.name = Foreuse chimique
block.mechanical-warfare-chemical-drill.description = Une foreuse qui utilise de l'acide corrosif. Capable de miner de l'uranium.
block.mechanical-warfare-quarry.name = Carrière
block.mechanical-warfare-quarry.description = Extraits des morceaux de roche. Doit être placé sur des carreaux de pierre.
// End Region Production
Expand Down
21 changes: 21 additions & 0 deletions content/blocks/drills/quarry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
size: 3
hasPower: true
hasItems: true
updateEffect: pulverizeMedium
updateEffectChance: 0.05
craftEffect: mineBig
craftTime: 30
consumes: {
power: 1
}
outputItem: cobblestone/1
requirements: [
copper/70
lead/50
silicon/60
iron/45
]
idleSound: drill
idleSoundVolume: 0.003
category: production
research: water-extractor
2 changes: 0 additions & 2 deletions content/blocks/environments/vanilla/char.json

This file was deleted.

2 changes: 0 additions & 2 deletions content/blocks/environments/vanilla/craters.json

This file was deleted.

2 changes: 0 additions & 2 deletions content/blocks/environments/vanilla/holostone.json

This file was deleted.

2 changes: 0 additions & 2 deletions content/blocks/environments/vanilla/ignarock.json

This file was deleted.

2 changes: 0 additions & 2 deletions content/blocks/environments/vanilla/stone.json

This file was deleted.

107 changes: 107 additions & 0 deletions scripts/blocks/drills.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,110 @@ const chemicalDrill = extendContent(Drill, "chemical-drill", {
},
});

// Stone floors
const stoneFloor = [Blocks.stone, Blocks.craters, Blocks.charr, Blocks.ignarock, Blocks.holostone];
function isStone(floor){
for(var i = 0; i < 5; i++){
if(floor === stoneFloor[i]){return true;}
}
return false;
}

// Quarry
const quarry = extendContent(GenericCrafter, "quarry", {
load(){
this.region = Core.atlas.find(this.name);
this.rotatorRegion = Core.atlas.find(this.name + "-rotator");
this.topRegion = Core.atlas.find(this.name + "-top");
this.rimRegion = Core.atlas.find(this.name + "-rim");
},
generateIcons: function(){
return [
Core.atlas.find(this.name),
Core.atlas.find(this.name + "-rotator"),
Core.atlas.find(this.name + "-top")
];
},
canPlaceOn: function(tile){
return tile.getLinkedTilesAs(this, this.tempTiles).contains(boolf(other => isStone(other.floor())));
},
update(tile){
this.super$update(tile);
var entity = tile.ent();
entity.setHeat(Mathf.lerpDelta(entity.getHeat(), entity.efficiency() > 0 ? entity.power.status : 0, 0.02));
entity.setRotation(entity.getRotation() + this.rotateSpeed * entity.delta() * entity.getHeat());
entity.setEfficiency(Mathf.lerpDelta(entity.getEfficiency(), entity.efficiency(), 0.02));
},
draw(tile){
var entity = tile.ent();
Draw.rect(this.region, tile.drawx(), tile.drawy());

Draw.color(Color.black, Pal.turretHeat, entity.getHeat() * (0.7 + Mathf.absin(Time.time(), 3, 0.3)));
Draw.blend(Blending.additive);
Draw.rect(this.rimRegion, tile.drawx(), tile.drawy());
Draw.blend();
Draw.color();

Draw.rect(this.rotatorRegion, tile.drawx(), tile.drawy(), entity.getRotation());
Draw.rect(this.topRegion, tile.drawx(), tile.drawy())
},
drawPlace(x, y, rotation, valid){
var c = 0;
var t = Vars.world.tile(x, y);
if(t != null){
t.getLinkedTilesAs(this, this.tempTiles).each(
boolf(other => isStone(other.floor())),
cons(other => c++)
);
}
this.drawPlaceText(Core.bundle.formatFloat("bar.efficiency", c / 9 * 100, 1), x, y, valid);
},
setBars(){
this.super$setBars();
this.bars.add("efficiency", func(entity => new Bar(prov(() =>
Core.bundle.formatFloat("bar.efficiency",
entity.getEfficiency() * 100, 1
)),
prov(() => Pal.ammo),
floatp(() => entity.getEfficiency())
)));
}
});
quarry.rotateSpeed = 3;
quarry.entityType = prov(() => {
const entity = extend(GenericCrafter.GenericCrafterEntity, {
getRotation: function(){
return this._rot;
},
setRotation: function(val){
this._rot = val % 360;
},
efficiency: function(){
var count = 0;
var res;
this.tile.getLinkedTilesAs(this.tile.block(), this.tile.block().tempTiles).each(boolf(other => isStone(other.floor())), cons(other => count++));
if(this.items.total() != this.tile.block().itemCapacity){
res = this.power.status * count / 9;
}else{
res = 0;
}
return res;
},
getHeat: function(){
return this._heat;
},
setHeat: function(val){
this._heat = val;
},
getEfficiency: function(){
return this._efficiency;
},
setEfficiency: function(val){
this._efficiency = val;
}
});
entity.setRotation(0);
entity.setHeat(0);
entity.setEfficiency(0);
return entity;
});
Binary file added sprites/blocks/drills/quarry-rim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/blocks/drills/quarry-rotator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/blocks/drills/quarry-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/blocks/drills/quarry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1a5e326

Please sign in to comment.