-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathspawnMotherships.luau
More file actions
60 lines (51 loc) · 1.71 KB
/
spawnMotherships.luau
File metadata and controls
60 lines (51 loc) · 1.71 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
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Components = require(ReplicatedStorage.Shared.components)
local Matter = require(ReplicatedStorage.Lib.Matter)
local function spawnMotherships(world)
if Matter.useThrottle(10) then
local spawnPosition = Vector3.new(500, 500, 500)
* Vector3.new(math.random(1, 2) == 1 and 1 or -1, 1, math.random(1, 2) == 1 and 1 or -1)
local despawnPosition = Vector3.new(500, 500, 500)
* Vector3.new(math.random(1, 2) == 1 and 1 or -1, 1, math.random(1, 2) == 1 and 1 or -1)
local goalPosition = Vector3.new(math.random(-100, 100), 100, math.random(-100, 100))
world:spawn(
Components.Mothership({
goal = goalPosition,
nextGoal = despawnPosition,
}),
Components.Transform({
cframe = CFrame.new(spawnPosition),
})
)
end
for id in world:query(Components.Transform, Components.Mothership):without(Components.Model) do
local model = ReplicatedStorage.Assets.Mothership:Clone()
model.Parent = workspace
model.PrimaryPart:SetNetworkOwner(nil)
world:insert(id, Components.Model(model))
end
for id, mothership, transform in
world:query(Components.Mothership, Components.Transform):without(Components.Lasering)
do
if (transform.cframe.p - mothership.goal).magnitude < 10 then
if mothership.lasered then
world:despawn(id)
else
world:insert(
id,
mothership:patch({
goal = mothership.nextGoal,
lasered = true,
}),
Components.Lasering({
remainingTime = 1,
})
)
end
end
end
for _, mothership, model in world:query(Components.Mothership, Components.Model):without(Components.Lasering) do
model.Roomba.AlignPosition.Position = mothership.goal
end
end
return spawnMotherships