Effects, collisions, method overrides
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
class AllEntities{
|
||||
|
||||
@EntityDef(value = {Bulletc.class, Velc.class, Timedc.class}, pooled = true)
|
||||
class BulletDef{}
|
||||
|
||||
@EntityDef(value = {Tilec.class}, isFinal = false)
|
||||
class TileDef{}
|
||||
|
||||
@EntityDef(value = {Effectc.class, Childc.class}, pooled = true)
|
||||
class EffectDef{}
|
||||
|
||||
@EntityDef({Decalc.class})
|
||||
class DecalDef{}
|
||||
|
||||
@EntityDef({Playerc.class})
|
||||
class PlayerDef{}
|
||||
|
||||
@EntityDef({Unitc.class})
|
||||
class GenericUnitDef{}
|
||||
|
||||
@GroupDef(Entityc.class)
|
||||
void all(){
|
||||
|
||||
}
|
||||
|
||||
@GroupDef(Playerc.class)
|
||||
void player(){
|
||||
|
||||
}
|
||||
|
||||
@GroupDef(value = Unitc.class, spatial = true)
|
||||
void unit(){
|
||||
|
||||
}
|
||||
|
||||
@GroupDef(Tilec.class)
|
||||
void tile(){
|
||||
|
||||
}
|
||||
|
||||
@GroupDef(Syncc.class)
|
||||
void sync(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,12 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
|
||||
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc, DrawLayerFloorc{
|
||||
Color color = new Color(1, 1, 1, 1);
|
||||
TextureRegion region;
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
public void drawFloor(){
|
||||
Draw.color(color);
|
||||
Draw.rect(region, x(), y(), rotation());
|
||||
Draw.color();
|
||||
|
||||
@@ -5,10 +5,5 @@ import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class DrawComp implements Posc{
|
||||
|
||||
abstract float clipSize();
|
||||
|
||||
void draw(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class EffectComp implements Posc, Drawc, Timedc, Rotc{
|
||||
Effect effect;
|
||||
abstract class EffectComp implements Posc, Drawc, Timedc, Rotc, Childc{
|
||||
Color color = new Color(Color.white);
|
||||
Effect effect;
|
||||
Object data;
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
void draw(){
|
||||
effect.render(id(), color, time(), rotation(), x(), y(), data);
|
||||
}
|
||||
|
||||
|
||||
22
core/src/mindustry/entities/def/ElevationMoveComp.java
Normal file
22
core/src/mindustry/entities/def/ElevationMoveComp.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.collisions;
|
||||
|
||||
@Component
|
||||
abstract class ElevationMoveComp implements Velc, Posc, Flyingc, Hitboxc{
|
||||
transient float x, y;
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
public void move(float cx, float cy){
|
||||
if(isFlying()){
|
||||
x += cx;
|
||||
y += cy;
|
||||
}else{
|
||||
collisions.move(this, cx, cy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc{
|
||||
|
||||
float elevation;
|
||||
float drownTime;
|
||||
float splashTimer;
|
||||
|
||||
boolean isGrounded(){
|
||||
return elevation < 0.001f;
|
||||
@@ -25,15 +26,22 @@ abstract class FlyingComp implements Posc, Velc, Healthc{
|
||||
return elevation >= 0.001f;
|
||||
}
|
||||
|
||||
boolean canDrown(){
|
||||
return isGrounded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
Floor floor = floorOn();
|
||||
|
||||
if(isGrounded() && floor.isLiquid && vel.len2() > 0.4f*0.4f && Mathf.chance((vel.len2() * floor.speedMultiplier) * 0.03f * Time.delta())){
|
||||
floor.walkEffect.at(x, y, 0, floor.color);
|
||||
if(isGrounded() && floor.isLiquid && !vel.isZero(0.01f)){
|
||||
if((splashTimer += vel.len()) >= 7f){
|
||||
floor.walkEffect.at(x, y, 0, floor.color);
|
||||
splashTimer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
if(isGrounded() && floor.isLiquid && floor.drownTime > 0){
|
||||
if(canDrown() && floor.isLiquid && floor.drownTime > 0){
|
||||
drownTime += Time.delta() * 1f / floor.drownTime;
|
||||
drownTime = Mathf.clamp(drownTime);
|
||||
if(Mathf.chance(Time.delta() * 0.05f)){
|
||||
|
||||
13
core/src/mindustry/entities/def/GroundEffectComp.java
Normal file
13
core/src/mindustry/entities/def/GroundEffectComp.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class GroundEffectComp implements Effectc, DrawLayerFloorOverc{
|
||||
|
||||
@Override
|
||||
public void drawFloorOver(){
|
||||
draw();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc, Unitc, Legsc{
|
||||
abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc, Unitc, Legsc, ElevationMovec{
|
||||
transient float x, y;
|
||||
|
||||
float baseRotation, walkTime;
|
||||
|
||||
13
core/src/mindustry/entities/def/StandardEffectComp.java
Normal file
13
core/src/mindustry/entities/def/StandardEffectComp.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class StandardEffectComp implements Effectc, DrawLayerEffectsc{
|
||||
|
||||
@Override
|
||||
public void drawEffects(){
|
||||
draw();
|
||||
}
|
||||
}
|
||||
@@ -73,13 +73,16 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
return Tmp.c1.set(Color.white);
|
||||
}
|
||||
|
||||
float r = 0f, g = 0f, b = 0f;
|
||||
float r = 1f, g = 1f, b = 1f, total = 0f;
|
||||
for(StatusEntry entry : statuses){
|
||||
r += entry.effect.color.r;
|
||||
g += entry.effect.color.g;
|
||||
b += entry.effect.color.b;
|
||||
float intensity = entry.time < 10f ? entry.time/10f : 1f;
|
||||
r += entry.effect.color.r * intensity;
|
||||
g += entry.effect.color.g * intensity;
|
||||
b += entry.effect.color.b * intensity;
|
||||
total += intensity;
|
||||
}
|
||||
return Tmp.c1.set(r / statuses.size, g / statuses.size, b / statuses.size, 1f);
|
||||
float count = statuses.size + total;
|
||||
return Tmp.c1.set(r / count, g / count, b / count, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,6 +121,8 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
return applied.get(effect.id);
|
||||
}
|
||||
|
||||
//TODO autogen io code
|
||||
|
||||
void writeSave(DataOutput stream) throws IOException{
|
||||
stream.writeByte(statuses.size);
|
||||
for(StatusEntry entry : statuses){
|
||||
|
||||
@@ -14,9 +14,12 @@ abstract class VelComp implements Posc{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
//TODO handle solidity
|
||||
x += vel.x;
|
||||
y += vel.y;
|
||||
move(vel.x, vel.y);
|
||||
vel.scl(1f - drag * Time.delta());
|
||||
}
|
||||
|
||||
void move(float cx, float cy){
|
||||
x += cx;
|
||||
y += cy;
|
||||
}
|
||||
}
|
||||
|
||||
33
core/src/mindustry/entities/def/WaterMoveComp.java
Normal file
33
core/src/mindustry/entities/def/WaterMoveComp.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.collisions;
|
||||
|
||||
//just a proof of concept
|
||||
@Component
|
||||
abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc{
|
||||
transient float x, y;
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
public void move(float cx, float cy){
|
||||
if(isGrounded()){
|
||||
if(!EntityCollisions.waterSolid(tileX(), tileY())){
|
||||
collisions.move(this, cx, cy, EntityCollisions::waterSolid);
|
||||
}
|
||||
}else{
|
||||
x += cx;
|
||||
y += cy;
|
||||
}
|
||||
}
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
public boolean canDrown(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user