mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-28 07:22:21 -08:00
Team-colored shields
This commit is contained in:
parent
0df4e26736
commit
7401c16ded
9 changed files with 23 additions and 30 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
uniform sampler2D u_texture;
|
||||
uniform vec2 u_texsize;
|
||||
uniform vec2 u_invsize;
|
||||
uniform float u_time;
|
||||
uniform float u_dp;
|
||||
uniform vec2 u_offset;
|
||||
|
|
@ -20,20 +21,19 @@ void main(){
|
|||
vec2 coords = (T * u_texsize) + u_offset;
|
||||
|
||||
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);
|
||||
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 &&
|
||||
(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)){
|
||||
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));
|
||||
|
||||
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{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -349,11 +349,11 @@ public class Control implements ApplicationListener, Loadable{
|
|||
//state.rules.zone = zone;
|
||||
for(Building core : state.teams.playerCores()){
|
||||
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();
|
||||
core.items().clear();
|
||||
core.items.clear();
|
||||
|
||||
logic.play();
|
||||
state.rules.waveTimer = false;
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public class Renderer implements ApplicationListener{
|
|||
|
||||
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), () -> {
|
||||
effectBuffer.end();
|
||||
effectBuffer.blit(Shaders.shield);
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ abstract class BuilderComp implements Unitc{
|
|||
|
||||
if(!(tile.block() instanceof BuildBlock)){
|
||||
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);
|
||||
}else{
|
||||
current.stuck = true;
|
||||
|
|
@ -151,7 +151,7 @@ abstract class BuilderComp implements Unitc{
|
|||
//requests that you have at least *started* are considered
|
||||
if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false;
|
||||
//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){
|
||||
|
|
|
|||
|
|
@ -192,8 +192,8 @@ public class Shaders{
|
|||
setUniformf("u_offset",
|
||||
Core.camera.position.x - Core.camera.width / 2,
|
||||
Core.camera.position.y - Core.camera.height / 2);
|
||||
setUniformf("u_texsize", Core.camera.width,
|
||||
Core.camera.height);
|
||||
setUniformf("u_texsize", Core.camera.width, 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.label(() -> {
|
||||
Building core = player.core();
|
||||
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;
|
||||
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;
|
||||
}).padLeft(2).left().padRight(4);
|
||||
|
||||
if(++i % 4 == 0){
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ public class PlacementFragment extends Fragment{
|
|||
|
||||
button.update(() -> { //color unplacable things gray
|
||||
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.setChecked(control.input.block == block);
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ public class PlacementFragment extends Fragment{
|
|||
Building core = player.core();
|
||||
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);
|
||||
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public class BuildBlock extends Block{
|
|||
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++){
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
builderID = builder.id();
|
||||
|
|
|
|||
|
|
@ -158,19 +158,12 @@ public class ForceProjector extends Block{
|
|||
|
||||
Draw.z(Layer.shields);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.color(team.color, Color.white, Mathf.clamp(hit));
|
||||
|
||||
if(Core.settings.getBool("animatedshields")){
|
||||
Fill.poly(x, y, 6, radius);
|
||||
|
||||
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{
|
||||
Lines.stroke(1.5f);
|
||||
Draw.alpha(0.09f + Mathf.clamp(0.08f * hit));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue