diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index ace43b85..26b85b26 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -39,7 +39,10 @@ function App() { data: '' }, hideCode: false, - stereoInLobby: true + stereoInLobby: true, + haunt: false, + globalVentsComm: false, + hearingDistance: 2.6, }); useEffect(() => { diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 47580ad4..84923133 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -89,6 +89,18 @@ const store = new Store({ stereoInLobby: { type: 'boolean', default: true + }, + haunt: { + type: 'boolean', + default: false + }, + globalVentsComm: { + type: 'boolean', + default: false + }, + hearingDistance: { + type: 'number', + default: 2.6 } } }); @@ -118,6 +130,9 @@ export interface ISettings { }, hideCode: boolean; stereoInLobby: boolean; + haunt: boolean; + globalVentsComm: boolean; + hearingDistance: number; } export const settingsReducer = (state: ISettings, action: { type: 'set' | 'setOne', action: [string, any] | ISettings @@ -137,6 +152,36 @@ interface MediaDevice { label: string; } +type EaringInputProps = { + initialDistance: string, + onValidDistance: (dist: number) => void +}; + +function EaringInput({ initialDistance, onValidDistance }: EaringInputProps) { + const [isValidNumber, setDistanceValid] = useState(true); + const [currentDistance, setCurrentDistance] = useState(initialDistance); + + useEffect(() => { + setCurrentDistance(initialDistance); + }, [initialDistance]); + + function onChange(event: React.ChangeEvent) { + setCurrentDistance(event.target.value); + + if (!isNaN(parseFloat(event.target.value)) + && parseFloat(event.target.value) >= 0 + && parseFloat(event.target.value) <= 255) { + setDistanceValid(true); + onValidDistance(parseFloat(event.target.value)); + } else { + setDistanceValid(false); + } + } + + return +} + type URLInputProps = { initialURL: string, onValidURL: (url: string) => void @@ -326,6 +371,29 @@ export default function Settings({ open, onClose }: SettingsProps) { +
setSettings({ + type: 'setOne', + action: ['haunt', !settings.haunt] + })}> + + +
+
setSettings({ + type: 'setOne', + action: ['globalVentsComm', !settings.globalVentsComm] + })}> + + +
+
+ + { + setSettings({ + type: 'setOne', + action: ['hearingDistance', dist] + }) + }} /> +
} \ No newline at end of file diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index 8c2a874e..7844d5b0 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -71,8 +71,13 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe if (isNaN(panPos[1])) panPos[1] = 999; panPos[0] = Math.min(999, Math.max(-999, panPos[0])); panPos[1] = Math.min(999, Math.max(-999, panPos[1])); - if (other.inVent) { - gain.gain.value = 0; + if (me.inVent && other.inVent) { + gain.gain.value = 1; + if (settings.globalVentsComm) { + panPos = [0, 0]; + } + pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); + pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; } if (me.isDead && other.isDead) { @@ -81,7 +86,11 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; } - if (!me.isDead && other.isDead) { + if (other.inVent) { + gain.gain.value = 0; + return; + } + if ((!me.isDead && other.isDead) && (!settings.haunt)) { gain.gain.value = 0; return; } @@ -260,7 +269,8 @@ export default function Voice() { pan.refDistance = 0.1; pan.panningModel = 'equalpower'; pan.distanceModel = 'linear'; - pan.maxDistance = 2.66 * 2; + // pan.maxDistance = 2.66 * 2; + pan.maxDistance = settings.hearingDistance * 2; pan.rolloffFactor = 1; source.connect(pan); diff --git a/yarn.lock b/yarn.lock index bbacc8a5..7e0f50f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1417,7 +1417,7 @@ ajv@^6.1.0, ajv@^6.10.1, ajv@^6.10.2, ajv@^6.12.0: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^6.12.2, ajv@^6.12.3, ajv@^6.9.1: +ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.6, ajv@^6.9.1: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==