Skip to content

Commit

Permalink
Collision explosion fix (#692)
Browse files Browse the repository at this point in the history
* add trackedlocations

* reimplement TrackedLocation to specification

* use built-in methods for vector manipulation

* Fix merge

* Fix build

* Process tracked locations on all parent crafts

* Update RotationTask.java

* Add allowInternalCollisionExplosion feature

* remove unused imports

---------

Co-authored-by: TylerS1066 <[email protected]>
  • Loading branch information
goodroach and TylerS1066 authored Aug 15, 2024
1 parent e02019a commit de8588b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit de8588b

Please sign in to comment.