mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Work on events and attributes for doors
This commit is contained in:
@@ -39,24 +39,39 @@ type Constructor_Fun = (
|
|||||||
LandingDoorsTree: Tags.LandingTags
|
LandingDoorsTree: Tags.LandingTags
|
||||||
) -> ClassConstructor
|
) -> ClassConstructor
|
||||||
|
|
||||||
|
type Attributes = {
|
||||||
|
Hall: {
|
||||||
|
Open: BoolValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
ElevatorBox: BasePart,
|
ElevatorBox: BasePart,
|
||||||
CabDoorsType: DoorEnums.DoorEnumValues,
|
CabDoorsType: DoorEnums.DoorEnumValues,
|
||||||
CabDoorsTree: {BasePart},
|
CabDoorsTree: {BasePart},
|
||||||
LandingDoorsType: DoorEnums.DoorEnumValues,
|
LandingDoorsType: DoorEnums.DoorEnumValues,
|
||||||
LandingDoorsTree: Tags.LandingTags
|
LandingDoorsTree: Tags.LandingTags,
|
||||||
|
Attributes: Attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
local Doors = {} :: Impl_Constructor
|
local Doors = {} :: Impl_Constructor
|
||||||
Doors.__index = Doors
|
Doors.__index = Doors
|
||||||
|
|
||||||
function Doors.constructor(ElevatorBox, CabDoorsType, CabDoorsTree, LandingDoorsType, LandingDoorsTree)
|
function Doors.constructor(ElevatorBox, CabDoorsType, CabDoorsTree, LandingDoorsType, LandingDoorsTree)
|
||||||
|
local HallOpen = Instance.new("BoolValue") :: BoolValue
|
||||||
|
HallOpen.Value = true
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
ElevatorBox = ElevatorBox,
|
ElevatorBox = ElevatorBox,
|
||||||
CabDoorsType = CabDoorsType,
|
CabDoorsType = CabDoorsType,
|
||||||
CabDoorsTree = CabDoorsTree,
|
CabDoorsTree = CabDoorsTree,
|
||||||
LandingDoorsType = LandingDoorsType,
|
LandingDoorsType = LandingDoorsType,
|
||||||
LandingDoorsTree = LandingDoorsTree
|
LandingDoorsTree = LandingDoorsTree,
|
||||||
|
Attributes = {
|
||||||
|
Hall = {
|
||||||
|
Open = HallOpen
|
||||||
|
}
|
||||||
|
}
|
||||||
}, Doors)
|
}, Doors)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,21 +79,25 @@ type DoorAnimationCallback<T...> = (self: ClassConstructor, Alpha: number, Time:
|
|||||||
local function DoorAnimationAsync(self: ClassConstructor, Time: number, Callback: DoorAnimationCallback<()>)
|
local function DoorAnimationAsync(self: ClassConstructor, Time: number, Callback: DoorAnimationCallback<()>)
|
||||||
local Alpha = 0
|
local Alpha = 0
|
||||||
local StartTime = os.clock()
|
local StartTime = os.clock()
|
||||||
|
|
||||||
while RS.Stepped:Wait() do
|
while RS.Stepped:Wait() do
|
||||||
Alpha+=1e-3
|
Alpha+=1e-3
|
||||||
local AnimationTime = Algebra.LinearElapse(StartTime, Time)
|
local AnimationTime = Algebra.LinearElapse(StartTime, Time)
|
||||||
Callback(self, Alpha, AnimationTime)
|
Callback(self, Alpha, AnimationTime)
|
||||||
|
|
||||||
if AnimationTime>=1 then
|
if AnimationTime>=1 then
|
||||||
print("door animation killed")
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
type DoorAnimationsMap = {
|
type DoorAnimationsMap = {
|
||||||
Cab: {[DoorEnums.DoorEnumValues]: DoorAnimationCallback<Vector3, Vector3?, Vector3?>},
|
Cab: {
|
||||||
Floor: {[DoorEnums.DoorEnumValues]: DoorAnimationCallback<number, Vector3, Vector3>}
|
[DoorEnums.DoorEnumValues]: DoorAnimationCallback<Vector3, Vector3?, Vector3?>
|
||||||
|
},
|
||||||
|
Floor: {
|
||||||
|
[DoorEnums.DoorEnumValues]: DoorAnimationCallback<number, Vector3, Vector3>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
local DoorAnimations: DoorAnimationsMap = {
|
local DoorAnimations: DoorAnimationsMap = {
|
||||||
Cab = {},
|
Cab = {},
|
||||||
@@ -100,21 +119,20 @@ DoorAnimations.Cab[DoorEnums.Door.TripleSpeed] = function(self, Alpha, Animation
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
DoorAnimations.Floor[DoorEnums.Door.SingleSpeed] = function(self, Alpha, AnimationTime, Floor, DoorP, OpenFromVec1)
|
DoorAnimations.Floor[DoorEnums.Door.SingleSpeed] = function(self, Alpha, AnimationTime, Floor, DoorPosition, OpenFromVec1)
|
||||||
local Door = self.LandingDoorsTree[Floor][1] :: BasePart
|
(self.LandingDoorsTree[Floor][1] :: BasePart).Position = DoorPosition:Lerp(OpenFromVec1, Algebra.Easing.OutQuad(AnimationTime))
|
||||||
Door.Position = DoorP:Lerp(OpenFromVec1, Algebra.Easing.OutQuad(AnimationTime))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Doors:OpenCabAsync(ObjectSpaceDistance)
|
function Doors:OpenCabAsync(ObjectSpaceDistance)
|
||||||
local OpenFromVecTuple = self.CabDoorsTree[1].Position+ObjectSpaceDistance
|
local OpenFromVecTuple = self.CabDoorsTree[1].Position+ObjectSpaceDistance
|
||||||
DoorAnimationAsync(self, 3, function(self, Alpha, Time)
|
DoorAnimationAsync(self, 4, function(self, Alpha, Time)
|
||||||
DoorAnimations.Cab[self.CabDoorsType](self, Alpha, Time, OpenFromVecTuple)
|
DoorAnimations.Cab[self.CabDoorsType](self, Alpha, Time, OpenFromVecTuple)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Doors:CloseCabAsync(ObjectSpaceDistance)
|
function Doors:CloseCabAsync(ObjectSpaceDistance)
|
||||||
local CloseFromVecTuple = self.CabDoorsTree[1].Position-ObjectSpaceDistance
|
local CloseFromVecTuple = self.CabDoorsTree[1].Position-ObjectSpaceDistance
|
||||||
DoorAnimationAsync(self, 3, function(self, Alpha, Time)
|
DoorAnimationAsync(self, 4, function(self, Alpha, Time)
|
||||||
DoorAnimations.Cab[self.CabDoorsType](self, Alpha, Time, CloseFromVecTuple)
|
DoorAnimations.Cab[self.CabDoorsType](self, Alpha, Time, CloseFromVecTuple)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -125,20 +143,26 @@ function Doors:CloseFloorAsync(Floor, ObjectSpaceDistance)
|
|||||||
assert(DoorFloor)
|
assert(DoorFloor)
|
||||||
local Door = DoorFloor[1]
|
local Door = DoorFloor[1]
|
||||||
assert(Door)
|
assert(Door)
|
||||||
local DoorP = (Door :: BasePart).Position
|
local DoorPosition = (Door :: BasePart).Position
|
||||||
local OpenFromVecTuple = DoorP+ObjectSpaceDistance
|
local OpenFromVecTuple = DoorPosition+ObjectSpaceDistance
|
||||||
DoorAnimationAsync(self, 3, function(self, Alpha, Time)
|
DoorAnimationAsync(self, 4, function(self, Alpha, Time)
|
||||||
DoorAnimations.Floor[self.CabDoorsType](self, Alpha, Time, Floor, DoorP, OpenFromVecTuple)
|
DoorAnimations.Floor[self.CabDoorsType](self, Alpha, Time, Floor, DoorPosition, OpenFromVecTuple)
|
||||||
end)
|
end)
|
||||||
|
self.Attributes.Hall.Open.Value = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function Doors:OpenFloorAsync(Floor, ObjectSpaceDistance)
|
function Doors:OpenFloorAsync(Floor, ObjectSpaceDistance)
|
||||||
-- --this needs to be made custom for self.CabDoorsType
|
--this needs to be made custom for self.CabDoorsType
|
||||||
-- local OpenFromVecTuple = (self.LandingDoorsTree[Floor][1] :: BasePart).Position+ObjectSpaceDistance
|
local DoorFloor = self.LandingDoorsTree[Floor]
|
||||||
|
assert(DoorFloor)
|
||||||
-- DoorAnimationAsync(self, 1, function(self, Alpha, Time)
|
local Door = DoorFloor[1]
|
||||||
-- DoorAnimations.Cab[self.CabDoorsType](self, Alpha, Time, OpenFromVecTuple)
|
assert(Door)
|
||||||
-- end)
|
local DoorPosition = (Door :: BasePart).Position
|
||||||
|
local OpenFromVecTuple = DoorPosition-ObjectSpaceDistance
|
||||||
|
DoorAnimationAsync(self, 4, function(self, Alpha, Time)
|
||||||
|
DoorAnimations.Floor[self.CabDoorsType](self, Alpha, Time, Floor, DoorPosition, OpenFromVecTuple)
|
||||||
|
end)
|
||||||
|
self.Attributes.Hall.Open.Value = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsMod
|
|||||||
ButtonsConstructor:InitForElevator(2, ButtonPromptsDistance)
|
ButtonsConstructor:InitForElevator(2, ButtonPromptsDistance)
|
||||||
|
|
||||||
local TractionRopesConstructor = TractionRopes.constructor(CabRopesObject, PulleyRopesObject)
|
local TractionRopesConstructor = TractionRopes.constructor(CabRopesObject, PulleyRopesObject)
|
||||||
|
local DoorsConstructor = Doors.constructor(ElevatorBoxModel, DoorEnums.Door.SingleSpeed, CabDoorsTree, DoorEnums.Door.SingleSpeed, LandingDoorTags)
|
||||||
local EventsConstructor = Events.constructor(
|
local EventsConstructor = Events.constructor(
|
||||||
Elevator,
|
Elevator,
|
||||||
Config,
|
Config,
|
||||||
@@ -46,7 +47,4 @@ return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsMod
|
|||||||
)
|
)
|
||||||
EventsConstructor:InitButtons()
|
EventsConstructor:InitButtons()
|
||||||
|
|
||||||
local DoorsConstructor = Doors.constructor(ElevatorBoxModel, DoorEnums.Door.SingleSpeed, CabDoorsTree, DoorEnums.Door.SingleSpeed, LandingDoorTags)
|
|
||||||
task.wait(2)
|
|
||||||
DoorsConstructor:CloseFloorAsync(1, HallDoorOffset)
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user