Archive incari-client (client, 26.3, clean)
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# nohurtcam: No Hurt Cam
|
||||
|
||||
Stops the camera tilting when you're hurt by holding the game's Damage Tilt at the module's value. Moving that slider yourself turns the module off. ([ADR 0050](../../docs/adr/0050-first-modules-game-view.md))
|
||||
|
||||
| Setting | Kind | Default |
|
||||
| --- | --- | --- |
|
||||
| Shake amount | 0-100% of the game's tilt | 0%: none |
|
||||
|
||||
```sh
|
||||
./gradlew :features:nohurtcam:check
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
// No Hurt Cam (ADR 0050): the camera doesn't shake when the player is hurt.
|
||||
// A feature module: it sees the module framework and nothing else.
|
||||
dependencies {
|
||||
api(project(":framework"))
|
||||
|
||||
testImplementation(testFixtures(project(":framework")))
|
||||
testImplementation(platform(libs.junit.bom))
|
||||
testImplementation(libs.junit.jupiter)
|
||||
testImplementation(libs.assertj)
|
||||
testImplementation(libs.archunit)
|
||||
testRuntimeOnly(libs.junit.launcher)
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package incari.features.nohurtcam;
|
||||
|
||||
import incari.framework.Category;
|
||||
import incari.framework.Module;
|
||||
import incari.framework.game.GameOption;
|
||||
import incari.framework.setting.IntSetting;
|
||||
|
||||
/**
|
||||
* No Hurt Cam: the camera doesn't tilt when the player is hurt. It holds the game's own Damage Tilt
|
||||
* option (Accessibility Settings) at the module's value while on, so there's nothing to patch and
|
||||
* the game's slider shows what's in effect; moving that slider hands control back to the player
|
||||
* and turns the module off.
|
||||
*/
|
||||
public final class NoHurtCam extends Module {
|
||||
|
||||
private final IntSetting shake = settings()
|
||||
.integer("shake", "Shake amount", 0, 100, 0)
|
||||
.formattedAs(percent -> percent + "%")
|
||||
.describedAs("0%: the camera doesn't move at all when you're hurt.");
|
||||
|
||||
/** No Hurt Cam, off until the player turns it on. */
|
||||
public NoHurtCam() {
|
||||
super(
|
||||
"nohurtcam",
|
||||
"No Hurt Cam",
|
||||
"Stops the camera shaking when you take damage (the game's Damage Tilt).",
|
||||
Category.VISUAL);
|
||||
holdOption(GameOption.DAMAGE_TILT, () -> shake.get() / 100.0);
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** No Hurt Cam (ADR 0050): the camera doesn't shake when the player is hurt. */
|
||||
@NullMarked
|
||||
package incari.features.nohurtcam;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.nohurtcam;
|
||||
|
||||
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.nohurtcam", 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.nohurtcam..");
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package incari.features.nohurtcam;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import incari.framework.game.GameOption;
|
||||
import incari.framework.setting.IntSetting;
|
||||
import incari.framework.testing.TestGame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class NoHurtCamTest {
|
||||
|
||||
private final NoHurtCam module = new NoHurtCam();
|
||||
private final TestGame game = new TestGame(module);
|
||||
|
||||
@Test
|
||||
void turnsTheGamesDamageTiltOffAndBack() {
|
||||
game.options.put(GameOption.DAMAGE_TILT, 0.8);
|
||||
module.setEnabled(true);
|
||||
assertThat(game.option(GameOption.DAMAGE_TILT)).isZero();
|
||||
|
||||
module.setEnabled(false);
|
||||
assertThat(game.option(GameOption.DAMAGE_TILT)).isEqualTo(0.8, org.assertj.core.data.Offset.offset(1e-4));
|
||||
}
|
||||
|
||||
@Test
|
||||
void someShakeCanBeKept() {
|
||||
module.setEnabled(true);
|
||||
((IntSetting) module.settings().get("shake")).set(25);
|
||||
game.tick();
|
||||
assertThat(game.option(GameOption.DAMAGE_TILT)).isEqualTo(0.25);
|
||||
assertThat(module.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void movingTheGamesSliderTurnsItOff() {
|
||||
module.setEnabled(true);
|
||||
game.setOption(GameOption.DAMAGE_TILT, 0.5);
|
||||
game.tick();
|
||||
assertThat(module.isEnabled()).isFalse();
|
||||
assertThat(game.option(GameOption.DAMAGE_TILT)).isEqualTo(0.5);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user