acesesibiliti
This commit is contained in:
217
src/systems/MotorAccessibilitySystem.js
Normal file
217
src/systems/MotorAccessibilitySystem.js
Normal file
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* MOTOR ACCESSIBILITY SYSTEM
|
||||
* Provides assistance for players with motor disabilities
|
||||
* Note: One-handed mode is already implemented in InputRemappingSystem
|
||||
*/
|
||||
class MotorAccessibilitySystem {
|
||||
constructor(scene) {
|
||||
this.scene = scene;
|
||||
this.enabled = true;
|
||||
|
||||
// Settings
|
||||
this.settings = {
|
||||
autoAim: false, // Auto-aim assist
|
||||
autoAimStrength: 0.5, // 0-1 (strength)
|
||||
stickyKeys: false, // Hold key instead of press
|
||||
reducedInputComplexity: false, // Simplified controls
|
||||
slowMotion: false, // Slow-motion mode
|
||||
slowMotionSpeed: 0.5, // 0.1-1.0 (game speed)
|
||||
autoRun: false, // Auto-run when moving
|
||||
autoInteract: false, // Auto-interact with nearby objects
|
||||
largerClickTargets: false, // Bigger UI buttons
|
||||
holdToConfirm: false // Hold instead of click
|
||||
};
|
||||
|
||||
this.loadSettings();
|
||||
this.init();
|
||||
|
||||
console.log('✅ Motor Accessibility System initialized');
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.settings.slowMotion) {
|
||||
this.enableSlowMotion();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable auto-aim assist
|
||||
*/
|
||||
enableAutoAim() {
|
||||
this.settings.autoAim = true;
|
||||
this.saveSettings();
|
||||
console.log('🎯 Auto-aim enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable auto-aim
|
||||
*/
|
||||
disableAutoAim() {
|
||||
this.settings.autoAim = false;
|
||||
this.saveSettings();
|
||||
console.log('🎯 Auto-aim disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set auto-aim strength
|
||||
*/
|
||||
setAutoAimStrength(strength) {
|
||||
this.settings.autoAimStrength = Phaser.Math.Clamp(strength, 0, 1);
|
||||
this.saveSettings();
|
||||
console.log(`🎯 Auto-aim strength: ${this.settings.autoAimStrength}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get nearest enemy for auto-aim
|
||||
*/
|
||||
getNearestEnemy() {
|
||||
if (!this.scene.player) return null;
|
||||
|
||||
const playerPos = this.scene.player.getPosition();
|
||||
let nearest = null;
|
||||
let minDist = 999999;
|
||||
|
||||
// Find nearest NPC
|
||||
for (const npc of this.scene.npcs) {
|
||||
if (!npc.sprite || npc.isFriendly) continue;
|
||||
|
||||
const dist = Phaser.Math.Distance.Between(
|
||||
playerPos.x, playerPos.y,
|
||||
npc.gridX, npc.gridY
|
||||
);
|
||||
|
||||
if (dist < minDist) {
|
||||
minDist = dist;
|
||||
nearest = npc;
|
||||
}
|
||||
}
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply auto-aim to attack
|
||||
*/
|
||||
applyAutoAim() {
|
||||
if (!this.settings.autoAim) return null;
|
||||
|
||||
const target = this.getNearestEnemy();
|
||||
if (!target) return null;
|
||||
|
||||
// Return target position with strength factor
|
||||
return {
|
||||
x: target.gridX,
|
||||
y: target.gridY,
|
||||
strength: this.settings.autoAimStrength
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable sticky keys
|
||||
*/
|
||||
enableStickyKeys() {
|
||||
this.settings.stickyKeys = true;
|
||||
this.saveSettings();
|
||||
console.log('⌨️ Sticky keys enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable sticky keys
|
||||
*/
|
||||
disableStickyKeys() {
|
||||
this.settings.stickyKeys = false;
|
||||
this.saveSettings();
|
||||
console.log('⌨️ Sticky keys disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable slow-motion mode
|
||||
*/
|
||||
enableSlowMotion() {
|
||||
this.settings.slowMotion = true;
|
||||
this.scene.time.timeScale = this.settings.slowMotionSpeed;
|
||||
this.saveSettings();
|
||||
console.log(`🐌 Slow-motion enabled (${this.settings.slowMotionSpeed}x)`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable slow-motion mode
|
||||
*/
|
||||
disableSlowMotion() {
|
||||
this.settings.slowMotion = false;
|
||||
this.scene.time.timeScale = 1.0;
|
||||
this.saveSettings();
|
||||
console.log('🐌 Slow-motion disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slow-motion speed
|
||||
*/
|
||||
setSlowMotionSpeed(speed) {
|
||||
this.settings.slowMotionSpeed = Phaser.Math.Clamp(speed, 0.1, 1.0);
|
||||
if (this.settings.slowMotion) {
|
||||
this.scene.time.timeScale = this.settings.slowMotionSpeed;
|
||||
}
|
||||
this.saveSettings();
|
||||
console.log(`🐌 Slow-motion speed: ${this.settings.slowMotionSpeed}x`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle auto-run
|
||||
*/
|
||||
toggleAutoRun() {
|
||||
this.settings.autoRun = !this.settings.autoRun;
|
||||
this.saveSettings();
|
||||
console.log(`🏃 Auto-run: ${this.settings.autoRun ? 'ON' : 'OFF'}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle auto-interact
|
||||
*/
|
||||
toggleAutoInteract() {
|
||||
this.settings.autoInteract = !this.settings.autoInteract;
|
||||
this.saveSettings();
|
||||
console.log(`🤝 Auto-interact: ${this.settings.autoInteract ? 'ON' : 'OFF'}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update (called every frame)
|
||||
*/
|
||||
update() {
|
||||
// Auto-interact logic
|
||||
if (this.settings.autoInteract) {
|
||||
this.checkAutoInteract();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for auto-interact opportunities
|
||||
*/
|
||||
checkAutoInteract() {
|
||||
// Implementation would check for nearby interactive objects
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings
|
||||
*/
|
||||
saveSettings() {
|
||||
localStorage.setItem('novafarma_motor_accessibility', JSON.stringify(this.settings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load settings
|
||||
*/
|
||||
loadSettings() {
|
||||
const saved = localStorage.getItem('novafarma_motor_accessibility');
|
||||
if (saved) {
|
||||
this.settings = { ...this.settings, ...JSON.parse(saved) };
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.settings.slowMotion) {
|
||||
this.scene.time.timeScale = 1.0;
|
||||
}
|
||||
console.log('🦾 Motor Accessibility System destroyed');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user