Remove recursive search for light source, add LightSources

This commit is contained in:
2024-04-19 01:23:27 -04:00
parent e76e38bf0f
commit dbda8f9ca6
3 changed files with 38 additions and 15 deletions

View File

@@ -19,7 +19,7 @@ type Impl_Constructor = {
__index: Impl_Constructor, __index: Impl_Constructor,
constructor: Constructor_Fun, constructor: Constructor_Fun,
--Class functions --Class functions
Init: (self: ClassConstructor) -> (), Init: (self: ClassConstructor) -> ()
} & Impl_Static_Props } & Impl_Static_Props
type Impl_Static_Props = { type Impl_Static_Props = {
@@ -63,6 +63,10 @@ local function ToggleSwitchLight(EnabledState: boolean, LightObject: BasePart, L
end end
end end
local function SwitchState()
end
local LightSwitchTween = TweenModule.constructor(TweenInfo.new(Lights.SwitchAnimationTime, Enum.EasingStyle.Linear)) local LightSwitchTween = TweenModule.constructor(TweenInfo.new(Lights.SwitchAnimationTime, Enum.EasingStyle.Linear))
local function SwitchAnimation(EnabledState: boolean, LightProperties: LightProperties) local function SwitchAnimation(EnabledState: boolean, LightProperties: LightProperties)
@@ -92,6 +96,14 @@ function Lights:Init()
local EnabledState = false local EnabledState = false
if LightProperties.ColorDeactivated and LightProperties.ColorActivated and LightProperties.Prompt and LightProperties.Lights then if LightProperties.ColorDeactivated and LightProperties.ColorActivated and LightProperties.Prompt and LightProperties.Lights then
if LightProperties.Enabled then
LightProperties.Prompt.ActionText = "Toggle Off"
else
LightProperties.Prompt.ActionText = "Toggle On"
end
Prompt:AddHookTriggered(function(_Player: Player) Prompt:AddHookTriggered(function(_Player: Player)
EnabledState = not EnabledState EnabledState = not EnabledState

View File

@@ -63,10 +63,12 @@ export type LanternsTree = {
export type LightSwitchProperties = { export type LightSwitchProperties = {
Switch: BasePart?, Switch: BasePart?,
Lights: {BasePart}?, Lights: {BasePart}?,
LightSources: {PointLight | SpotLight}?,
Prompt: ProximityPrompt?, Prompt: ProximityPrompt?,
ClickSound: Sound?, ClickSound: Sound?,
ColorActivated: Color3?, ColorActivated: Color3?,
ColorDeactivated: Color3? ColorDeactivated: Color3?,
Enabled: boolean?
} }
export type LightSwitchTree = { export type LightSwitchTree = {
@@ -233,8 +235,9 @@ function Tags:__Interactables()
Interactables.LightSwitches[InteractObjectLocation] = {} Interactables.LightSwitches[InteractObjectLocation] = {}
end end
if InteractType == Enums.Interactables.LightSwitch then
local ptr = Interactables.LightSwitches[InteractObjectLocation] local ptr = Interactables.LightSwitches[InteractObjectLocation]
if InteractType == Enums.InteractType.LightSwitch then
local itype = type(Inst) == "table" local itype = type(Inst) == "table"
local Switch = (itype and (Inst :: {Instance})[1] or Inst :: Instance) :: BasePart local Switch = (itype and (Inst :: {Instance})[1] or Inst :: Instance) :: BasePart
if itype then if itype then
@@ -244,6 +247,7 @@ function Tags:__Interactables()
local Attachment = Instance.new("Attachment") :: Attachment local Attachment = Instance.new("Attachment") :: Attachment
Attachment.Parent = Switch Attachment.Parent = Switch
local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt
Prompt.ObjectText = "Light"
Prompt.MaxActivationDistance = Tags.MaxLightSwitchActivationDistance Prompt.MaxActivationDistance = Tags.MaxLightSwitchActivationDistance
Prompt.HoldDuration = Tags.MaxLightSwitchHoldDuration Prompt.HoldDuration = Tags.MaxLightSwitchHoldDuration
Prompt.Parent = Attachment Prompt.Parent = Attachment
@@ -254,9 +258,10 @@ function Tags:__Interactables()
local ActivatedColor: Color3 = Switch:GetAttribute("Activated") local ActivatedColor: Color3 = Switch:GetAttribute("Activated")
local DeactivatedColor: Color3 = Switch:GetAttribute("Deactivated") local DeactivatedColor: Color3 = Switch:GetAttribute("Deactivated")
local Enabled: boolean = Switch:GetAttribute("Enabled")
if ActivatedColor then if ActivatedColor then
ptr.ColorActivated = ActivatedColor ptr.ColorActivated = ActivatedColor
Switch:SetAttribute("Activated", nil)
print(`LightSwitch: [{Switch}] "Activated" -> "{Switch:GetAttribute("Activated")}"`) print(`LightSwitch: [{Switch}] "Activated" -> "{Switch:GetAttribute("Activated")}"`)
else else
@@ -264,7 +269,6 @@ function Tags:__Interactables()
end end
if DeactivatedColor then if DeactivatedColor then
ptr.ColorDeactivated = DeactivatedColor ptr.ColorDeactivated = DeactivatedColor
Switch:SetAttribute("Deactivated", nil)
print(`LightSwitch: [{Switch}] "Deactivated" -> "{Switch:GetAttribute("Deactivated")}"`) print(`LightSwitch: [{Switch}] "Deactivated" -> "{Switch:GetAttribute("Deactivated")}"`)
else else
@@ -274,15 +278,20 @@ function Tags:__Interactables()
ptr.Switch = Switch ptr.Switch = Switch
ptr.Prompt = Prompt ptr.Prompt = Prompt
ptr.ClickSound = ClickSound ptr.ClickSound = ClickSound
elseif InteractType == Enums.Interactables.Light then ptr.Enabled = Enabled
local ptr = Interactables.LightSwitches[InteractObjectLocation]
Switch:SetAttribute("Activated", nil)
Switch:SetAttribute("Deactivated", nil)
Switch:SetAttribute("Enabled", nil)
elseif InteractType == Enums.InteractType.Light then
if type(Inst) == "table" then if type(Inst) == "table" then
ptr.Lights = Inst ptr.Lights = Inst
else else
ptr.Lights = {} ptr.Lights = {}
table.insert(ptr.Lights :: {BasePart}, Inst :: BasePart) table.insert(ptr.Lights :: {BasePart}, Inst :: BasePart)
end end
elseif InteractType == Enums.InteractType.LightSource then
ptr.LightSources = {}
end end
end end
end end

View File

@@ -8,7 +8,7 @@ export type EnumValue = EnumButton | EnumButtonTree | EnumElevator | EnumInterac
export type EnumButton = typeof(Enums.Button) export type EnumButton = typeof(Enums.Button)
export type EnumButtonTree = typeof(Enums.ButtonTree) export type EnumButtonTree = typeof(Enums.ButtonTree)
export type EnumElevator = typeof(Enums.Elevator) export type EnumElevator = typeof(Enums.Elevator)
export type EnumInteractables = typeof(Enums.Interactables) export type EnumInteractables = typeof(Enums.InteractType)
export type ButtonValues = typeof(Enums.Button.Car) | export type ButtonValues = typeof(Enums.Button.Car) |
typeof(Enums.Button.Landing) | typeof(Enums.Button.Landing) |
@@ -21,8 +21,9 @@ export type ButtonTreeValues = typeof(Enums.ButtonTree.Car) |
typeof(Enums.ButtonTree.Relays) | typeof(Enums.ButtonTree.Relays) |
typeof(Enums.ButtonTree.Unknown) typeof(Enums.ButtonTree.Unknown)
export type InteractablesValues = typeof(Enums.Interactables.LightSwitch) | export type InteractablesValues = typeof(Enums.InteractType.LightSwitch) |
typeof(Enums.Interactables.Light) typeof(Enums.InteractType.Light) |
typeof(Enums.InteractType.LightSource)
export type ElevatorValues = typeof(Enums.Elevator.Otis1960) export type ElevatorValues = typeof(Enums.Elevator.Otis1960)
@@ -45,9 +46,10 @@ Enums.Elevator = {
Otis1960 = "Otis1960" :: "Otis1960" Otis1960 = "Otis1960" :: "Otis1960"
} }
Enums.Interactables = { Enums.InteractType = {
LightSwitch = "LightSwitch" :: "LightSwitch", LightSwitch = "LightSwitch" :: "LightSwitch",
Light = "Light" :: "Light" Light = "Light" :: "Light",
LightSource = "LightSource" :: "LightSource"
} }
return Enums return Enums