isaacscript-common 6.11.2 → 6.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/callbacks/postGridEntityCustomRender.d.ts +2 -0
- package/dist/callbacks/postGridEntityCustomRender.d.ts.map +1 -0
- package/dist/callbacks/postGridEntityCustomRender.lua +36 -0
- package/dist/callbacks/postGridEntityCustomUpdate.d.ts +2 -0
- package/dist/callbacks/postGridEntityCustomUpdate.d.ts.map +1 -0
- package/dist/callbacks/postGridEntityCustomUpdate.lua +36 -0
- package/dist/callbacks/postNewRoomEarly.lua +2 -2
- package/dist/callbacks/postPickupInitFirst.lua +1 -20
- package/dist/callbacks/reorderedCallbacks.d.ts +5 -5
- package/dist/callbacks/reorderedCallbacks.d.ts.map +1 -1
- package/dist/callbacks/reorderedCallbacks.lua +5 -5
- package/dist/callbacks/subscriptions/postGridEntityCustomRender.d.ts +6 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomRender.d.ts.map +1 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomRender.lua +29 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomUpdate.d.ts +6 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomUpdate.d.ts.map +1 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomUpdate.lua +29 -0
- package/dist/constants.d.ts +1 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.lua +0 -7
- package/dist/constantsFirstLast.d.ts +5 -1
- package/dist/constantsFirstLast.d.ts.map +1 -1
- package/dist/constantsFirstLast.lua +6 -0
- package/dist/enums/ModCallbackCustom.d.ts +89 -66
- package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/enums/ModCallbackCustom.lua +62 -58
- package/dist/enums/private/SerializationBrand.d.ts +1 -1
- package/dist/enums/private/SerializationBrand.lua +1 -1
- package/dist/features/collectibleItemPoolType.d.ts +2 -2
- package/dist/features/collectibleItemPoolType.lua +2 -2
- package/dist/features/customGridEntity.d.ts +11 -2
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +22 -2
- package/dist/features/customTrapdoor/blackSprite.d.ts.map +1 -1
- package/dist/features/customTrapdoor/blackSprite.lua +6 -6
- package/dist/features/customTrapdoor/customTrapdoorConstants.d.ts +2 -2
- package/dist/features/customTrapdoor/customTrapdoorConstants.d.ts.map +1 -1
- package/dist/features/customTrapdoor/customTrapdoorConstants.lua +2 -2
- package/dist/features/customTrapdoor/init.d.ts.map +1 -1
- package/dist/features/customTrapdoor/init.lua +4 -3
- package/dist/features/customTrapdoor/touched.d.ts.map +1 -1
- package/dist/features/customTrapdoor/touched.lua +51 -33
- package/dist/features/deployJSONRoom.d.ts +2 -2
- package/dist/features/deployJSONRoom.lua +2 -2
- package/dist/features/extraConsoleCommands/exports.d.ts +4 -3
- package/dist/features/extraConsoleCommands/exports.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/exports.lua +4 -3
- package/dist/features/extraConsoleCommands/init.lua +12 -14
- package/dist/features/extraConsoleCommands/listCommands.d.ts +15 -19
- package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/listCommands.lua +34 -42
- package/dist/features/pause.d.ts +1 -1
- package/dist/features/pause.d.ts.map +1 -1
- package/dist/features/pause.lua +87 -8
- package/dist/features/persistentEntities.d.ts.map +1 -1
- package/dist/features/persistentEntities.lua +7 -7
- package/dist/features/pickupIndex.d.ts +19 -0
- package/dist/features/pickupIndex.d.ts.map +1 -0
- package/dist/features/pickupIndex.lua +197 -0
- package/dist/features/roomHistory.d.ts +24 -0
- package/dist/features/roomHistory.d.ts.map +1 -0
- package/dist/features/roomHistory.lua +89 -0
- package/dist/functions/collectibles.d.ts +26 -13
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/collectibles.lua +26 -13
- package/dist/functions/color.d.ts +10 -0
- package/dist/functions/color.d.ts.map +1 -1
- package/dist/functions/color.lua +24 -0
- package/dist/functions/entities.d.ts +3 -3
- package/dist/functions/entities.d.ts.map +1 -1
- package/dist/functions/entities.lua +8 -3
- package/dist/functions/gridEntities.d.ts +4 -22
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/gridEntities.lua +4 -61
- package/dist/functions/isaacAPIClass.d.ts +64 -0
- package/dist/functions/isaacAPIClass.d.ts.map +1 -1
- package/dist/functions/isaacAPIClass.lua +84 -1
- package/dist/functions/kColor.d.ts +10 -0
- package/dist/functions/kColor.d.ts.map +1 -1
- package/dist/functions/kColor.lua +24 -0
- package/dist/functions/map.d.ts +2 -0
- package/dist/functions/map.d.ts.map +1 -1
- package/dist/functions/map.lua +7 -0
- package/dist/functions/npcs.d.ts +2 -2
- package/dist/functions/npcs.lua +2 -2
- package/dist/functions/pickupVariants.d.ts +2 -2
- package/dist/functions/pickupVariants.d.ts.map +1 -1
- package/dist/functions/pickupVariants.lua +2 -2
- package/dist/functions/playerCenter.lua +2 -2
- package/dist/functions/playerIndex.d.ts +0 -3
- package/dist/functions/playerIndex.d.ts.map +1 -1
- package/dist/functions/playerIndex.lua +4 -23
- package/dist/functions/random.d.ts +1 -1
- package/dist/functions/random.lua +1 -1
- package/dist/functions/rockAlt.d.ts +28 -0
- package/dist/functions/rockAlt.d.ts.map +1 -0
- package/dist/functions/rockAlt.lua +140 -0
- package/dist/functions/roomData.d.ts +3 -2
- package/dist/functions/roomData.d.ts.map +1 -1
- package/dist/functions/roomData.lua +3 -2
- package/dist/functions/rooms.d.ts +6 -6
- package/dist/functions/rooms.lua +6 -6
- package/dist/functions/set.d.ts +2 -0
- package/dist/functions/set.d.ts.map +1 -1
- package/dist/functions/set.lua +6 -0
- package/dist/functions/stage.d.ts +1 -0
- package/dist/functions/stage.d.ts.map +1 -1
- package/dist/functions/stage.lua +4 -0
- package/dist/functions/vector.d.ts +11 -0
- package/dist/functions/vector.d.ts.map +1 -1
- package/dist/functions/vector.lua +23 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +31 -0
- package/dist/initCustomCallbacks.d.ts.map +1 -1
- package/dist/initCustomCallbacks.lua +6 -0
- package/dist/initFeatures.d.ts.map +1 -1
- package/dist/initFeatures.lua +6 -0
- package/dist/interfaces/AddCallbackParameterCustom.d.ts +4 -0
- package/dist/interfaces/AddCallbackParameterCustom.d.ts.map +1 -1
- package/dist/interfaces/RoomDescription.d.ts +14 -0
- package/dist/interfaces/RoomDescription.d.ts.map +1 -0
- package/dist/interfaces/RoomDescription.lua +2 -0
- package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
- package/dist/objects/callbackRegisterFunctions.lua +6 -0
- package/dist/types/CollectibleIndex.d.ts +1 -1
- package/dist/types/PickupIndex.d.ts +17 -0
- package/dist/types/PickupIndex.d.ts.map +1 -0
- package/dist/types/PickupIndex.lua +2 -0
- package/dist/types/PlayerIndex.d.ts +1 -1
- package/dist/upgradeMod.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/callbacks/postGridEntityCustomRender.ts +44 -0
- package/src/callbacks/postGridEntityCustomUpdate.ts +44 -0
- package/src/callbacks/postNewRoomEarly.ts +2 -2
- package/src/callbacks/postPickupInitFirst.ts +3 -32
- package/src/callbacks/postPlayerReorderedCallbacks.ts +3 -3
- package/src/callbacks/reorderedCallbacks.ts +9 -8
- package/src/callbacks/subscriptions/postGridEntityCustomRender.ts +41 -0
- package/src/callbacks/subscriptions/postGridEntityCustomUpdate.ts +41 -0
- package/src/constants.ts +1 -9
- package/src/constantsFirstLast.ts +16 -0
- package/src/enums/ModCallbackCustom.ts +33 -8
- package/src/enums/private/SerializationBrand.ts +1 -1
- package/src/features/collectibleItemPoolType.ts +3 -3
- package/src/features/customGridEntity.ts +27 -2
- package/src/features/customTrapdoor/blackSprite.ts +11 -5
- package/src/features/customTrapdoor/customTrapdoorConstants.ts +2 -2
- package/src/features/customTrapdoor/init.ts +7 -5
- package/src/features/customTrapdoor/touched.ts +59 -39
- package/src/features/deployJSONRoom.ts +4 -4
- package/src/features/extraConsoleCommands/exports.ts +4 -3
- package/src/features/extraConsoleCommands/init.ts +18 -14
- package/src/features/extraConsoleCommands/listCommands.ts +38 -43
- package/src/features/pause.ts +97 -7
- package/src/features/persistentEntities.ts +9 -8
- package/src/features/pickupIndex.ts +257 -0
- package/src/features/playerInventory.ts +2 -2
- package/src/features/roomHistory.ts +113 -0
- package/src/features/saveDataManager/main.ts +2 -2
- package/src/features/taintedLazarusPlayers.ts +5 -5
- package/src/functions/collectibles.ts +26 -13
- package/src/functions/color.ts +22 -0
- package/src/functions/entities.ts +6 -3
- package/src/functions/gridEntities.ts +4 -56
- package/src/functions/isaacAPIClass.ts +106 -1
- package/src/functions/kColor.ts +22 -0
- package/src/functions/map.ts +10 -0
- package/src/functions/npcs.ts +2 -2
- package/src/functions/pickupVariants.ts +2 -2
- package/src/functions/playerCenter.ts +2 -2
- package/src/functions/playerIndex.ts +8 -21
- package/src/functions/random.ts +1 -1
- package/src/functions/rockAlt.ts +117 -0
- package/src/functions/roomData.ts +3 -2
- package/src/functions/rooms.ts +6 -6
- package/src/functions/set.ts +7 -1
- package/src/functions/stage.ts +10 -1
- package/src/functions/vector.ts +23 -0
- package/src/index.ts +4 -0
- package/src/initCustomCallbacks.ts +4 -0
- package/src/initFeatures.ts +4 -0
- package/src/interfaces/AddCallbackParameterCustom.ts +4 -0
- package/src/interfaces/RoomDescription.ts +19 -0
- package/src/objects/callbackRegisterFunctions.ts +6 -0
- package/src/types/CollectibleIndex.ts +1 -1
- package/src/types/PickupIndex.ts +15 -0
- package/src/types/PlayerIndex.ts +1 -1
- package/src/upgradeMod.ts +2 -1
|
@@ -7,8 +7,6 @@ local postEntityRemove, postNewRoomReordered, spawnAndTrack, v
|
|
|
7
7
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
8
8
|
local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
|
|
9
9
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
10
|
-
local ____cachedClasses = require("cachedClasses")
|
|
11
|
-
local game = ____cachedClasses.game
|
|
12
10
|
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
13
11
|
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
14
12
|
local ____featuresInitialized = require("featuresInitialized")
|
|
@@ -17,6 +15,8 @@ local ____entities = require("functions.entities")
|
|
|
17
15
|
local spawn = ____entities.spawn
|
|
18
16
|
local ____roomData = require("functions.roomData")
|
|
19
17
|
local getRoomListIndex = ____roomData.getRoomListIndex
|
|
18
|
+
local ____roomHistory = require("features.roomHistory")
|
|
19
|
+
local getLatestRoomDescription = ____roomHistory.getLatestRoomDescription
|
|
20
20
|
local ____exports = require("features.saveDataManager.exports")
|
|
21
21
|
local saveDataManager = ____exports.saveDataManager
|
|
22
22
|
function postEntityRemove(self, entity)
|
|
@@ -26,16 +26,16 @@ function postEntityRemove(self, entity)
|
|
|
26
26
|
return
|
|
27
27
|
end
|
|
28
28
|
local index = tuple[1]
|
|
29
|
-
local
|
|
30
|
-
local
|
|
31
|
-
local
|
|
32
|
-
v.level.persistentEntities:set(index, {
|
|
29
|
+
local previousRoomDescription = getLatestRoomDescription(nil)
|
|
30
|
+
local previousRoomListIndex = previousRoomDescription.roomListIndex
|
|
31
|
+
local persistentEntityDescription = {
|
|
33
32
|
entityType = entity.Type,
|
|
34
33
|
variant = entity.Variant,
|
|
35
34
|
subType = entity.SubType,
|
|
36
35
|
roomListIndex = previousRoomListIndex,
|
|
37
36
|
position = entity.Position
|
|
38
|
-
}
|
|
37
|
+
}
|
|
38
|
+
v.level.persistentEntities:set(index, persistentEntityDescription)
|
|
39
39
|
end
|
|
40
40
|
function postNewRoomReordered(self)
|
|
41
41
|
local roomListIndex = getRoomListIndex(nil)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { ModUpgraded } from "../classes/ModUpgraded";
|
|
3
|
+
import { PickupIndex } from "../types/PickupIndex";
|
|
4
|
+
export declare function pickupIndexInit(mod: ModUpgraded): void;
|
|
5
|
+
/**
|
|
6
|
+
* Mods often have to track variables relating to a pickups. Finding an index for these kinds of
|
|
7
|
+
* data structures is difficult, since pickups are respawned every time a player re-enters a room,
|
|
8
|
+
* so the `PtrHash` will change.
|
|
9
|
+
*
|
|
10
|
+
* Use this function to get a unique index for a pickup to use in these data structures.
|
|
11
|
+
*
|
|
12
|
+
* Specifically, `PickupIndex` is a number that represents the spawn order of the pickup on the
|
|
13
|
+
* current run. For example, the first pickup spawned will have an index of 1, the second one will
|
|
14
|
+
* have an index of 2, and so on.
|
|
15
|
+
*
|
|
16
|
+
* Tracking pickups requires stateful tracking, so using pickup indexes requires an upgraded mod.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPickupIndex(pickup: EntityPickup): PickupIndex;
|
|
19
|
+
//# sourceMappingURL=pickupIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickupIndex.d.ts","sourceRoot":"","sources":["../../src/features/pickupIndex.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAQrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAgCnD,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAatD;AA0KD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAahE"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local postPickupInit, postEntityRemovePickup, checkDespawningFromPlayerLeavingRoom, trackDespawningPickupMetadata, postNewRoomReordered, getStoredPickupIndex, getPostAscentPickupIndex, v
|
|
7
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
8
|
+
local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
|
|
9
|
+
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
10
|
+
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
|
|
11
|
+
local ____cachedClasses = require("cachedClasses")
|
|
12
|
+
local game = ____cachedClasses.game
|
|
13
|
+
local ____DefaultMap = require("classes.DefaultMap")
|
|
14
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
15
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
16
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
17
|
+
local ____featuresInitialized = require("featuresInitialized")
|
|
18
|
+
local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
|
|
19
|
+
local ____entities = require("functions.entities")
|
|
20
|
+
local getEntityID = ____entities.getEntityID
|
|
21
|
+
local ____entitiesSpecific = require("functions.entitiesSpecific")
|
|
22
|
+
local getPickups = ____entitiesSpecific.getPickups
|
|
23
|
+
local ____roomData = require("functions.roomData")
|
|
24
|
+
local getRoomListIndex = ____roomData.getRoomListIndex
|
|
25
|
+
local ____stage = require("functions.stage")
|
|
26
|
+
local onAscent = ____stage.onAscent
|
|
27
|
+
local ____vector = require("functions.vector")
|
|
28
|
+
local vectorEquals = ____vector.vectorEquals
|
|
29
|
+
local ____roomHistory = require("features.roomHistory")
|
|
30
|
+
local getLatestRoomDescription = ____roomHistory.getLatestRoomDescription
|
|
31
|
+
local ____exports = require("features.saveDataManager.exports")
|
|
32
|
+
local saveDataManager = ____exports.saveDataManager
|
|
33
|
+
function postPickupInit(self, pickup)
|
|
34
|
+
local ptrHash = GetPtrHash(pickup)
|
|
35
|
+
if v.room.pickupIndexes:has(ptrHash) then
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
local room = game:GetRoom()
|
|
39
|
+
local isFirstVisit = room:IsFirstVisit()
|
|
40
|
+
local roomFrameCount = room:GetFrameCount()
|
|
41
|
+
if not isFirstVisit and roomFrameCount <= 0 then
|
|
42
|
+
return
|
|
43
|
+
end
|
|
44
|
+
local ____v_run_0, ____pickupCounter_1 = v.run, "pickupCounter"
|
|
45
|
+
____v_run_0[____pickupCounter_1] = ____v_run_0[____pickupCounter_1] + 1
|
|
46
|
+
v.room.pickupIndexes:set(ptrHash, v.run.pickupCounter)
|
|
47
|
+
v.run.currentRoomListIndex = getRoomListIndex(nil)
|
|
48
|
+
end
|
|
49
|
+
function postEntityRemovePickup(self, entity)
|
|
50
|
+
checkDespawningFromPlayerLeavingRoom(nil, entity)
|
|
51
|
+
end
|
|
52
|
+
function checkDespawningFromPlayerLeavingRoom(self, entity)
|
|
53
|
+
local ptrHash = GetPtrHash(entity)
|
|
54
|
+
local pickupIndex = v.room.pickupIndexes:get(ptrHash)
|
|
55
|
+
if pickupIndex == nil then
|
|
56
|
+
return
|
|
57
|
+
end
|
|
58
|
+
local roomListIndex = getRoomListIndex(nil)
|
|
59
|
+
if roomListIndex == v.run.currentRoomListIndex then
|
|
60
|
+
return
|
|
61
|
+
end
|
|
62
|
+
trackDespawningPickupMetadata(nil, entity, pickupIndex)
|
|
63
|
+
end
|
|
64
|
+
function trackDespawningPickupMetadata(self, entity, pickupIndex)
|
|
65
|
+
local previousRoomDescription = getLatestRoomDescription(nil)
|
|
66
|
+
local previousRoomListIndex = previousRoomDescription.roomListIndex
|
|
67
|
+
local pickupDescriptions = v.level.pickupData:getAndSetDefault(previousRoomListIndex)
|
|
68
|
+
local pickupDescription = {position = entity.Position, initSeed = entity.InitSeed}
|
|
69
|
+
pickupDescriptions:set(pickupIndex, pickupDescription)
|
|
70
|
+
if onAscent(nil) then
|
|
71
|
+
return
|
|
72
|
+
end
|
|
73
|
+
local room = game:GetRoom()
|
|
74
|
+
local roomType = room:GetType()
|
|
75
|
+
repeat
|
|
76
|
+
local ____switch13 = roomType
|
|
77
|
+
local ____cond13 = ____switch13 == RoomType.TREASURE
|
|
78
|
+
if ____cond13 then
|
|
79
|
+
do
|
|
80
|
+
v.run.pickupDataTreasureRooms:set(pickupIndex, pickupDescription)
|
|
81
|
+
break
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
____cond13 = ____cond13 or ____switch13 == RoomType.BOSS
|
|
85
|
+
if ____cond13 then
|
|
86
|
+
do
|
|
87
|
+
v.run.pickupDataBossRooms:set(pickupIndex, pickupDescription)
|
|
88
|
+
break
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
do
|
|
92
|
+
do
|
|
93
|
+
break
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
until true
|
|
97
|
+
end
|
|
98
|
+
function postNewRoomReordered(self)
|
|
99
|
+
local room = game:GetRoom()
|
|
100
|
+
local isFirstVisit = room:IsFirstVisit()
|
|
101
|
+
if isFirstVisit then
|
|
102
|
+
return
|
|
103
|
+
end
|
|
104
|
+
local roomListIndex = getRoomListIndex(nil)
|
|
105
|
+
local pickupDescriptions = v.level.pickupData:getAndSetDefault(roomListIndex)
|
|
106
|
+
for ____, pickup in ipairs(getPickups(nil)) do
|
|
107
|
+
local pickupIndex = getStoredPickupIndex(nil, pickup, pickupDescriptions)
|
|
108
|
+
if pickupIndex == nil then
|
|
109
|
+
pickupIndex = getPostAscentPickupIndex(nil, pickup)
|
|
110
|
+
end
|
|
111
|
+
if pickupIndex == nil then
|
|
112
|
+
local entityID = getEntityID(nil, pickup)
|
|
113
|
+
error("Failed to find a pickup index corresponding to existing pickup: " .. entityID)
|
|
114
|
+
end
|
|
115
|
+
local ptrHash = GetPtrHash(pickup)
|
|
116
|
+
v.room.pickupIndexes:set(ptrHash, pickupIndex)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
function getStoredPickupIndex(self, pickup, pickupDescriptions)
|
|
120
|
+
for ____, ____value in __TS__Iterator(pickupDescriptions:entries()) do
|
|
121
|
+
local pickupIndex = ____value[1]
|
|
122
|
+
local pickupDescription = ____value[2]
|
|
123
|
+
if vectorEquals(nil, pickupDescription.position, pickup.Position) and pickupDescription.initSeed == pickup.InitSeed then
|
|
124
|
+
return pickupIndex
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
return nil
|
|
128
|
+
end
|
|
129
|
+
function getPostAscentPickupIndex(self, pickup)
|
|
130
|
+
if not onAscent(nil) then
|
|
131
|
+
return nil
|
|
132
|
+
end
|
|
133
|
+
local room = game:GetRoom()
|
|
134
|
+
local roomType = room:GetType()
|
|
135
|
+
repeat
|
|
136
|
+
local ____switch29 = roomType
|
|
137
|
+
local ____cond29 = ____switch29 == RoomType.TREASURE
|
|
138
|
+
if ____cond29 then
|
|
139
|
+
do
|
|
140
|
+
return getStoredPickupIndex(nil, pickup, v.run.pickupDataTreasureRooms)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
____cond29 = ____cond29 or ____switch29 == RoomType.BOSS
|
|
144
|
+
if ____cond29 then
|
|
145
|
+
do
|
|
146
|
+
return getStoredPickupIndex(nil, pickup, v.run.pickupDataBossRooms)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
do
|
|
150
|
+
do
|
|
151
|
+
return nil
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
until true
|
|
155
|
+
end
|
|
156
|
+
local FEATURE_NAME = "pickupIndex"
|
|
157
|
+
v = {
|
|
158
|
+
run = {
|
|
159
|
+
pickupCounter = 0,
|
|
160
|
+
currentRoomListIndex = 0,
|
|
161
|
+
pickupDataTreasureRooms = __TS__New(Map),
|
|
162
|
+
pickupDataBossRooms = __TS__New(Map)
|
|
163
|
+
},
|
|
164
|
+
level = {pickupData = __TS__New(
|
|
165
|
+
DefaultMap,
|
|
166
|
+
function() return __TS__New(Map) end
|
|
167
|
+
)},
|
|
168
|
+
room = {pickupIndexes = __TS__New(Map)}
|
|
169
|
+
}
|
|
170
|
+
function ____exports.pickupIndexInit(self, mod)
|
|
171
|
+
saveDataManager(nil, FEATURE_NAME, v)
|
|
172
|
+
mod:AddCallback(ModCallback.POST_PICKUP_INIT, postPickupInit)
|
|
173
|
+
mod:AddCallback(ModCallback.POST_ENTITY_REMOVE, postEntityRemovePickup, EntityType.PICKUP)
|
|
174
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
|
|
175
|
+
end
|
|
176
|
+
--- Mods often have to track variables relating to a pickups. Finding an index for these kinds of
|
|
177
|
+
-- data structures is difficult, since pickups are respawned every time a player re-enters a room,
|
|
178
|
+
-- so the `PtrHash` will change.
|
|
179
|
+
--
|
|
180
|
+
-- Use this function to get a unique index for a pickup to use in these data structures.
|
|
181
|
+
--
|
|
182
|
+
-- Specifically, `PickupIndex` is a number that represents the spawn order of the pickup on the
|
|
183
|
+
-- current run. For example, the first pickup spawned will have an index of 1, the second one will
|
|
184
|
+
-- have an index of 2, and so on.
|
|
185
|
+
--
|
|
186
|
+
-- Tracking pickups requires stateful tracking, so using pickup indexes requires an upgraded mod.
|
|
187
|
+
function ____exports.getPickupIndex(self, pickup)
|
|
188
|
+
errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
|
|
189
|
+
local ptrHash = GetPtrHash(pickup)
|
|
190
|
+
local pickupIndex = v.room.pickupIndexes:get(ptrHash)
|
|
191
|
+
if pickupIndex == nil then
|
|
192
|
+
local entityID = getEntityID(nil, pickup)
|
|
193
|
+
error((("Failed to get a pickup index for entity " .. entityID) .. " with hash: ") .. tostring(ptrHash))
|
|
194
|
+
end
|
|
195
|
+
return pickupIndex
|
|
196
|
+
end
|
|
197
|
+
return ____exports
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RoomDescription } from "../interfaces/RoomDescription";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to get information about all of the rooms that a player has visited thus far on
|
|
4
|
+
* this run.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getRoomHistory(): readonly RoomDescription[];
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get information about the room that was previously visited.
|
|
9
|
+
*
|
|
10
|
+
* In the special case of only one room having been visited thus far (i.e. the starting room of the
|
|
11
|
+
* run), the starting room will be returned.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPreviousRoomDescription(): RoomDescription;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to get information about the most recent room that is stored in the room history
|
|
16
|
+
* array.
|
|
17
|
+
*
|
|
18
|
+
* This is useful in the `POST_ENTITY_REMOVE` callback, since if an entity is despawning due to a
|
|
19
|
+
* player having left the room, the current room will have changed already, but the `POST_NEW_ROOM`
|
|
20
|
+
* callback will not have fired yet, and there will not be an entry in the room history array for
|
|
21
|
+
* the current room.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getLatestRoomDescription(): RoomDescription;
|
|
24
|
+
//# sourceMappingURL=roomHistory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roomHistory.d.ts","sourceRoot":"","sources":["../../src/features/roomHistory.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiDhE;;;GAGG;AACH,wBAAgB,cAAc,IAAI,SAAS,eAAe,EAAE,CAG3D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,IAAI,eAAe,CAe5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,eAAe,CAS1D"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local postNewRoomEarly, v
|
|
3
|
+
local ____cachedClasses = require("cachedClasses")
|
|
4
|
+
local game = ____cachedClasses.game
|
|
5
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
6
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
7
|
+
local ____featuresInitialized = require("featuresInitialized")
|
|
8
|
+
local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
|
|
9
|
+
local ____array = require("functions.array")
|
|
10
|
+
local getLastElement = ____array.getLastElement
|
|
11
|
+
local ____roomData = require("functions.roomData")
|
|
12
|
+
local getRoomGridIndex = ____roomData.getRoomGridIndex
|
|
13
|
+
local getRoomListIndex = ____roomData.getRoomListIndex
|
|
14
|
+
local getRoomName = ____roomData.getRoomName
|
|
15
|
+
local getRoomStageID = ____roomData.getRoomStageID
|
|
16
|
+
local getRoomSubType = ____roomData.getRoomSubType
|
|
17
|
+
local getRoomVariant = ____roomData.getRoomVariant
|
|
18
|
+
local ____exports = require("features.saveDataManager.exports")
|
|
19
|
+
local saveDataManager = ____exports.saveDataManager
|
|
20
|
+
function postNewRoomEarly(self)
|
|
21
|
+
local level = game:GetLevel()
|
|
22
|
+
local stage = level:GetStage()
|
|
23
|
+
local stageType = level:GetStageType()
|
|
24
|
+
local room = game:GetRoom()
|
|
25
|
+
local roomType = room:GetType()
|
|
26
|
+
local stageID = getRoomStageID(nil)
|
|
27
|
+
local roomVariant = getRoomVariant(nil)
|
|
28
|
+
local roomSubType = getRoomSubType(nil)
|
|
29
|
+
local roomName = getRoomName(nil)
|
|
30
|
+
local roomGridIndex = getRoomGridIndex(nil)
|
|
31
|
+
local roomListIndex = getRoomListIndex(nil)
|
|
32
|
+
local roomDescription = {
|
|
33
|
+
stage = stage,
|
|
34
|
+
stageType = stageType,
|
|
35
|
+
stageID = stageID,
|
|
36
|
+
roomType = roomType,
|
|
37
|
+
roomVariant = roomVariant,
|
|
38
|
+
roomSubType = roomSubType,
|
|
39
|
+
roomName = roomName,
|
|
40
|
+
roomGridIndex = roomGridIndex,
|
|
41
|
+
roomListIndex = roomListIndex
|
|
42
|
+
}
|
|
43
|
+
local ____v_run_roomHistory_0 = v.run.roomHistory
|
|
44
|
+
____v_run_roomHistory_0[#____v_run_roomHistory_0 + 1] = roomDescription
|
|
45
|
+
end
|
|
46
|
+
local FEATURE_NAME = "roomHistory"
|
|
47
|
+
v = {run = {roomHistory = {}}}
|
|
48
|
+
---
|
|
49
|
+
-- @internal
|
|
50
|
+
function ____exports.roomHistoryInit(self, mod)
|
|
51
|
+
saveDataManager(nil, FEATURE_NAME, v)
|
|
52
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_EARLY, postNewRoomEarly)
|
|
53
|
+
end
|
|
54
|
+
--- Helper function to get information about all of the rooms that a player has visited thus far on
|
|
55
|
+
-- this run.
|
|
56
|
+
function ____exports.getRoomHistory(self)
|
|
57
|
+
errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
|
|
58
|
+
return v.run.roomHistory
|
|
59
|
+
end
|
|
60
|
+
--- Helper function to get information about the room that was previously visited.
|
|
61
|
+
--
|
|
62
|
+
-- In the special case of only one room having been visited thus far (i.e. the starting room of the
|
|
63
|
+
-- run), the starting room will be returned.
|
|
64
|
+
function ____exports.getPreviousRoomDescription(self)
|
|
65
|
+
local previousRoomDescription = v.run.roomHistory[#v.run.roomHistory - 2 + 1]
|
|
66
|
+
if previousRoomDescription ~= nil then
|
|
67
|
+
return previousRoomDescription
|
|
68
|
+
end
|
|
69
|
+
local startingRoomDescription = v.run.roomHistory[1]
|
|
70
|
+
if startingRoomDescription ~= nil then
|
|
71
|
+
return startingRoomDescription
|
|
72
|
+
end
|
|
73
|
+
error("Failed to find a room description for any rooms thus far on this run.")
|
|
74
|
+
end
|
|
75
|
+
--- Helper function to get information about the most recent room that is stored in the room history
|
|
76
|
+
-- array.
|
|
77
|
+
--
|
|
78
|
+
-- This is useful in the `POST_ENTITY_REMOVE` callback, since if an entity is despawning due to a
|
|
79
|
+
-- player having left the room, the current room will have changed already, but the `POST_NEW_ROOM`
|
|
80
|
+
-- callback will not have fired yet, and there will not be an entry in the room history array for
|
|
81
|
+
-- the current room.
|
|
82
|
+
function ____exports.getLatestRoomDescription(self)
|
|
83
|
+
local latestRoomDescription = getLastElement(nil, v.run.roomHistory)
|
|
84
|
+
if latestRoomDescription == nil then
|
|
85
|
+
error("Failed to get the latest room description since the room history array was empty.")
|
|
86
|
+
end
|
|
87
|
+
return latestRoomDescription
|
|
88
|
+
end
|
|
89
|
+
return ____exports
|
|
@@ -24,38 +24,51 @@ export declare function getCollectibleDevilHeartPrice(collectibleType: Collectib
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function getCollectibleGfxFilename(collectibleType: CollectibleType): string;
|
|
26
26
|
/**
|
|
27
|
-
* Mods
|
|
28
|
-
* data structures is difficult, since collectibles are respawned every time a player re-enters a
|
|
29
|
-
* room, so the `PtrHash` will change.
|
|
30
|
-
*
|
|
27
|
+
* Mods may have to keep track of data relating to a collectible. Finding an index for these kinds
|
|
28
|
+
* of data structures is difficult, since collectibles are respawned every time a player re-enters a
|
|
29
|
+
* room (like all other pickups), so the `PtrHash` will change.
|
|
30
|
+
*
|
|
31
|
+
* Use this function to get a unique index for a collectible to use in these data structures.
|
|
32
|
+
*
|
|
33
|
+
* If your mod is upgraded, then you should use the `getPickupIndex` function instead, as it is more
|
|
34
|
+
* general purpose and less prone to error (but relies on stateful tracking of pickups as the run
|
|
35
|
+
* progresses).
|
|
36
|
+
*
|
|
37
|
+
* Collectibles are a special case of pickups: they cannot be pushed around. (They actually can be
|
|
38
|
+
* pushed, but usually will stay on the same grid index.) Thus, it is possible to generate a
|
|
39
|
+
* somewhat reliable non-stateful index for collectibles. We use a 4-tuple of the room list index,
|
|
40
|
+
* the grid index of the collectible in the room, the collectible's `SubType`, and the collectible's
|
|
41
|
+
* `InitSeed`.
|
|
31
42
|
*
|
|
32
43
|
* Collectibles that are shifted by Tainted Isaac's mechanic will have unique collectible indexes
|
|
33
|
-
* because the SubType is different. (The collectible entities share the same InitSeed
|
|
44
|
+
* because the `SubType` is different. (The collectible entities share the same `InitSeed` and
|
|
45
|
+
* `PtrHash`.)
|
|
34
46
|
*
|
|
35
47
|
* Collectibles that are rolled (with e.g. a D6) will have unique collectible indexes because the
|
|
36
|
-
* SubType and InitSeed are different. If you want to track collectibles independently of any
|
|
48
|
+
* `SubType` and `InitSeed` are different. If you want to track collectibles independently of any
|
|
37
49
|
* rerolls, then you can use the `PtrHash` as an index instead. (The `PtrHash` will not persist
|
|
38
50
|
* between rooms, however.)
|
|
39
51
|
*
|
|
40
52
|
* Note that:
|
|
41
53
|
* - The grid index is a necessary part of the collectible index because Diplopia and Crooked Penny
|
|
42
|
-
* can cause two or more collectibles with the same SubType and InitSeed to exist in the same
|
|
54
|
+
* can cause two or more collectibles with the same `SubType` and `InitSeed` to exist in the same
|
|
43
55
|
* room.
|
|
44
56
|
* - This index will fail in the case where the player uses Diplopia or a successful Crooked Penny
|
|
45
57
|
* seven or more times in the same room, since that will cause two or more collectibles with the
|
|
46
|
-
* same grid index, SubType
|
|
47
|
-
*
|
|
48
|
-
*
|
|
58
|
+
* same grid index, `SubType`, and `InitSeed` to exist. (More than seven is required in non-1x1
|
|
59
|
+
* rooms.)
|
|
60
|
+
* - The `SubType` is a necessary part of the collectible index because Tainted Isaac will
|
|
61
|
+
* continuously cause collectibles to morph into new sub-types with the same `InitSeed`.
|
|
49
62
|
* - Using a collectible's position as part of the index is problematic, since players can push a
|
|
50
63
|
* pedestal. (Even using the grid index does not solve this problem, since it is possible in
|
|
51
64
|
* certain cases for collectibles to be spawned at a position that is not aligned with the grid,
|
|
52
65
|
* and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
|
|
53
66
|
* - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
|
|
54
|
-
* different
|
|
67
|
+
* a different `InitSeed`, so this is not a problem for this indexing scheme.
|
|
55
68
|
* - The indexing scheme used is different for collectibles that are inside of a Treasure Room or
|
|
56
69
|
* Boss Room, in order to handle the case of the player seeing the same collectible again in a
|
|
57
|
-
* post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, SubType
|
|
58
|
-
* and InitSeed is used in this case. (Using the room list index or the room grid index is not
|
|
70
|
+
* post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, `SubType`,
|
|
71
|
+
* and `InitSeed` is used in this case. (Using the room list index or the room grid index is not
|
|
59
72
|
* suitable for this purpose, since both of these values can change in the post-Ascent rooms.)
|
|
60
73
|
* Even though Treasure Rooms and Boss Rooms are grouped together in this scheme, there probably
|
|
61
74
|
* will not be collectibles with the same grid index, SubType, and InitSeed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEf,aAAa,EAEb,QAAQ,EACR,WAAW,EAGZ,MAAM,8BAA8B,CAAC;AAkBtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAyB7D,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAEtE;AAED,6FAA6F;AAC7F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAsBT;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,eAAe,GAC/B,GAAG,CAYL;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,YAAY,GACnB,WAAW,CAyBb;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAOR;AAED
|
|
1
|
+
{"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEf,aAAa,EAEb,QAAQ,EACR,WAAW,EAGZ,MAAM,8BAA8B,CAAC;AAkBtC,OAAO,EAAE,gBAAgB,EAAE,MAAM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qBAAqB,CACnC,WAAW,EAAE,YAAY,EACzB,kBAAkB,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
|
|
@@ -182,38 +182,51 @@ function ____exports.getCollectibleGfxFilename(self, collectibleType)
|
|
|
182
182
|
end
|
|
183
183
|
return itemConfigItem.GfxFileName
|
|
184
184
|
end
|
|
185
|
-
--- Mods
|
|
186
|
-
-- data structures is difficult, since collectibles are respawned every time a player re-enters a
|
|
187
|
-
-- room, so the `PtrHash` will change.
|
|
188
|
-
--
|
|
185
|
+
--- Mods may have to keep track of data relating to a collectible. Finding an index for these kinds
|
|
186
|
+
-- of data structures is difficult, since collectibles are respawned every time a player re-enters a
|
|
187
|
+
-- room (like all other pickups), so the `PtrHash` will change.
|
|
188
|
+
--
|
|
189
|
+
-- Use this function to get a unique index for a collectible to use in these data structures.
|
|
190
|
+
--
|
|
191
|
+
-- If your mod is upgraded, then you should use the `getPickupIndex` function instead, as it is more
|
|
192
|
+
-- general purpose and less prone to error (but relies on stateful tracking of pickups as the run
|
|
193
|
+
-- progresses).
|
|
194
|
+
--
|
|
195
|
+
-- Collectibles are a special case of pickups: they cannot be pushed around. (They actually can be
|
|
196
|
+
-- pushed, but usually will stay on the same grid index.) Thus, it is possible to generate a
|
|
197
|
+
-- somewhat reliable non-stateful index for collectibles. We use a 4-tuple of the room list index,
|
|
198
|
+
-- the grid index of the collectible in the room, the collectible's `SubType`, and the collectible's
|
|
199
|
+
-- `InitSeed`.
|
|
189
200
|
--
|
|
190
201
|
-- Collectibles that are shifted by Tainted Isaac's mechanic will have unique collectible indexes
|
|
191
|
-
-- because the SubType is different. (The collectible entities share the same InitSeed
|
|
202
|
+
-- because the `SubType` is different. (The collectible entities share the same `InitSeed` and
|
|
203
|
+
-- `PtrHash`.)
|
|
192
204
|
--
|
|
193
205
|
-- Collectibles that are rolled (with e.g. a D6) will have unique collectible indexes because the
|
|
194
|
-
-- SubType and InitSeed are different. If you want to track collectibles independently of any
|
|
206
|
+
-- `SubType` and `InitSeed` are different. If you want to track collectibles independently of any
|
|
195
207
|
-- rerolls, then you can use the `PtrHash` as an index instead. (The `PtrHash` will not persist
|
|
196
208
|
-- between rooms, however.)
|
|
197
209
|
--
|
|
198
210
|
-- Note that:
|
|
199
211
|
-- - The grid index is a necessary part of the collectible index because Diplopia and Crooked Penny
|
|
200
|
-
-- can cause two or more collectibles with the same SubType and InitSeed to exist in the same
|
|
212
|
+
-- can cause two or more collectibles with the same `SubType` and `InitSeed` to exist in the same
|
|
201
213
|
-- room.
|
|
202
214
|
-- - This index will fail in the case where the player uses Diplopia or a successful Crooked Penny
|
|
203
215
|
-- seven or more times in the same room, since that will cause two or more collectibles with the
|
|
204
|
-
-- same grid index, SubType
|
|
205
|
-
--
|
|
206
|
-
--
|
|
216
|
+
-- same grid index, `SubType`, and `InitSeed` to exist. (More than seven is required in non-1x1
|
|
217
|
+
-- rooms.)
|
|
218
|
+
-- - The `SubType` is a necessary part of the collectible index because Tainted Isaac will
|
|
219
|
+
-- continuously cause collectibles to morph into new sub-types with the same `InitSeed`.
|
|
207
220
|
-- - Using a collectible's position as part of the index is problematic, since players can push a
|
|
208
221
|
-- pedestal. (Even using the grid index does not solve this problem, since it is possible in
|
|
209
222
|
-- certain cases for collectibles to be spawned at a position that is not aligned with the grid,
|
|
210
223
|
-- and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
|
|
211
224
|
-- - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
|
|
212
|
-
-- different
|
|
225
|
+
-- a different `InitSeed`, so this is not a problem for this indexing scheme.
|
|
213
226
|
-- - The indexing scheme used is different for collectibles that are inside of a Treasure Room or
|
|
214
227
|
-- Boss Room, in order to handle the case of the player seeing the same collectible again in a
|
|
215
|
-
-- post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, SubType
|
|
216
|
-
-- and InitSeed is used in this case. (Using the room list index or the room grid index is not
|
|
228
|
+
-- post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, `SubType`,
|
|
229
|
+
-- and `InitSeed` is used in this case. (Using the room list index or the room grid index is not
|
|
217
230
|
-- suitable for this purpose, since both of these values can change in the post-Ascent rooms.)
|
|
218
231
|
-- Even though Treasure Rooms and Boss Rooms are grouped together in this scheme, there probably
|
|
219
232
|
-- will not be collectibles with the same grid index, SubType, and InitSeed.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
2
|
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
5
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
6
|
declare type SerializedColor = LuaMap<string, unknown> & {
|
|
5
7
|
readonly __serializedColorBrand: symbol;
|
|
@@ -19,6 +21,14 @@ export declare function colorEquals(color1: Color, color2: Color): boolean;
|
|
|
19
21
|
*/
|
|
20
22
|
export declare function copyColor<C extends Color | SerializedColor, S extends SerializationType>(color: C, serializationType: S): CopyColorReturn[S];
|
|
21
23
|
export declare function copyColor<C extends Color | SerializedColor>(color: C): CopyColorReturn[SerializationType.NONE];
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to get a random color.
|
|
26
|
+
*
|
|
27
|
+
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
28
|
+
* `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
29
|
+
* @param alpha Optional. The alpha value to use. Default is 1.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getRandomColor(seedOrRNG?: Seed | RNG, alpha?: number): Color;
|
|
22
32
|
/** Helper function to check if something is an instantiated Color object. */
|
|
23
33
|
export declare function isColor(object: unknown): object is Color;
|
|
24
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/functions/color.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/functions/color.ts"],"names":[],"mappings":";;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAO/D,aAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC/C,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF,UAAU,eAAe;IACvB,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAChC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC/C,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;CACxC;AAKD,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,CAAC,SAAS,KAAK,GAAG,eAAe,EACjC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACtD,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,eAAe,EACzD,KAAK,EAAE,CAAC,GACP,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAuE3C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,KAAK,SAAI,GACR,KAAK,CAQP;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,KAAK,CAExD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E"}
|
package/dist/functions/color.lua
CHANGED
|
@@ -7,6 +7,12 @@ local SerializationType = ____SerializationType.SerializationType
|
|
|
7
7
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
8
8
|
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
9
9
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
10
|
+
local ____random = require("functions.random")
|
|
11
|
+
local getRandom = ____random.getRandom
|
|
12
|
+
local ____rng = require("functions.rng")
|
|
13
|
+
local getRandomSeed = ____rng.getRandomSeed
|
|
14
|
+
local isRNG = ____rng.isRNG
|
|
15
|
+
local newRNG = ____rng.newRNG
|
|
10
16
|
local ____table = require("functions.table")
|
|
11
17
|
local copyValuesToTable = ____table.copyValuesToTable
|
|
12
18
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
@@ -104,6 +110,24 @@ function ____exports.copyColor(self, color, serializationType)
|
|
|
104
110
|
end
|
|
105
111
|
until true
|
|
106
112
|
end
|
|
113
|
+
--- Helper function to get a random color.
|
|
114
|
+
--
|
|
115
|
+
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
116
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
117
|
+
-- @param alpha Optional. The alpha value to use. Default is 1.
|
|
118
|
+
function ____exports.getRandomColor(self, seedOrRNG, alpha)
|
|
119
|
+
if seedOrRNG == nil then
|
|
120
|
+
seedOrRNG = getRandomSeed(nil)
|
|
121
|
+
end
|
|
122
|
+
if alpha == nil then
|
|
123
|
+
alpha = 1
|
|
124
|
+
end
|
|
125
|
+
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
126
|
+
local r = getRandom(nil, rng)
|
|
127
|
+
local g = getRandom(nil, rng)
|
|
128
|
+
local b = getRandom(nil, rng)
|
|
129
|
+
return Color(r, g, b, alpha)
|
|
130
|
+
end
|
|
107
131
|
--- Used to determine is the given table is a serialized `Color` object created by the save data
|
|
108
132
|
-- manager and/or the `deepCopy` function.
|
|
109
133
|
function ____exports.isSerializedColor(self, object)
|
|
@@ -65,10 +65,10 @@ export declare function getClosestEntityTo<T extends AnyEntity>(referenceEntity:
|
|
|
65
65
|
export declare function getEntities(entityType?: EntityType, variant?: number, subType?: number, ignoreFriendly?: boolean): Entity[];
|
|
66
66
|
/**
|
|
67
67
|
* Helper function to get all the fields on an entity. For example, this is useful for comparing it
|
|
68
|
-
* to another entity later.
|
|
68
|
+
* to another entity later. (One option is to use the `logTableDifferences` function for this.)
|
|
69
69
|
*
|
|
70
|
-
* This function will only get fields that are equal to booleans, numbers, or strings,
|
|
71
|
-
* other types is non-trivial.
|
|
70
|
+
* This function will only get fields that are equal to booleans, numbers, or strings, or Vectors,
|
|
71
|
+
* as comparing other types is non-trivial.
|
|
72
72
|
*/
|
|
73
73
|
export declare function getEntityFields(entity: Entity): LuaMap<string, boolean | number | string>;
|
|
74
74
|
/** Helper function to return a string containing the entity's type, variant, and sub-type. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/functions/entities.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/functions/entities.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAO/C;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,UAAU,GAAE,UAAe,EAC3B,OAAO,SAAK,EACZ,OAAO,SAAK,EACZ,cAAc,UAAQ,GACrB,GAAG,CAcL;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,UAAU,GAAE,UAAe,EAC3B,OAAO,SAAK,EACZ,OAAO,SAAK,EACZ,cAAc,UAAQ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