Team-colored shields
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
uniform vec2 u_texsize;
|
uniform vec2 u_texsize;
|
||||||
|
uniform vec2 u_invsize;
|
||||||
uniform float u_time;
|
uniform float u_time;
|
||||||
uniform float u_dp;
|
uniform float u_dp;
|
||||||
uniform vec2 u_offset;
|
uniform vec2 u_offset;
|
||||||
@@ -21,19 +22,18 @@ void main(){
|
|||||||
|
|
||||||
T += vec2(sin(coords.y / 3.0 + u_time / 20.0), sin(coords.x / 3.0 + u_time / 20.0)) / u_texsize;
|
T += vec2(sin(coords.y / 3.0 + u_time / 20.0), sin(coords.x / 3.0 + u_time / 20.0)) / u_texsize;
|
||||||
|
|
||||||
float si = sin(u_time / 20.0) / 8.0;
|
|
||||||
vec4 color = texture2D(u_texture, T);
|
vec4 color = texture2D(u_texture, T);
|
||||||
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
vec2 v = u_invsize;
|
||||||
|
|
||||||
if(texture2D(u_texture, T).a < 0.9 &&
|
vec4 maxed = max(max(max(texture2D(u_texture, T + vec2(0, step) * v), texture2D(u_texture, T + vec2(0, -step) * v)), texture2D(u_texture, T + vec2(step, 0) * v)), texture2D(u_texture, T + vec2(-step, 0) * v));
|
||||||
(texture2D(u_texture, T + vec2(0, step) * v).a > 0.0 || texture2D(u_texture, T + vec2(0, -step) * v).a > 0.0 ||
|
|
||||||
texture2D(u_texture, T + vec2(step, 0) * v).a > 0.0 || texture2D(u_texture, T + vec2(-step, 0) * v).a > 0.0)){
|
|
||||||
|
|
||||||
gl_FragColor = mix(u_shieldcolor, vec4(1.0), si);
|
if(texture2D(u_texture, T).a < 0.9 && maxed.a > 0.9){
|
||||||
|
|
||||||
|
gl_FragColor = vec4(maxed.rgb, maxed.a * 100.0);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
if(color.a > 0.0){
|
if(color.a > 0.0){
|
||||||
if(mod(coords.x / u_dp + coords.y / u_dp + sin(floor(coords.x / u_dp) / 5.0) * 3.0 + sin(floor(coords.y / u_dp) / 5.0) * 3.0 + u_time / 4.0, 10.0) < 2.0){
|
if(mod(coords.x / u_dp + coords.y / u_dp + sin(coords.x / u_dp / 5.0) * 3.0 + sin(coords.y / u_dp / 5.0) * 3.0 + u_time / 4.0, 10.0) < 2.0){
|
||||||
color *= 1.65;
|
color *= 1.65;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -349,11 +349,11 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
//state.rules.zone = zone;
|
//state.rules.zone = zone;
|
||||||
for(Building core : state.teams.playerCores()){
|
for(Building core : state.teams.playerCores()){
|
||||||
for(ItemStack stack : zone.getStartingItems()){
|
for(ItemStack stack : zone.getStartingItems()){
|
||||||
core.items().add(stack.item, stack.amount);
|
core.items.add(stack.item, stack.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Building core = state.teams.playerCores().first();
|
Building core = state.teams.playerCores().first();
|
||||||
core.items().clear();
|
core.items.clear();
|
||||||
|
|
||||||
logic.play();
|
logic.play();
|
||||||
state.rules.waveTimer = false;
|
state.rules.waveTimer = false;
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
Draw.draw(Layer.plans, overlays::drawBottom);
|
Draw.draw(Layer.plans, overlays::drawBottom);
|
||||||
|
|
||||||
if(settings.getBool("animatedshields")){
|
if(settings.getBool("animatedshields") && Shaders.shield != null){
|
||||||
Draw.drawRange(Layer.shields, 1f, () -> effectBuffer.begin(Color.clear), () -> {
|
Draw.drawRange(Layer.shields, 1f, () -> effectBuffer.begin(Color.clear), () -> {
|
||||||
effectBuffer.end();
|
effectBuffer.end();
|
||||||
effectBuffer.blit(Shaders.shield);
|
effectBuffer.blit(Shaders.shield);
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ abstract class BuilderComp implements Unitc{
|
|||||||
|
|
||||||
if(!(tile.block() instanceof BuildBlock)){
|
if(!(tile.block() instanceof BuildBlock)){
|
||||||
if(!current.initialized && !current.breaking && Build.validPlace(current.block, team(), current.x, current.y, current.rotation)){
|
if(!current.initialized && !current.breaking && Build.validPlace(current.block, team(), current.x, current.y, current.rotation)){
|
||||||
boolean hasAll = !Structs.contains(current.block.requirements, i -> !core.items().has(i.item));
|
boolean hasAll = infinite || !Structs.contains(current.block.requirements, i -> core != null && !core.items.has(i.item));
|
||||||
|
|
||||||
if(hasAll || infinite){
|
if(hasAll){
|
||||||
Build.beginPlace(current.block, team(), current.x, current.y, current.rotation);
|
Build.beginPlace(current.block, team(), current.x, current.y, current.rotation);
|
||||||
}else{
|
}else{
|
||||||
current.stuck = true;
|
current.stuck = true;
|
||||||
@@ -151,7 +151,7 @@ abstract class BuilderComp implements Unitc{
|
|||||||
//requests that you have at least *started* are considered
|
//requests that you have at least *started* are considered
|
||||||
if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false;
|
if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false;
|
||||||
//TODO these are bad criteria
|
//TODO these are bad criteria
|
||||||
return (request.stuck && !core.items().has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items().has(i.item)) && !request.initialized);
|
return (request.stuck && !core.items.has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items.has(i.item)) && !request.initialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeBuild(int x, int y, boolean breaking){
|
void removeBuild(int x, int y, boolean breaking){
|
||||||
|
|||||||
@@ -192,8 +192,8 @@ public class Shaders{
|
|||||||
setUniformf("u_offset",
|
setUniformf("u_offset",
|
||||||
Core.camera.position.x - Core.camera.width / 2,
|
Core.camera.position.x - Core.camera.width / 2,
|
||||||
Core.camera.position.y - Core.camera.height / 2);
|
Core.camera.position.y - Core.camera.height / 2);
|
||||||
setUniformf("u_texsize", Core.camera.width,
|
setUniformf("u_texsize", Core.camera.width, Core.camera.height);
|
||||||
Core.camera.height);
|
setUniformf("u_invsize", 1f/Core.camera.width, 1f/Core.camera.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -339,8 +339,8 @@ public class SchematicsDialog extends BaseDialog{
|
|||||||
r.image(s.item.icon(Cicon.small)).left();
|
r.image(s.item.icon(Cicon.small)).left();
|
||||||
r.label(() -> {
|
r.label(() -> {
|
||||||
Building core = player.core();
|
Building core = player.core();
|
||||||
if(core == null || state.rules.infiniteResources || core.items().has(s.item, s.amount)) return "[lightgray]" + s.amount + "";
|
if(core == null || state.rules.infiniteResources || core.items.has(s.item, s.amount)) return "[lightgray]" + s.amount + "";
|
||||||
return (core.items().has(s.item, s.amount) ? "[lightgray]" : "[scarlet]") + Math.min(core.items().get(s.item), s.amount) + "[lightgray]/" + s.amount;
|
return (core.items.has(s.item, s.amount) ? "[lightgray]" : "[scarlet]") + Math.min(core.items.get(s.item), s.amount) + "[lightgray]/" + s.amount;
|
||||||
}).padLeft(2).left().padRight(4);
|
}).padLeft(2).left().padRight(4);
|
||||||
|
|
||||||
if(++i % 4 == 0){
|
if(++i % 4 == 0){
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
|
|
||||||
button.update(() -> { //color unplacable things gray
|
button.update(() -> { //color unplacable things gray
|
||||||
Building core = player.core();
|
Building core = player.core();
|
||||||
Color color = (state.rules.infiniteResources || (core != null && (core.items().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources))) && player.isBuilder() ? Color.white : Color.gray;
|
Color color = (state.rules.infiniteResources || (core != null && (core.items.has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources))) && player.isBuilder() ? Color.white : Color.gray;
|
||||||
button.forEach(elem -> elem.setColor(color));
|
button.forEach(elem -> elem.setColor(color));
|
||||||
button.setChecked(control.input.block == block);
|
button.setChecked(control.input.block == block);
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
Building core = player.core();
|
Building core = player.core();
|
||||||
if(core == null || state.rules.infiniteResources) return "*/*";
|
if(core == null || state.rules.infiniteResources) return "*/*";
|
||||||
|
|
||||||
int amount = core.items().get(stack.item);
|
int amount = core.items.get(stack.item);
|
||||||
int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier);
|
int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier);
|
||||||
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
|
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public class BuildBlock extends Block{
|
|||||||
setConstruct(previous, cblock);
|
setConstruct(previous, cblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
float maxProgress = core == null || team.rules().infiniteResources ? amount : checkRequired(core.items(), amount, false);
|
float maxProgress = core == null || team.rules().infiniteResources ? amount : checkRequired(core.items, amount, false);
|
||||||
|
|
||||||
for(int i = 0; i < cblock.requirements.length; i++){
|
for(int i = 0; i < cblock.requirements.length; i++){
|
||||||
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
||||||
@@ -208,7 +208,7 @@ public class BuildBlock extends Block{
|
|||||||
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
||||||
}
|
}
|
||||||
|
|
||||||
maxProgress = core == null || team.rules().infiniteResources ? maxProgress : checkRequired(core.items(), maxProgress, true);
|
maxProgress = core == null || team.rules().infiniteResources ? maxProgress : checkRequired(core.items, maxProgress, true);
|
||||||
|
|
||||||
progress = Mathf.clamp(progress + maxProgress);
|
progress = Mathf.clamp(progress + maxProgress);
|
||||||
builderID = builder.id();
|
builderID = builder.id();
|
||||||
|
|||||||
@@ -158,19 +158,12 @@ public class ForceProjector extends Block{
|
|||||||
|
|
||||||
Draw.z(Layer.shields);
|
Draw.z(Layer.shields);
|
||||||
|
|
||||||
Draw.color(Pal.accent);
|
Draw.color(team.color, Color.white, Mathf.clamp(hit));
|
||||||
|
|
||||||
if(Core.settings.getBool("animatedshields")){
|
if(Core.settings.getBool("animatedshields")){
|
||||||
Fill.poly(x, y, 6, radius);
|
Fill.poly(x, y, 6, radius);
|
||||||
|
|
||||||
Draw.z(Layer.shields + 0.01f);
|
Draw.z(Layer.shields + 0.01f);
|
||||||
|
|
||||||
if(hit > 0){
|
|
||||||
Draw.color(Color.white);
|
|
||||||
Draw.alpha(1f);
|
|
||||||
Fill.poly(x, y, 6, radius);
|
|
||||||
Draw.color();
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
Lines.stroke(1.5f);
|
Lines.stroke(1.5f);
|
||||||
Draw.alpha(0.09f + Mathf.clamp(0.08f * hit));
|
Draw.alpha(0.09f + Mathf.clamp(0.08f * hit));
|
||||||
|
|||||||
Reference in New Issue
Block a user