Archive incari-client (client, 26.3, clean)
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
package incari.features.lowshield;
|
||||
|
||||
import incari.framework.Category;
|
||||
import incari.framework.Module;
|
||||
import incari.framework.event.Events;
|
||||
import incari.framework.event.HeldItem;
|
||||
import incari.framework.setting.BooleanSetting;
|
||||
import incari.framework.setting.IntSetting;
|
||||
|
||||
/**
|
||||
* Low Shield: a shield held in first person is drawn lower, so it hides less of the view. Only the
|
||||
* drawing moves: blocking works as it did.
|
||||
*/
|
||||
public final class LowShield extends Module {
|
||||
|
||||
/**
|
||||
* The view's units a percent moves the shield: 100% is the shield's height on screen (measured:
|
||||
* 0.16 units took a resting shield's top 30% of the screen down, to the screen's edge).
|
||||
*/
|
||||
static final float UNITS_PER_PERCENT = 0.0018F;
|
||||
|
||||
final IntSetting lower = settings()
|
||||
.integer("lower", "Lower by", 0, 90, 35)
|
||||
.formattedAs(percent -> percent + "%")
|
||||
.describedAs("How far down the shield is drawn, as a share of its height.");
|
||||
final BooleanSetting whileBlocking = settings()
|
||||
.bool("while-blocking", "Also while blocking", true)
|
||||
.describedAs("Off: a raised shield is drawn where the game draws it.");
|
||||
|
||||
/** Low Shield, off until the player turns it on. */
|
||||
public LowShield() {
|
||||
super("lowshield", "Low Shield", "Draws the shield in your hand lower, so it hides less.", Category.VISUAL);
|
||||
on(Events.HELD_ITEM, this::onHeldItem);
|
||||
}
|
||||
|
||||
private void onHeldItem(HeldItem item) {
|
||||
if (item.shield() && (whileBlocking.get() || !item.using())) {
|
||||
item.setLower(lower.get() * UNITS_PER_PERCENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** Low Shield (ADR 0053): the shield drawn lower in first person. */
|
||||
@NullMarked
|
||||
package incari.features.lowshield;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.lowshield;
|
||||
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
|
||||
|
||||
import com.tngtech.archunit.core.importer.ImportOption;
|
||||
import com.tngtech.archunit.junit.AnalyzeClasses;
|
||||
import com.tngtech.archunit.junit.ArchTest;
|
||||
import com.tngtech.archunit.lang.ArchRule;
|
||||
|
||||
/** A feature sees the module framework and the JDK's basics: no game, platform or other feature. */
|
||||
@AnalyzeClasses(packages = "incari.features.lowshield", importOptions = ImportOption.DoNotIncludeTests.class)
|
||||
class BoundaryTest {
|
||||
|
||||
@ArchTest
|
||||
static final ArchRule onlyTheFramework = classes()
|
||||
.should()
|
||||
.onlyDependOnClassesThat()
|
||||
.resideInAnyPackage(
|
||||
"java.lang..",
|
||||
"java.util..",
|
||||
"org.jspecify..",
|
||||
"incari.framework..",
|
||||
"incari.features.lowshield..");
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package incari.features.lowshield;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import incari.framework.setting.BooleanSetting;
|
||||
import incari.framework.testing.TestGame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LowShieldTest {
|
||||
|
||||
private final LowShield module = new LowShield();
|
||||
private final TestGame game = new TestGame(module);
|
||||
|
||||
@Test
|
||||
void lowersShieldsOnly() {
|
||||
module.setEnabled(true);
|
||||
assertThat(game.heldItem(false, true, false).lower()).isEqualTo(35 * LowShield.UNITS_PER_PERCENT);
|
||||
assertThat(game.heldItem(true, false, false).lower()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void canLeaveARaisedShieldAlone() {
|
||||
module.setEnabled(true);
|
||||
((BooleanSetting) module.settings().get("while-blocking")).set(false);
|
||||
assertThat(game.heldItem(false, true, true).lower()).isZero();
|
||||
assertThat(game.heldItem(false, true, false).lower()).isPositive();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user