-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBogie.lua
More file actions
96 lines (78 loc) · 1.79 KB
/
Copy pathBogie.lua
File metadata and controls
96 lines (78 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
--!strict
-- Bogie
-- Yuuwa0519
-- 2022-05-05
-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Modules
local Packages = ReplicatedStorage:FindFirstChild("Packages")
local Trove = require(Packages.Trove)
local Railways = require(script.Parent.Railways)
-- Var
local DEBUG = false
-- Main
local Bogie = {}
Bogie.__index = Bogie
function Bogie.new()
local self = setmetatable({}, Bogie)
self.Position = Vector3.new()
self.NextNodeId = 0
self.PreviouNodeId = 0
self.AssociatedBogies = {
Previous = {
Bogie = nil,
Distance = nil,
},
Next = {
Bogie = nil,
Distance = nil,
},
}
self.Trove = Trove.new()
if DEBUG then
self.DebugPart = self.Trove:Add(Instance.new("Part")) :: Part
self.DebugPart.Size = Vector3.new(1, 1, 1)
self.DebugPart.Anchored = true
self.DebugPart.CanCollide = false
self.DebugPart.CanTouch = false
self.DebugPart.CanQuery = false
self.DebugPart.Color = Color3.new(0.984313, 1, 0)
self.DebugPart.Material = Enum.Material.Neon
self.DebugPart.Name = "BogieDebugPart"
self.DebugPart.Parent = workspace
self.Trove:AttachToInstance(self.DebugPart)
end
return self
end
function Bogie:SetPosition(position: Vector3)
self.Position = position
if DEBUG then
self.DebugPart.Position = self.Position
end
end
function Bogie:SetNodes(previousNodeId: number, nextNodeId: number)
self.PreviousNodeId = previousNodeId
self.NextNodeId = nextNodeId
end
function Bogie:Destroy()
self.Trove:Destroy()
end
type AssociatedBogie = {
Bogie: Class?,
Distance: number?,
}
export type Class = typeof(setmetatable(
{} :: {
Position: Vector3,
NextNodeId: number,
PreviousNodeId: number,
AssociatedBogies: {
Previous: AssociatedBogie,
Next: AssociatedBogie,
},
DebugPart: Part?,
Trove: any,
},
Bogie
))
return Bogie