Skip to content

Commit

Permalink
(0.651.0.6510833)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgoMoose authored and github-actions[bot] committed Nov 14, 2024
1 parent 1fe2a9f commit 54c77b7
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 89 deletions.
95 changes: 55 additions & 40 deletions src/PlayerModulePatched/CameraModule/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ local UserInputService = game:GetService("UserInputService")
local VRService = game:GetService("VRService")
local UserGameSettings = UserSettings():GetService("UserGameSettings")

local CommonUtils = script.Parent:WaitForChild("CommonUtils")
local FlagUtil = require(CommonUtils:WaitForChild("FlagUtil"))

-- Static camera utils
local CameraUtils = require(script:WaitForChild("CameraUtils"))
local CameraInput = require(script:WaitForChild("CameraInput"))
Expand Down Expand Up @@ -103,6 +106,7 @@ do
PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.CameraToggle)
end

local FFlagUserRespectLegacyCameraOptions = FlagUtil.getUserFlag("UserRespectLegacyCameraOptions")

function CameraModule.new()
local self = setmetatable({},CameraModule)
Expand Down Expand Up @@ -142,7 +146,11 @@ function CameraModule.new()
end
end

self:ActivateCameraController(self:GetCameraControlChoice())
if FFlagUserRespectLegacyCameraOptions then
self:ActivateCameraController()
else
self:ActivateCameraController(self:GetCameraControlChoice())
end
self:ActivateOcclusionModule(Players.LocalPlayer.DevCameraOcclusionMode)
self:OnCurrentCameraChanged() -- Does initializations and makes first camera controller
RunService:BindToRenderStep("cameraRenderUpdate", Enum.RenderPriority.Camera.Value, function(dt) self:Update(dt) end)
Expand Down Expand Up @@ -286,46 +294,43 @@ function CameraModule:ShouldUseVehicleCamera()
return isEligibleSubject and isEligibleType and isEligibleOcclusionMode
end

-- When supplied, legacyCameraType is used and cameraMovementMode is ignored (should be nil anyways)
-- Next, if userCameraCreator is passed in, that is used as the cameraCreator
function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?)
function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?) -- remove args with FFlagUserRespectLegacyCameraOptions
if FFlagUserRespectLegacyCameraOptions then
-- legacyCameraType should always be respected
legacyCameraType = (workspace.CurrentCamera :: Camera).CameraType
cameraMovementMode = self:GetCameraMovementModeFromSettings()
end
local newCameraCreator = nil

if legacyCameraType~=nil then
--[[
This function has been passed a CameraType enum value. Some of these map to the use of
the LegacyCamera module, the value "Custom" will be translated to a movementMode enum
value based on Dev and User settings, and "Scriptable" will disable the camera controller.
--]]

-- Some legacy CameraTypes map to the use of
-- the LegacyCamera module, the value "Custom" will be translated to a movementMode enum
-- value based on Dev and User settings, and "Scriptable" will disable the camera controller.
if (if FFlagUserRespectLegacyCameraOptions then true else legacyCameraType ~= nil) then
if legacyCameraType == Enum.CameraType.Scriptable then
if self.activeCameraController then
self.activeCameraController:Enable(false)
self.activeCameraController = nil
end
return

elseif legacyCameraType == Enum.CameraType.Custom then
cameraMovementMode = self:GetCameraMovementModeFromSettings()

elseif legacyCameraType == Enum.CameraType.Track then
-- Note: The TrackCamera module was basically an older, less fully-featured
-- version of ClassicCamera, no longer actively maintained, but it is re-implemented in
-- case a game was dependent on its lack of ClassicCamera's extra functionality.
cameraMovementMode = Enum.ComputerCameraMovementMode.Classic

elseif legacyCameraType == Enum.CameraType.Follow then
cameraMovementMode = Enum.ComputerCameraMovementMode.Follow

elseif legacyCameraType == Enum.CameraType.Orbital then
cameraMovementMode = Enum.ComputerCameraMovementMode.Orbital

elseif legacyCameraType == Enum.CameraType.Attach or
legacyCameraType == Enum.CameraType.Watch or
legacyCameraType == Enum.CameraType.Fixed then
elseif
legacyCameraType == Enum.CameraType.Attach
or legacyCameraType == Enum.CameraType.Watch
or legacyCameraType == Enum.CameraType.Fixed
then
newCameraCreator = LegacyCamera
else
warn("CameraScript encountered an unhandled Camera.CameraType value: ",legacyCameraType)
warn("CameraScript encountered an unhandled Camera.CameraType value: ", legacyCameraType)
end
end

Expand Down Expand Up @@ -382,12 +387,20 @@ function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraT
end

