Skip to content

Commit

Permalink
> Fixed: gattrib rendered setup and render2d (Halo)
Browse files Browse the repository at this point in the history
> Fixed: ISmoke
+Update
  • Loading branch information
Cediner committed Mar 25, 2024
1 parent 029183d commit 8e31452
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 18 deletions.
46 changes: 37 additions & 9 deletions src/ISmoke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* Preprocessed source code */
/* $use: lib/globfx */
/* $use: lib/env */

import haven.BGL;
import haven.Config;
import haven.Coord3f;
import haven.Drawable;
import haven.GLState;
import haven.GOut;
import haven.Gob;
Expand Down Expand Up @@ -52,7 +48,7 @@
/* >spr: ISmoke */
public class ISmoke extends Sprite implements Gob.Overlay.CDel {
static {
dev.checkFileVersion("gfx/fx/ismoke", 106);
dev.checkFileVersion("gfx/fx/ismoke", 108);
}

FloatBuffer posb = null, colb = null;
Expand All @@ -64,6 +60,16 @@ public class ISmoke extends Sprite implements Gob.Overlay.CDel {
final float sz, den, fadepow, initzv, life, srad;
boolean spawn = true;

public static Resource ctxres(Owner owner) {
Gob gob = owner.context(Gob.class);
if (gob == null)
throw (new RuntimeException("no context resource for owner " + owner));
Drawable d = gob.getattr(Drawable.class);
if (d == null)
throw (new RuntimeException("no drawable on object " + gob));
return (d.getres());
}

public ISmoke(Owner owner, Resource res, Message sdt) {
super(owner, res);
Material mat1;
Expand All @@ -76,10 +82,10 @@ public ISmoke(Owner owner, Resource res, Message sdt) {
mat = mat1;
sz = sdt.uint8() / 10.0f;
String locn = sdt.string();
if (locn.equals(""))
if (locn.isEmpty())
loc = null;
else
loc = owner.getres().layer(Skeleton.BoneOffset.class, locn).forpose(null);
loc = ctxres(owner).layer(Skeleton.BoneOffset.class, locn).forpose(null);
col = Utils.col16(sdt.uint16());
den = sdt.uint8();
fadepow = sdt.uint8() / 10.0f;
Expand All @@ -89,10 +95,32 @@ public ISmoke(Owner owner, Resource res, Message sdt) {
srad = sdt.uint8() / 10.0f;
}

public ISmoke(Owner owner, Resource res, Object... args) {
super(owner, res);
new Throwable().printStackTrace();
int a = 0;
String fl = (String) args[a++];
mat = ((fl.indexOf('o') >= 0) ? res : Resource.classres(ISmoke.class)).layer(Material.Res.class, (Integer) args[a++]).get();
sz = ((Number) args[a++]).floatValue();
String locn = (String) args[a++];
if (locn.isEmpty())
loc = null;
else
loc = owner.getres().layer(Skeleton.BoneOffset.class, locn).forpose(null);
col = (Color) args[a++];
den = ((Number) args[a++]).floatValue();
fadepow = ((Number) args[a++]).floatValue();
life = ((Number) args[a++]).floatValue();
float h = ((Number) args[a++]).floatValue();
initzv = h / life;
srad = ((Number) args[a++]).floatValue();
}

float de = 0;

private final AtomicLong ticktime = new AtomicLong(System.currentTimeMillis());
private int buffertime = 0;

@Override
public boolean tick(int idt) {
if (configuration.disableAnimation(owner)) {
Expand Down Expand Up @@ -210,7 +238,7 @@ private void updpos(GOut d) {
@Override
public Expression expand(Expression in) {
return (mul(sub(pdiv.call(prog.vctx.projxf(add(prog.vctx.eyev.depref(), vec4(bollsz.ref(), l(0.0), l(0.0), l(0.0))))),
pdiv.call(prog.vctx.posv.depref())),
pdiv.call(prog.vctx.posv.depref())),
pick(MiscLib.screensize.ref(), "x")));
}
}, 0);
Expand Down
15 changes: 9 additions & 6 deletions src/haven/Gob.java
Original file line number Diff line number Diff line change
Expand Up @@ -1402,8 +1402,8 @@ private Class<? extends GAttrib> attrclass(Class<? extends GAttrib> cl) {
}

public void setattr(GAttrib a) {
if (a instanceof haven.Rendered)
renderedattrs.add((haven.Rendered) a);
// if (a instanceof haven.Rendered)
// renderedattrs.add((haven.Rendered) a);
Class<? extends GAttrib> ac = attrclass(a.getClass());
GAttrib at = attr.put(ac, a);
if (at != null)
Expand Down Expand Up @@ -1846,9 +1846,9 @@ else if (empty)
}


for (final haven.Rendered rattr : new ArrayList<>(renderedattrs)) {
rattr.setup(rl);
}
// for (final haven.Rendered rattr : new ArrayList<>(renderedattrs)) {
// rattr.setup(rl);
// }

GobHighlight highlight = getattr(GobHighlight.class);
if (highlight != null) {
Expand Down Expand Up @@ -2010,8 +2010,11 @@ else if (isDead() && ol != null)
if (sp != null)
rl.add(sp.fx, null);
for (GAttrib a : attr) {
if (a instanceof Rendered)
if (a instanceof PView.Render2D) {
rl.add((Rendered) a, null);
} else if (a instanceof Rendered) {
((Rendered) a).setup(rl);
}
}

if (DefSettings.SHOWHITBOX.get() && hitboxmesh != null && hitboxmesh.length != 0) {
Expand Down

0 comments on commit 8e31452

Please sign in to comment.