V 0.5
This commit is contained in:
21
scripts/Game/VON/SCR_ModdedVONController.c
Normal file
21
scripts/Game/VON/SCR_ModdedVONController.c
Normal file
@@ -0,0 +1,21 @@
|
||||
modded class SCR_VONController {
|
||||
override void DeactivateVON(EVONTransmitType transmitType = EVONTransmitType.NONE) {
|
||||
super.DeactivateVON(transmitType);
|
||||
}
|
||||
|
||||
override void SetVONProximityToggle(bool activate) {
|
||||
if (!m_VONComp) return;
|
||||
if (!m_DirectSpeechEntry || !m_DirectSpeechEntry.IsUsable()) return;
|
||||
if (m_bIsToggledDirect == activate) return;
|
||||
|
||||
m_bIsToggledDirect = activate;
|
||||
|
||||
if (activate) {
|
||||
ActivateVON(EVONTransmitType.DIRECT);
|
||||
} else {
|
||||
DeactivateVON(EVONTransmitType.DIRECT);
|
||||
}
|
||||
|
||||
m_OnVONActiveToggled.Invoke(m_bIsToggledDirect, false);
|
||||
}
|
||||
}
|
||||
11
scripts/Game/VON/SCR_VoiceComponents.c
Normal file
11
scripts/Game/VON/SCR_VoiceComponents.c
Normal file
@@ -0,0 +1,11 @@
|
||||
[ComponentEditorProps(category: "GameScripted/", description: "Whispering VoN component")]
|
||||
class SCR_VoNWhisperingClass: SCR_VoNComponentClass {}
|
||||
class SCR_VoNWhispering: SCR_VoNComponent {}
|
||||
|
||||
[ComponentEditorProps(category: "GameScripted/", description: "Normal VoN component")]
|
||||
class SCR_VoNNormalClass: SCR_VoNComponentClass {}
|
||||
class SCR_VoNNormal: SCR_VoNComponent {}
|
||||
|
||||
[ComponentEditorProps(category: "GameScripted/", description: "Loud VoN component")]
|
||||
class SCR_VoNLoudClass: SCR_VoNComponentClass {}
|
||||
class SCR_VoNLoud: SCR_VoNComponent {}
|
||||
121
scripts/Game/VON/SCR_VoiceRangeController.c
Normal file
121
scripts/Game/VON/SCR_VoiceRangeController.c
Normal file
@@ -0,0 +1,121 @@
|
||||
[ComponentEditorProps(category: "GameScripted/", description: "Voice Range Controller (Per Meter)")]
|
||||
class SCR_VoiceRangeControllerClass: ScriptComponentClass {}
|
||||
|
||||
class SCR_VoiceRangeController: ScriptComponent {
|
||||
|
||||
[Attribute("25", UIWidgets.Slider, "Start-Reichweite in Metern", "1 100 1")]
|
||||
protected int m_iCurrentRange;
|
||||
|
||||
[Attribute("1", UIWidgets.Slider, "Minimale Reichweite", "1 100 1")]
|
||||
protected int m_iMinRange;
|
||||
|
||||
[Attribute("100", UIWidgets.Slider, "Maximale Reichweite", "1 100 1")]
|
||||
protected int m_iMaxRange;
|
||||
|
||||
[Attribute("1", UIWidgets.Slider, "Schrittgröße (Meter pro Tastendruck)", "1 50 1")]
|
||||
protected int m_iStepSize;
|
||||
|
||||
protected ref Shape m_RangeCircleShape;
|
||||
|
||||
static SCR_VoiceRangeController GetInstance() {
|
||||
if (!GetGame().GetPlayerController()) return null;
|
||||
return SCR_VoiceRangeController.Cast(GetGame().GetPlayerController().FindComponent(SCR_VoiceRangeController));
|
||||
}
|
||||
|
||||
void SCR_VoiceRangeController(IEntityComponentSource src, IEntity ent, IEntity parent) {
|
||||
SetEventMask(ent, EntityEvent.INIT);
|
||||
}
|
||||
|
||||
protected override void EOnInit(IEntity owner) {
|
||||
if (!GetGame().GetInputManager()) return;
|
||||
|
||||
// Die Actions, die aufgerufen werden, wenn du + oder - drückst
|
||||
GetGame().GetInputManager().AddActionListener("SCR_VoiceRangeUp", EActionTrigger.DOWN, IncreaseRange);
|
||||
GetGame().GetInputManager().AddActionListener("SCR_VoiceRangeDown", EActionTrigger.DOWN, DecreaseRange);
|
||||
}
|
||||
|
||||
void IncreaseRange() {
|
||||
ChangeRange(1);
|
||||
}
|
||||
|
||||
void DecreaseRange() {
|
||||
ChangeRange(-1);
|
||||
}
|
||||
|
||||
void ChangeRange(int direction) {
|
||||
// Berechnet die neue Reichweite basierend auf der Schrittgröße
|
||||
int newRange = Math.ClampInt(m_iCurrentRange + (direction * m_iStepSize), m_iMinRange, m_iMaxRange);
|
||||
|
||||
// Nichts tun, wenn das Limit bereits erreicht ist
|
||||
if (m_iCurrentRange == newRange) return;
|
||||
|
||||
m_iCurrentRange = newRange;
|
||||
|
||||
ApplyRangeToVON();
|
||||
UpdateUI();
|
||||
DrawRangeCircle();
|
||||
}
|
||||
|
||||
protected void ApplyRangeToVON() {
|
||||
IEntity player = GetGame().GetPlayerController().GetControlledEntity();
|
||||
if (!player) return;
|
||||
|
||||
SCR_VONController vonContr = SCR_VONController.Cast(GetOwner().FindComponent(SCR_VONController));
|
||||
if (!vonContr) return;
|
||||
|
||||
// --- HYBRID LÖSUNG ---
|
||||
// Da die Engine "pro Meter" im echten Voice-Chat nicht zulässt,
|
||||
// ordnen wir die Meterzahl im Hintergrund den 3 Komponenten zu.
|
||||
typename compType = SCR_VoNNormal; // Standard
|
||||
|
||||
if (m_iCurrentRange <= 15) {
|
||||
compType = SCR_VoNWhispering;
|
||||
} else if (m_iCurrentRange >= 50) {
|
||||
compType = SCR_VoNLoud;
|
||||
}
|
||||
|
||||
SCR_VoNComponent newVonComp = SCR_VoNComponent.Cast(player.FindComponent(compType));
|
||||
if (newVonComp) {
|
||||
vonContr.SetVONComponent(newVonComp);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateUI() {
|
||||
SCR_HUDManagerComponent hud = SCR_HUDManagerComponent.Cast(GetOwner().FindComponent(SCR_HUDManagerComponent));
|
||||
if (!hud) return;
|
||||
|
||||
SCR_VoiceRangeDisplay display = SCR_VoiceRangeDisplay.Cast(hud.FindInfoDisplay(SCR_VoiceRangeDisplay));
|
||||
if (display) {
|
||||
// Übergibt die exakte Meterzahl an dein UI
|
||||
display.UpdateRangeText(m_iCurrentRange);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawRangeCircle() {
|
||||
IEntity player = GetGame().GetPlayerController().GetControlledEntity();
|
||||
if (!player) return;
|
||||
|
||||
if (m_RangeCircleShape) {
|
||||
m_RangeCircleShape = null;
|
||||
}
|
||||
|
||||
vector mat[4];
|
||||
player.GetTransform(mat);
|
||||
|
||||
vector boundsMin, boundsMax;
|
||||
player.GetBounds(boundsMin, boundsMax);
|
||||
mat[3][1] = mat[3][1] + boundsMin[1] + 0.1;
|
||||
|
||||
int color = ARGB(200, 50, 150, 255);
|
||||
|
||||
// Zeichnet den Kreis mit dem exakten Radius in Metern (m_iCurrentRange)
|
||||
m_RangeCircleShape = Shape.CreateCylinder(color, ShapeFlags.WIREFRAME | ShapeFlags.TRANSP, mat, m_iCurrentRange, 0.05);
|
||||
|
||||
GetGame().GetCallqueue().Remove(HideRangeCircle);
|
||||
GetGame().GetCallqueue().CallLater(HideRangeCircle, 2000, false);
|
||||
}
|
||||
|
||||
void HideRangeCircle() {
|
||||
m_RangeCircleShape = null;
|
||||
}
|
||||
}
|
||||
43
scripts/Game/VON/SCR_VoiceRangeDisplay.c
Normal file
43
scripts/Game/VON/SCR_VoiceRangeDisplay.c
Normal file
@@ -0,0 +1,43 @@
|
||||
class SCR_VoiceRangeDisplay: SCR_InfoDisplay {
|
||||
protected TextWidget m_wRangeText;
|
||||
protected SCR_FadeUIComponent m_FadeComponent;
|
||||
|
||||
protected override event void OnStartDraw(IEntity owner) {
|
||||
super.OnStartDraw(owner);
|
||||
|
||||
if (!m_wRoot) {
|
||||
// Passe den Pfad zu deiner UI Layout-Datei an
|
||||
m_wRoot = GetGame().GetWorkspace().CreateWidgets("68D6F5422C10ACFC/UI/layouts/VoiceRange/VoiceRangeDynamicNumber.layout");
|
||||
if (!m_wRoot) return;
|
||||
}
|
||||
|
||||
m_wRangeText = TextWidget.Cast(m_wRoot.FindAnyWidget("RangeText"));
|
||||
if (!m_wRangeText) return;
|
||||
|
||||
m_FadeComponent = SCR_FadeUIComponent.Cast(m_wRangeText.FindHandler(SCR_FadeUIComponent));
|
||||
|
||||
m_wRangeText.SetVisible(false);
|
||||
}
|
||||
|
||||
void UpdateRangeText(int range) {
|
||||
if (!m_wRangeText) return;
|
||||
|
||||
m_wRangeText.SetText(range.ToString() + " m");
|
||||
m_wRangeText.SetVisible(true);
|
||||
|
||||
if (m_FadeComponent) {
|
||||
m_FadeComponent.FadeIn(true);
|
||||
}
|
||||
|
||||
GetGame().GetCallqueue().Remove(StartFadeOut);
|
||||
GetGame().GetCallqueue().CallLater(StartFadeOut, 3000, false);
|
||||
}
|
||||
|
||||
protected void StartFadeOut() {
|
||||
if (m_FadeComponent) {
|
||||
m_FadeComponent.FadeOut(false);
|
||||
} else if (m_wRangeText) {
|
||||
m_wRangeText.SetVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user