if self.activeCameraController then
if cameraMovementMode~=nil then
if FFlagUserRespectLegacyCameraOptions then
-- These functions can be removed in the future and the logic of managing cameraType/cameraMovementMode should be moved
-- into a higher level class so that activeCameraControllers can be single function.
self.activeCameraController:SetCameraMovementMode(cameraMovementMode)
elseif legacyCameraType~=nil then
-- Note that this is only called when legacyCameraType is not a type that
-- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera
self.activeCameraController:SetCameraType(legacyCameraType)
else
if cameraMovementMode~=nil then
self.activeCameraController:SetCameraMovementMode(cameraMovementMode)
elseif legacyCameraType~=nil then
-- Note that this is only called when legacyCameraType is not a type that
-- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera
self.activeCameraController:SetCameraType(legacyCameraType)
end
end
end
end
Expand Down Expand Up @@ -529,24 +542,26 @@ end

-- Formerly getCurrentCameraMode, this function resolves developer and user camera control settings to
-- decide which camera control module should be instantiated. The old method of converting redundant enum types
function CameraModule:GetCameraControlChoice()
local player = Players.LocalPlayer

if player then
if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then
-- Touch
if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then
return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode )
else
return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode )
end
else
-- Computer
if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then
local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode)
return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode)
if not FFlagUserRespectLegacyCameraOptions then
function CameraModule:GetCameraControlChoice()
local player = Players.LocalPlayer

if player then
if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then
-- Touch
if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then
return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode )
else
return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode )
end
else
return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode)
-- Computer
if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then
local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode)
return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode)
else
return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode)
end
end
end
end
Expand Down
14 changes: 11 additions & 3 deletions src/PlayerModulePatched/ControlModule/TouchJump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local GuiService = game:GetService("GuiService")
local CommonUtils = script.Parent.Parent:WaitForChild("CommonUtils")
local FlagUtil = require(CommonUtils:WaitForChild("FlagUtil"))

local FFlagUserUpdateTouchJump = FlagUtil.getUserFlag("UserUpdateTouchJump")
local FFlagUserUpdateTouchJump = FlagUtil.getUserFlag("UserUpdateTouchJump2")
local ConnectionUtil
local CharacterUtil
if FFlagUserUpdateTouchJump then
Expand Down Expand Up @@ -41,8 +41,10 @@ type TouchJumpClass = {
}

export type TouchJump = typeof(setmetatable({} :: {
_connectionUtil: any -- ConnectionUtil.ConnectionUtil,

-- holds any connections this module makes
_connectionUtil: any, -- ConnectionUtil.ConnectionUtil,
-- true if the jump is active including checks like humanoid state and if the module is active
_active: boolean
}, {} :: TouchJumpClass))


Expand Down Expand Up @@ -70,6 +72,7 @@ function TouchJump.new()
self.externallyEnabled = false
self.isJumping = false
if FFlagUserUpdateTouchJump then
self._active = false
self._connectionUtil = ConnectionUtil.new()
end

Expand All @@ -88,6 +91,10 @@ end

function TouchJump:EnableButton(enable)
if FFlagUserUpdateTouchJump then
if enable == self._active then
return
end

if enable then
if not self.jumpButton then
self:Create()
Expand Down Expand Up @@ -122,6 +129,7 @@ function TouchJump:EnableButton(enable)
self._connectionUtil:disconnect(CONNECTIONS.MENU_OPENED)
end
self:_reset()
self._active = enable
else
if enable then
if not self.jumpButton then
Expand Down
95 changes: 55 additions & 40 deletions src/PlayerModuleUnpatched/CameraModule/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ local UserInputService = game:GetService("UserInputService")
local VRService = game:GetService("VRService")
local UserGameSettings = UserSettings():GetService("UserGameSettings")

local CommonUtils = script.Parent:WaitForChild("CommonUtils")
local FlagUtil = require(CommonUtils:WaitForChild("FlagUtil"))

-- Static camera utils
local CameraUtils = require(script:WaitForChild("CameraUtils"))
local CameraInput = require(script:WaitForChild("CameraInput"))
Expand Down Expand Up @@ -91,6 +94,7 @@ do
PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.CameraToggle)
end

local FFlagUserRespectLegacyCameraOptions = FlagUtil.getUserFlag("UserRespectLegacyCameraOptions")

function CameraModule.new()
local self = setmetatable({},CameraModule)
Expand Down Expand Up @@ -130,7 +134,11 @@ function CameraModule.new()
end
end

self:ActivateCameraController(self:GetCameraControlChoice())
if FFlagUserRespectLegacyCameraOptions then
self:ActivateCameraController()
else
self:ActivateCameraController(self:GetCameraControlChoice())
end
self:ActivateOcclusionModule(Players.LocalPlayer.DevCameraOcclusionMode)
self:OnCurrentCameraChanged() -- Does initializations and makes first camera controller
RunService:BindToRenderStep("cameraRenderUpdate", Enum.RenderPriority.Camera.Value, function(dt) self:Update(dt) end)
Expand Down Expand Up @@ -274,46 +282,43 @@ function CameraModule:ShouldUseVehicleCamera()
return isEligibleSubject and isEligibleType and isEligibleOcclusionMode
end

