Skip to content

Commit a7e81a6

Browse files
committed
Update types to make it compatible for both solvers
1 parent 64fcf96 commit a7e81a6

3 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/Classes/Observer.luau

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,13 +1385,13 @@ end
13851385
@return () -> Zone?
13861386
]=]
13871387
function Observer.iterZones(self: Types.InternalObserver): () -> Types.Zone?
1388-
local zoneId: number
1388+
local zoneId: number?
13891389
local attachedList: { number }
13901390
local observerId = self.id
13911391

13921392
return function(): Types.Zone?
13931393
while true do
1394-
zoneId, attachedList = next(zoneAttachedObservers :: any, zoneId)
1394+
zoneId, attachedList = next(zoneAttachedObservers, zoneId)
13951395

13961396
if not zoneId then
13971397
return nil
@@ -1417,13 +1417,13 @@ end
14171417
@return () -> Group?
14181418
]=]
14191419
function Observer.iterGroups(self: Types.InternalObserver): () -> Types.Group?
1420-
local groupId: number
1420+
local groupId: number?
14211421
local observersMap: { [number]: boolean }
14221422
local observerId = self.id
14231423

14241424
return function(): Types.Group?
14251425
while true do
1426-
groupId, observersMap = next(State.groupToObservers :: any, groupId)
1426+
groupId, observersMap = next(State.groupToObservers, groupId)
14271427

14281428
if not groupId then
14291429
return nil
@@ -1433,7 +1433,7 @@ function Observer.iterGroups(self: Types.InternalObserver): () -> Types.Group?
14331433
continue
14341434
end
14351435

1436-
local group = State.groups[groupId]
1436+
local group = State.groups[groupId :: number]
14371437
if group then
14381438
return group
14391439
end
@@ -1451,7 +1451,7 @@ end
14511451
]=]
14521452
function Observer.iterEntitiesInside(self: Types.InternalObserver): () -> (any?, Types.Zone?)
14531453
local entities = (State.observerTrackingEntities[self.id] or {}) :: { [Types.Entity]: boolean }
1454-
local entity: Types.Entity
1454+
local entity: Types.Entity?
14551455
local observerId = self.id
14561456

14571457
return function()
@@ -1461,7 +1461,7 @@ function Observer.iterEntitiesInside(self: Types.InternalObserver): () -> (any?,
14611461
return nil
14621462
end
14631463

1464-
local data = State.entityData[entity]
1464+
local data = State.entityData[entity :: Types.Entity]
14651465
if not data then
14661466
continue
14671467
end
@@ -1471,7 +1471,7 @@ function Observer.iterEntitiesInside(self: Types.InternalObserver): () -> (any?,
14711471
continue
14721472
end
14731473

1474-
local ref = State.entityToReference[entity] or entity
1474+
local ref = State.entityToReference[entity :: Types.Entity] or entity
14751475
return ref, State.zoneIdToZoneObj[zoneId]
14761476
end
14771477
end
@@ -1487,7 +1487,7 @@ end
14871487
]=]
14881488
function Observer.iterPlayersInside(self: Types.InternalObserver): () -> (Player?, Types.Zone?)
14891489
local entities = (State.observerTrackingEntities[self.id] or {}) :: { [Types.Entity]: boolean }
1490-
local entity: Types.Entity
1490+
local entity: Types.Entity?
14911491
local observerId = self.id
14921492

14931493
return function()
@@ -1497,7 +1497,7 @@ function Observer.iterPlayersInside(self: Types.InternalObserver): () -> (Player
14971497
return nil, nil
14981498
end
14991499

1500-
local data = State.entityData[entity]
1500+
local data = State.entityData[entity :: Types.Entity]
15011501
if not data then
15021502
continue
15031503
end
@@ -1507,7 +1507,7 @@ function Observer.iterPlayersInside(self: Types.InternalObserver): () -> (Player
15071507
continue
15081508
end
15091509

1510-
local ref = State.entityToReference[entity] or entity
1510+
local ref = State.entityToReference[entity :: Types.Entity] or entity
15111511
if typeof(ref) == 'Instance' and ref:IsA('Player') then
15121512
return ref, State.zoneIdToZoneObj[zoneId]
15131513
end
@@ -1532,7 +1532,7 @@ function Observer.iterEntitiesInZone(self: Types.InternalObserver, zone: Types.Z
15321532
end
15331533
end
15341534

1535-
local entity: Types.Entity
1535+
local entity: Types.Entity?
15361536
local targetZoneId = zone:getId()
15371537
local observerId = self.id
15381538

@@ -1543,13 +1543,13 @@ function Observer.iterEntitiesInZone(self: Types.InternalObserver, zone: Types.Z
15431543
return nil
15441544
end
15451545

1546-
local data = State.entityData[entity]
1546+
local data = State.entityData[entity :: Types.Entity]
15471547

15481548
if not data or data.activeObserverMemberships[observerId] ~= targetZoneId then
15491549
continue
15501550
end
15511551

1552-
return State.entityToReference[entity] or entity
1552+
return State.entityToReference[entity :: Types.Entity] or entity
15531553
end
15541554
end
15551555
end
@@ -1571,7 +1571,7 @@ function Observer.iterPlayersInZone(self: Types.InternalObserver, zone: Types.Zo
15711571
end
15721572
end
15731573

1574-
local entity: Types.Entity
1574+
local entity: Types.Entity?
15751575
local targetZoneId = zone:getId()
15761576
local observerId = self.id
15771577

@@ -1582,13 +1582,13 @@ function Observer.iterPlayersInZone(self: Types.InternalObserver, zone: Types.Zo
15821582
return nil
15831583
end
15841584

1585-
local data = State.entityData[entity]
1585+
local data = State.entityData[entity :: Types.Entity]
15861586

15871587
if not data or data.activeObserverMemberships[observerId] ~= targetZoneId then
15881588
continue
15891589
end
15901590

1591-
local ref = State.entityToReference[entity] or entity
1591+
local ref = State.entityToReference[entity :: Types.Entity] or entity
15921592
if typeof(ref) == 'Instance' and ref:IsA('Player') then
15931593
return ref
15941594
end

src/Classes/Zones.luau

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,16 @@ end
279279
@return () -> ((BasePart | Attachment | Bone)?, Zone?)
280280
]=]
281281
function Zones.iterReferences(self: Types.InternalZones): () -> ((BasePart | Attachment | Bone)?, Types.Zone?)
282-
local currentZone: Types.Zone
282+
local currentZone: Types.Zone?
283283

284284
return function()
285285
while true do
286-
currentZone = next(self.zones :: any, currentZone)
286+
currentZone = next(self.zones, currentZone)
287287
if not currentZone then
288288
return nil, nil
289289
end
290290

291-
local ref = currentZone:getReference()
291+
local ref = (currentZone :: Types.Zone):getReference()
292292
if ref then
293293
return ref, currentZone
294294
end

src/init.luau

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,16 +565,16 @@ function QuickZone:iterZonesOfEntity(entity: any): () -> Types.Zone?
565565

566566
local memberships = data.activeObserverMemberships
567567
local seenZones: { [number]: boolean } = {}
568-
local observerId: number
568+
local observerId: number?
569569

570570
return function(): Types.Zone?
571571
while true do
572-
observerId = next(memberships :: any, observerId)
572+
observerId = next(memberships, observerId)
573573
if not observerId then
574574
return nil
575575
end
576576

577-
local zoneId = memberships[observerId]
577+
local zoneId = memberships[observerId :: number]
578578
if seenZones[zoneId] then
579579
continue
580580
end

0 commit comments

Comments
 (0)