Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision explosion fix #692

Merged
merged 17 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.countercraft.movecraft.craft.Craft;
import net.countercraft.movecraft.craft.CraftManager;
import net.countercraft.movecraft.craft.SinkingCraft;
import net.countercraft.movecraft.craft.SubCraft;
import net.countercraft.movecraft.craft.type.CraftType;
import net.countercraft.movecraft.events.CraftCollisionEvent;
import net.countercraft.movecraft.events.CraftCollisionExplosionEvent;
Expand Down Expand Up @@ -357,7 +358,16 @@ else if (world.equals(craft.getWorld())
}
} else if ((craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION) > 0F)
&& System.currentTimeMillis() - craft.getOrigPilotTime() > craft.getType().getIntProperty(CraftType.EXPLOSION_ARMING_TIME)) {
Craft parentCraft = null;
if (craft instanceof SubCraft) {
parentCraft = ((SubCraft) craft).getParent();
}
for (MovecraftLocation location : collisionBox) {
if (parentCraft != null && parentCraft.getHitBox().contains(location)
&& !parentCraft.getType().getBoolProperty(CraftType.ALLOW_INTERNAL_COLLISION_EXPLOSION)) {
//Prevents CollisionExplosion crafts from exploding inside the craft.
break;
}
float explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION);
boolean incendiary = craft.getType().getBoolProperty(CraftType.INCENDIARY_ON_CRASH);
if (craft.getType().getBoolProperty(CraftType.FOCUSED_EXPLOSION)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ final public class CraftType {
public static final NamespacedKey CRUISE_ON_PILOT_LIFETIME = buildKey("cruise_on_pilot_lifetime");

public static final NamespacedKey EXPLOSION_ARMING_TIME = buildKey("explosion_arming_time");

public static final NamespacedKey ALLOW_INTERNAL_COLLISION_EXPLOSION = buildKey("allow_internal_collision_explosion");
//endregion

@Contract("_ -> new")
Expand Down Expand Up @@ -566,6 +568,7 @@ else if (o instanceof Integer)
registerProperty(new BooleanProperty("mergePistonExtensions", MERGE_PISTON_EXTENSIONS, type -> false));
registerProperty(new IntegerProperty("cruiseOnPilotLifetime", CRUISE_ON_PILOT_LIFETIME, type -> 15*20));
registerProperty(new IntegerProperty("explosionArmingTime", EXPLOSION_ARMING_TIME, type -> 1000));
registerProperty(new BooleanProperty("allowInternalCollisionExplosion", ALLOW_INTERNAL_COLLISION_EXPLOSION, type -> false));

/* Craft type transforms */
// Convert speed to TICK_COOLDOWN
Expand Down