-- When supplied, legacyCameraType is used and cameraMovementMode is ignored (should be nil anyways)
-- Next, if userCameraCreator is passed in, that is used as the cameraCreator
function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?)
function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?) -- remove args with FFlagUserRespectLegacyCameraOptions
if FFlagUserRespectLegacyCameraOptions then
-- legacyCameraType should always be respected
legacyCameraType = (workspace.CurrentCamera :: Camera).CameraType
cameraMovementMode = self:GetCameraMovementModeFromSettings()
end
local newCameraCreator = nil

if legacyCameraType~=nil then
--[[
This function has been passed a CameraType enum value. Some of these map to the use of
the LegacyCamera module, the value "Custom" will be translated to a movementMode enum
value based on Dev and User settings, and "Scriptable" will disable the camera controller.
--]]

-- Some legacy CameraTypes map to the use of
-- the LegacyCamera module, the value "Custom" will be translated to a movementMode enum
-- value based on Dev and User settings, and "Scriptable" will disable the camera controller.
if (if FFlagUserRespectLegacyCameraOptions then true else legacyCameraType ~= nil) then
if legacyCameraType == Enum.CameraType.Scriptable then
if self.activeCameraController then
self.activeCameraController:Enable(false)
self.activeCameraController = nil
end
return

elseif legacyCameraType == Enum.CameraType.Custom then
cameraMovementMode = self:GetCameraMovementModeFromSettings()

elseif legacyCameraType == Enum.CameraType.Track then
-- Note: The TrackCamera module was basically an older, less fully-featured
-- version of ClassicCamera, no longer actively maintained, but it is re-implemented in
-- case a game was dependent on its lack of ClassicCamera's extra functionality.
cameraMovementMode = Enum.ComputerCameraMovementMode.Classic

elseif legacyCameraType == Enum.CameraType.Follow then
cameraMovementMode = Enum.ComputerCameraMovementMode.Follow

elseif legacyCameraType == Enum.CameraType.Orbital then
cameraMovementMode = Enum.ComputerCameraMovementMode.Orbital

elseif legacyCameraType == Enum.CameraType.Attach or
legacyCameraType == Enum.CameraType.Watch or
legacyCameraType == Enum.CameraType.Fixed then
elseif
legacyCameraType == Enum.CameraType.Attach
or legacyCameraType == Enum.CameraType.Watch
or legacyCameraType == Enum.CameraType.Fixed
then
newCameraCreator = LegacyCamera
else
warn("CameraScript encountered an unhandled Camera.CameraType value: ",legacyCameraType)
warn("CameraScript encountered an unhandled Camera.CameraType value: ", legacyCameraType)
end
end

Expand Down Expand Up @@ -370,12 +375,20 @@ function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraT
end

if self.activeCameraController then
if cameraMovementMode~=nil then
if FFlagUserRespectLegacyCameraOptions then
-- These functions can be removed in the future and the logic of managing cameraType/cameraMovementMode should be moved
-- into a higher level class so that activeCameraControllers can be single function.
self.activeCameraController:SetCameraMovementMode(cameraMovementMode)
elseif legacyCameraType~=nil then
-- Note that this is only called when legacyCameraType is not a type that
-- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera
self.activeCameraController:SetCameraType(legacyCameraType)
else
if cameraMovementMode~=nil then
self.activeCameraController:SetCameraMovementMode(cameraMovementMode)
elseif legacyCameraType~=nil then
-- Note that this is only called when legacyCameraType is not a type that
-- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera
self.activeCameraController:SetCameraType(legacyCameraType)
end
end
end
end
Expand Down Expand Up @@ -517,24 +530,26 @@ end

-- Formerly getCurrentCameraMode, this function resolves developer and user camera control settings to
-- decide which camera control module should be instantiated. The old method of converting redundant enum types
function CameraModule:GetCameraControlChoice()
local player = Players.LocalPlayer

if player then
if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then
-- Touch
if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then
return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode )
else
return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode )
end
else
-- Computer
if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then
local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode)
return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode)
if not FFlagUserRespectLegacyCameraOptions then
function CameraModule:GetCameraControlChoice()
local player = Players.LocalPlayer

if player then
if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then
-- Touch
if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then
return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode )
else
return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode )
end
else
return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode)
-- Computer
if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then
local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode)
return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode)
else
return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode)
end
end
end
end
Expand Down
Loading

0 comments on commit 54c77b7

Please sign in to comment.