isaacscript-common 3.2.0 → 3.3.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/callbacks/customRevive.lua +3 -3
- package/callbacks/postGridEntity.lua +5 -3
- package/callbacks/postRoomClearChanged.lua +5 -3
- package/callbacks/postSlotInitUpdate.lua +5 -3
- package/features/deployJSONRoom.lua +5 -4
- package/features/extraConsoleCommands/listCommands.lua +1 -0
- package/features/persistentEntities.d.ts +28 -0
- package/features/persistentEntities.lua +150 -0
- package/functions/color.d.ts +2 -16
- package/functions/color.lua +0 -9
- package/functions/entity.d.ts +10 -0
- package/functions/entity.lua +29 -0
- package/functions/log.lua +2 -2
- package/index.d.ts +1 -0
- package/index.lua +7 -0
- package/initFeatures.lua +3 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
-
local hasSubscriptions, postRender,
|
|
2
|
+
local hasSubscriptions, postRender, postNewRoomReordered, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, logStateChanged, DEBUG, CustomReviveState, v
|
|
3
3
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
4
4
|
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
|
|
5
5
|
local FamiliarVariant = ____isaac_2Dtypescript_2Ddefinitions.FamiliarVariant
|
|
@@ -41,7 +41,7 @@ function postRender(self)
|
|
|
41
41
|
end
|
|
42
42
|
sfxManager:Stop(SoundEffect.ONE_UP)
|
|
43
43
|
end
|
|
44
|
-
function
|
|
44
|
+
function postNewRoomReordered(self)
|
|
45
45
|
if v.run.state ~= CustomReviveState.WAITING_FOR_ROOM_TRANSITION then
|
|
46
46
|
return
|
|
47
47
|
end
|
|
@@ -139,7 +139,7 @@ v = {run = {state = CustomReviveState.DISABLED, revivalType = nil, dyingPlayerIn
|
|
|
139
139
|
function ____exports.customReviveCallbacksInit(self, mod)
|
|
140
140
|
saveDataManager(nil, "customRevive", v, hasSubscriptions)
|
|
141
141
|
mod:AddCallback(ModCallback.POST_RENDER, postRender)
|
|
142
|
-
mod:
|
|
142
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
|
|
143
143
|
mod:AddCallbackCustom(ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
|
|
144
144
|
mod:AddCallbackCustom(ModCallbackCustom.POST_PLAYER_FATAL_DAMAGE, postPlayerFatalDamage)
|
|
145
145
|
mod:AddCallbackCustom(ModCallbackCustom.PRE_BERSERK_DEATH, preBerserkDeath)
|
|
@@ -3,9 +3,11 @@ local Map = ____lualib.Map
|
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
5
|
local ____exports = {}
|
|
6
|
-
local hasSubscriptions, postUpdate, checkGridEntitiesRemoved, checkGridEntityStateChanged, checkNewGridEntity, updateTupleInMap,
|
|
6
|
+
local hasSubscriptions, postUpdate, checkGridEntitiesRemoved, checkGridEntityStateChanged, checkNewGridEntity, updateTupleInMap, postNewRoomReordered, v
|
|
7
7
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
8
8
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
9
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
10
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
9
11
|
local ____exports = require("features.saveDataManager.exports")
|
|
10
12
|
local saveDataManager = ____exports.saveDataManager
|
|
11
13
|
local ____gridEntity = require("functions.gridEntity")
|
|
@@ -85,7 +87,7 @@ function updateTupleInMap(self, gridEntity)
|
|
|
85
87
|
local newTuple = {gridEntityType, gridEntityVariant, gridEntity.State}
|
|
86
88
|
v.room.initializedGridEntities:set(gridIndex, newTuple)
|
|
87
89
|
end
|
|
88
|
-
function
|
|
90
|
+
function postNewRoomReordered(self)
|
|
89
91
|
if not hasSubscriptions(nil) then
|
|
90
92
|
return
|
|
91
93
|
end
|
|
@@ -102,6 +104,6 @@ v = {room = {initializedGridEntities = __TS__New(Map)}}
|
|
|
102
104
|
function ____exports.postGridEntityCallbacksInit(self, mod)
|
|
103
105
|
saveDataManager(nil, "postGridEntity", v, hasSubscriptions)
|
|
104
106
|
mod:AddCallback(ModCallback.POST_UPDATE, postUpdate)
|
|
105
|
-
mod:
|
|
107
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
|
|
106
108
|
end
|
|
107
109
|
return ____exports
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
-
local hasSubscriptions, postUpdate,
|
|
2
|
+
local hasSubscriptions, postUpdate, postNewRoomReordered, v
|
|
3
3
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
4
4
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
5
5
|
local ____cachedClasses = require("cachedClasses")
|
|
6
6
|
local game = ____cachedClasses.game
|
|
7
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
8
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
7
9
|
local ____exports = require("features.saveDataManager.exports")
|
|
8
10
|
local saveDataManager = ____exports.saveDataManager
|
|
9
11
|
local ____postRoomClearChanged = require("callbacks.subscriptions.postRoomClearChanged")
|
|
@@ -23,7 +25,7 @@ function postUpdate(self)
|
|
|
23
25
|
postRoomClearChangedFire(nil, roomClear)
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
|
-
function
|
|
28
|
+
function postNewRoomReordered(self)
|
|
27
29
|
if not hasSubscriptions(nil) then
|
|
28
30
|
return
|
|
29
31
|
end
|
|
@@ -37,6 +39,6 @@ v = {room = {cleared = false}}
|
|
|
37
39
|
function ____exports.postRoomClearChangedCallbackInit(self, mod)
|
|
38
40
|
saveDataManager(nil, "postRoomClearChanged", v, hasSubscriptions)
|
|
39
41
|
mod:AddCallback(ModCallback.POST_UPDATE, postUpdate)
|
|
40
|
-
mod:
|
|
42
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
|
|
41
43
|
end
|
|
42
44
|
return ____exports
|
|
@@ -2,9 +2,11 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local ____exports = {}
|
|
5
|
-
local hasSubscriptions, postUpdate,
|
|
5
|
+
local hasSubscriptions, postUpdate, postNewRoomReordered, checkNewEntity, v
|
|
6
6
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
7
7
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
8
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
9
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
8
10
|
local ____exports = require("features.saveDataManager.exports")
|
|
9
11
|
local saveDataManager = ____exports.saveDataManager
|
|
10
12
|
local ____entitySpecific = require("functions.entitySpecific")
|
|
@@ -27,7 +29,7 @@ function postUpdate(self)
|
|
|
27
29
|
postSlotUpdateFire(nil, slot)
|
|
28
30
|
end
|
|
29
31
|
end
|
|
30
|
-
function
|
|
32
|
+
function postNewRoomReordered(self)
|
|
31
33
|
if not hasSubscriptions(nil) then
|
|
32
34
|
return
|
|
33
35
|
end
|
|
@@ -48,6 +50,6 @@ v = {room = {initializedSlots = __TS__New(Set)}}
|
|
|
48
50
|
function ____exports.postSlotInitUpdateCallbacksInit(self, mod)
|
|
49
51
|
saveDataManager(nil, "postSlotInitUpdate", v, hasSubscriptions)
|
|
50
52
|
mod:AddCallback(ModCallback.POST_UPDATE, postUpdate)
|
|
51
|
-
mod:
|
|
53
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
|
|
52
54
|
end
|
|
53
55
|
return ____exports
|
|
@@ -4,7 +4,7 @@ local __TS__New = ____lualib.__TS__New
|
|
|
4
4
|
local Map = ____lualib.Map
|
|
5
5
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
6
6
|
local ____exports = {}
|
|
7
|
-
local
|
|
7
|
+
local postNewRoomReordered, setDecorationsInvisible, respawnPersistentEntities, removeSpecificNPCs, fillRoomWithDecorations, spawnAllEntities, spawnGridEntityForJSONRoom, spawnNormalEntityForJSONRoom, storePersistentEntity, fixPitGraphics, getPitMap, getPitFrame, FEATURE_NAME, NPC_TYPES_TO_NOT_REMOVE, PERSISTENT_ENTITY_TYPES, v
|
|
8
8
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
9
9
|
local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
|
|
10
10
|
local EntityCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityCollisionClass
|
|
@@ -12,7 +12,6 @@ local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
|
|
|
12
12
|
local EntityGridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityGridCollisionClass
|
|
13
13
|
local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
|
|
14
14
|
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
|
|
15
|
-
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
16
15
|
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
|
|
17
16
|
local PitfallVariant = ____isaac_2Dtypescript_2Ddefinitions.PitfallVariant
|
|
18
17
|
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
|
|
@@ -20,6 +19,8 @@ local ____cachedClasses = require("cachedClasses")
|
|
|
20
19
|
local game = ____cachedClasses.game
|
|
21
20
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
22
21
|
local DefaultMap = ____DefaultMap.DefaultMap
|
|
22
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
23
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
23
24
|
local ____featuresInitialized = require("featuresInitialized")
|
|
24
25
|
local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
|
|
25
26
|
local ____entity = require("functions.entity")
|
|
@@ -57,7 +58,7 @@ local ____utils = require("functions.utils")
|
|
|
57
58
|
local erange = ____utils.erange
|
|
58
59
|
local ____exports = require("features.saveDataManager.exports")
|
|
59
60
|
local saveDataManager = ____exports.saveDataManager
|
|
60
|
-
function
|
|
61
|
+
function postNewRoomReordered(self)
|
|
61
62
|
local roomListIndex = getRoomListIndex(nil)
|
|
62
63
|
if not v.level.deployedRoomListIndexes:has(roomListIndex) then
|
|
63
64
|
return
|
|
@@ -427,7 +428,7 @@ v = {level = {
|
|
|
427
428
|
-- @internal
|
|
428
429
|
function ____exports.deployJSONRoomInit(self, mod)
|
|
429
430
|
saveDataManager(nil, "deployJSONRoom", v)
|
|
430
|
-
mod:
|
|
431
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
|
|
431
432
|
end
|
|
432
433
|
--- Helper function to deconstruct a vanilla room and set up a custom room in its place.
|
|
433
434
|
-- Specifically, this will clear the current room of all entities and grid entities, and then spawn
|
|
@@ -810,6 +810,7 @@ end
|
|
|
810
810
|
--- Logs information about the room to the "log.txt" file.
|
|
811
811
|
function ____exports.roomCommand(self)
|
|
812
812
|
logRoom()
|
|
813
|
+
printConsole(nil, "Logged room information to the \"log.txt\" file.")
|
|
813
814
|
end
|
|
814
815
|
--- Gives a rotten heart. Provide a number to give a custom amount of hearts. (You can use negative
|
|
815
816
|
-- numbers to remove hearts.)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EntityType } from "isaac-typescript-definitions";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to spawn an entity that will have persistence similar to a pickup.
|
|
4
|
+
*
|
|
5
|
+
* By default, as soon as you leave a room, any spawned entities will be despawned and will not
|
|
6
|
+
* return if the player revisits the room. This means that if you want to have an entity like a
|
|
7
|
+
* pickup, you have to manually respawn it when the player re-enters the room. Use this helper
|
|
8
|
+
* function to avoid having to do any tracking on your own.
|
|
9
|
+
*
|
|
10
|
+
* Conventionally, the word "persistent" refers to `EntityFlag.FLAG_PERSISTENT`, which is used on
|
|
11
|
+
* e.g. familiars to make them appear in every room. On the other hand, pickups are also persistent,
|
|
12
|
+
* but they are not present in every room, only one specific room. This function spawns entities
|
|
13
|
+
* like pickups, not familiars.
|
|
14
|
+
*
|
|
15
|
+
* @returns A tuple containing the entity and the persistent entity index. You can use the index
|
|
16
|
+
* with the `removePersistentEntity` function.
|
|
17
|
+
*/
|
|
18
|
+
export declare function spawnPersistentEntity(entityType: EntityType, variant: int, subType: int, position: Vector): [Entity, int];
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to stop an entity spawned with the `spawnPersistentEntity` helper function from
|
|
21
|
+
* respawning.
|
|
22
|
+
*
|
|
23
|
+
* @param persistentEntityIndex The index that was returned by the `spawnPersistentEntity` function.
|
|
24
|
+
* @param removeEntity Optional. True by default. Set to false if you want to stop an entity from
|
|
25
|
+
* being persistent but you don't want to actually remove the currently-spawned
|
|
26
|
+
* entity from the room.
|
|
27
|
+
*/
|
|
28
|
+
export declare function removePersistentEntity(persistentEntityIndex: int, removeEntity?: boolean): void;
|
|
@@ -0,0 +1,150 @@
|
|
|
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 postEntityRemove, postNewRoomReordered, spawnAndTrack, v
|
|
7
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
8
|
+
local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
|
|
9
|
+
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
10
|
+
local ____cachedClasses = require("cachedClasses")
|
|
11
|
+
local game = ____cachedClasses.game
|
|
12
|
+
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
|
|
13
|
+
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
14
|
+
local ____entity = require("functions.entity")
|
|
15
|
+
local spawn = ____entity.spawn
|
|
16
|
+
local ____roomData = require("functions.roomData")
|
|
17
|
+
local getRoomListIndex = ____roomData.getRoomListIndex
|
|
18
|
+
local ____exports = require("features.saveDataManager.exports")
|
|
19
|
+
local saveDataManager = ____exports.saveDataManager
|
|
20
|
+
function postEntityRemove(self, entity)
|
|
21
|
+
local ptrHash = GetPtrHash(entity)
|
|
22
|
+
local tuple = v.room.spawnedPersistentEntities:get(ptrHash)
|
|
23
|
+
if tuple == nil then
|
|
24
|
+
return
|
|
25
|
+
end
|
|
26
|
+
local index = tuple[1]
|
|
27
|
+
local level = game:GetLevel()
|
|
28
|
+
local previousRoomGridIndex = level:GetPreviousRoomIndex()
|
|
29
|
+
local previousRoomListIndex = getRoomListIndex(nil, previousRoomGridIndex)
|
|
30
|
+
v.level.persistentEntities:set(index, {
|
|
31
|
+
entityType = entity.Type,
|
|
32
|
+
variant = entity.Variant,
|
|
33
|
+
subType = entity.SubType,
|
|
34
|
+
roomListIndex = previousRoomListIndex,
|
|
35
|
+
position = entity.Position
|
|
36
|
+
})
|
|
37
|
+
end
|
|
38
|
+
function postNewRoomReordered(self)
|
|
39
|
+
local roomListIndex = getRoomListIndex(nil)
|
|
40
|
+
for ____, ____value in __TS__Iterator(v.level.persistentEntities:entries()) do
|
|
41
|
+
local index = ____value[1]
|
|
42
|
+
local description = ____value[2]
|
|
43
|
+
do
|
|
44
|
+
if roomListIndex ~= description.roomListIndex then
|
|
45
|
+
goto __continue6
|
|
46
|
+
end
|
|
47
|
+
v.level.persistentEntities:delete(index)
|
|
48
|
+
spawnAndTrack(
|
|
49
|
+
nil,
|
|
50
|
+
description.entityType,
|
|
51
|
+
description.variant,
|
|
52
|
+
description.subType,
|
|
53
|
+
description.position,
|
|
54
|
+
index,
|
|
55
|
+
true
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
::__continue6::
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
function spawnAndTrack(self, entityType, variant, subType, position, index, respawning)
|
|
62
|
+
if respawning == nil then
|
|
63
|
+
respawning = false
|
|
64
|
+
end
|
|
65
|
+
local entity = spawn(
|
|
66
|
+
nil,
|
|
67
|
+
entityType,
|
|
68
|
+
variant,
|
|
69
|
+
subType,
|
|
70
|
+
position
|
|
71
|
+
)
|
|
72
|
+
if respawning then
|
|
73
|
+
entity:ClearEntityFlags(EntityFlag.APPEAR)
|
|
74
|
+
end
|
|
75
|
+
local ptrHash = GetPtrHash(entity)
|
|
76
|
+
local tuple = {
|
|
77
|
+
index,
|
|
78
|
+
EntityPtr(entity)
|
|
79
|
+
}
|
|
80
|
+
v.room.spawnedPersistentEntities:set(ptrHash, tuple)
|
|
81
|
+
return entity
|
|
82
|
+
end
|
|
83
|
+
--- Iterates upward as new persistent entities are created.
|
|
84
|
+
local persistentEntityIndexCounter = 0
|
|
85
|
+
v = {
|
|
86
|
+
level = {persistentEntities = __TS__New(Map)},
|
|
87
|
+
room = {spawnedPersistentEntities = __TS__New(Map)}
|
|
88
|
+
}
|
|
89
|
+
---
|
|
90
|
+
-- @internal
|
|
91
|
+
function ____exports.persistentEntitiesInit(self, mod)
|
|
92
|
+
saveDataManager(nil, "persistentEntities", v)
|
|
93
|
+
mod:AddCallback(ModCallback.POST_ENTITY_REMOVE, postEntityRemove)
|
|
94
|
+
mod:AddCallbackCustom(ModCallbackCustom.POST_NEW_ROOM_REORDERED, postNewRoomReordered)
|
|
95
|
+
end
|
|
96
|
+
--- Helper function to spawn an entity that will have persistence similar to a pickup.
|
|
97
|
+
--
|
|
98
|
+
-- By default, as soon as you leave a room, any spawned entities will be despawned and will not
|
|
99
|
+
-- return if the player revisits the room. This means that if you want to have an entity like a
|
|
100
|
+
-- pickup, you have to manually respawn it when the player re-enters the room. Use this helper
|
|
101
|
+
-- function to avoid having to do any tracking on your own.
|
|
102
|
+
--
|
|
103
|
+
-- Conventionally, the word "persistent" refers to `EntityFlag.FLAG_PERSISTENT`, which is used on
|
|
104
|
+
-- e.g. familiars to make them appear in every room. On the other hand, pickups are also persistent,
|
|
105
|
+
-- but they are not present in every room, only one specific room. This function spawns entities
|
|
106
|
+
-- like pickups, not familiars.
|
|
107
|
+
--
|
|
108
|
+
-- @returns A tuple containing the entity and the persistent entity index. You can use the index
|
|
109
|
+
-- with the `removePersistentEntity` function.
|
|
110
|
+
function ____exports.spawnPersistentEntity(self, entityType, variant, subType, position)
|
|
111
|
+
persistentEntityIndexCounter = persistentEntityIndexCounter + 1
|
|
112
|
+
local entity = spawnAndTrack(
|
|
113
|
+
nil,
|
|
114
|
+
entityType,
|
|
115
|
+
variant,
|
|
116
|
+
subType,
|
|
117
|
+
position,
|
|
118
|
+
persistentEntityIndexCounter
|
|
119
|
+
)
|
|
120
|
+
return {entity, persistentEntityIndexCounter}
|
|
121
|
+
end
|
|
122
|
+
--- Helper function to stop an entity spawned with the `spawnPersistentEntity` helper function from
|
|
123
|
+
-- respawning.
|
|
124
|
+
--
|
|
125
|
+
-- @param persistentEntityIndex The index that was returned by the `spawnPersistentEntity` function.
|
|
126
|
+
-- @param removeEntity Optional. True by default. Set to false if you want to stop an entity from
|
|
127
|
+
-- being persistent but you don't want to actually remove the currently-spawned
|
|
128
|
+
-- entity from the room.
|
|
129
|
+
function ____exports.removePersistentEntity(self, persistentEntityIndex, removeEntity)
|
|
130
|
+
if removeEntity == nil then
|
|
131
|
+
removeEntity = true
|
|
132
|
+
end
|
|
133
|
+
v.level.persistentEntities:delete(persistentEntityIndex)
|
|
134
|
+
for ____, ____value in __TS__Iterator(v.room.spawnedPersistentEntities:entries()) do
|
|
135
|
+
local ptrHash = ____value[1]
|
|
136
|
+
local tuple = ____value[2]
|
|
137
|
+
do
|
|
138
|
+
local index, entityPtr = table.unpack(tuple)
|
|
139
|
+
if index ~= persistentEntityIndex then
|
|
140
|
+
goto __continue13
|
|
141
|
+
end
|
|
142
|
+
v.room.spawnedPersistentEntities:delete(ptrHash)
|
|
143
|
+
if removeEntity and entityPtr.Ref ~= nil then
|
|
144
|
+
entityPtr.Ref:Remove()
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
::__continue13::
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
return ____exports
|
package/functions/color.d.ts
CHANGED
|
@@ -9,9 +9,6 @@ interface CopyColorReturn {
|
|
|
9
9
|
[SerializationType.SERIALIZE]: SerializedColor;
|
|
10
10
|
[SerializationType.DESERIALIZE]: Color;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* @category color
|
|
14
|
-
*/
|
|
15
12
|
export declare function colorEquals(color1: Color, color2: Color): boolean;
|
|
16
13
|
/**
|
|
17
14
|
* Helper function to copy a `Color` object.
|
|
@@ -19,27 +16,16 @@ export declare function colorEquals(color1: Color, color2: Color): boolean;
|
|
|
19
16
|
* @param color The Color object to copy. In the case of deserialization, this will actually be a
|
|
20
17
|
* Lua table instead of an instantiated Color class.
|
|
21
18
|
* @param serializationType Default is `SerializationType.NONE`.
|
|
22
|
-
* @category color
|
|
23
19
|
*/
|
|
24
20
|
export declare function copyColor<C extends Color | SerializedColor, S extends SerializationType>(color: C, serializationType: S): CopyColorReturn[S];
|
|
25
21
|
export declare function copyColor<C extends Color | SerializedColor>(color: C): CopyColorReturn[SerializationType.NONE];
|
|
26
|
-
/**
|
|
27
|
-
* Returns `Color(1, 1, 1)`.
|
|
28
|
-
*
|
|
29
|
-
* @category color
|
|
30
|
-
*/
|
|
22
|
+
/** Returns `Color(1, 1, 1)`. */
|
|
31
23
|
export declare function getDefaultColor(): Color;
|
|
32
|
-
/**
|
|
33
|
-
* Helper function to check if something is an instantiated Color object.
|
|
34
|
-
*
|
|
35
|
-
* @category color
|
|
36
|
-
*/
|
|
24
|
+
/** Helper function to check if something is an instantiated Color object. */
|
|
37
25
|
export declare function isColor(object: unknown): object is Color;
|
|
38
26
|
/**
|
|
39
27
|
* Used to determine is the given table is a serialized `Color` object created by the save data
|
|
40
28
|
* manager and/or the `deepCopy` function.
|
|
41
|
-
*
|
|
42
|
-
* @category color
|
|
43
29
|
*/
|
|
44
30
|
export declare function isSerializedColor(object: unknown): object is SerializedColor;
|
|
45
31
|
export {};
|
package/functions/color.lua
CHANGED
|
@@ -14,8 +14,6 @@ local tableHasKeys = ____table.tableHasKeys
|
|
|
14
14
|
local ____utils = require("functions.utils")
|
|
15
15
|
local ensureAllCases = ____utils.ensureAllCases
|
|
16
16
|
--- Helper function to check if something is an instantiated Color object.
|
|
17
|
-
--
|
|
18
|
-
-- @category color
|
|
19
17
|
function ____exports.isColor(self, object)
|
|
20
18
|
return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
|
|
21
19
|
end
|
|
@@ -29,8 +27,6 @@ local KEYS = {
|
|
|
29
27
|
"BO"
|
|
30
28
|
}
|
|
31
29
|
OBJECT_NAME = "Color"
|
|
32
|
-
---
|
|
33
|
-
-- @category color
|
|
34
30
|
function ____exports.colorEquals(self, color1, color2)
|
|
35
31
|
return isaacAPIClassEquals(nil, color1, color2, KEYS)
|
|
36
32
|
end
|
|
@@ -39,7 +35,6 @@ end
|
|
|
39
35
|
-- @param color The Color object to copy. In the case of deserialization, this will actually be a
|
|
40
36
|
-- Lua table instead of an instantiated Color class.
|
|
41
37
|
-- @param serializationType Default is `SerializationType.NONE`.
|
|
42
|
-
-- @category color
|
|
43
38
|
function ____exports.copyColor(self, color, serializationType)
|
|
44
39
|
if serializationType == nil then
|
|
45
40
|
serializationType = SerializationType.NONE
|
|
@@ -116,15 +111,11 @@ function ____exports.copyColor(self, color, serializationType)
|
|
|
116
111
|
until true
|
|
117
112
|
end
|
|
118
113
|
--- Returns `Color(1, 1, 1)`.
|
|
119
|
-
--
|
|
120
|
-
-- @category color
|
|
121
114
|
function ____exports.getDefaultColor(self)
|
|
122
115
|
return Color(1, 1, 1)
|
|
123
116
|
end
|
|
124
117
|
--- Used to determine is the given table is a serialized `Color` object created by the save data
|
|
125
118
|
-- manager and/or the `deepCopy` function.
|
|
126
|
-
--
|
|
127
|
-
-- @category color
|
|
128
119
|
function ____exports.isSerializedColor(self, object)
|
|
129
120
|
local objectType = type(object)
|
|
130
121
|
if objectType ~= "table" then
|
package/functions/entity.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ import { AnyEntity } from "../types/AnyEntity";
|
|
|
11
11
|
* @param ignoreFriendly Default is false.
|
|
12
12
|
*/
|
|
13
13
|
export declare function countEntities(entityType?: EntityType, variant?: number, subType?: number, ignoreFriendly?: boolean): int;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to check if one or more of a specific kind of entity is present in the current
|
|
16
|
+
* room. It uses the `countEntities` helper function to determine this.
|
|
17
|
+
*
|
|
18
|
+
* @param entityType Default is -1. -1 matches every entity type.
|
|
19
|
+
* @param variant Default is -1. -1 matches every variant.
|
|
20
|
+
* @param subType Default is -1. -1 matches every sub-type.
|
|
21
|
+
* @param ignoreFriendly Default is false.
|
|
22
|
+
*/
|
|
23
|
+
export declare function doesEntityExist(entityType?: EntityType, variant?: number, subType?: number, ignoreFriendly?: boolean): boolean;
|
|
14
24
|
/**
|
|
15
25
|
* Given an array of entities, this helper function returns the closest one to a provided reference
|
|
16
26
|
* entity.
|
package/functions/entity.lua
CHANGED
|
@@ -66,6 +66,35 @@ function ____exports.countEntities(self, entityType, variant, subType, ignoreFri
|
|
|
66
66
|
)
|
|
67
67
|
return #entities
|
|
68
68
|
end
|
|
69
|
+
--- Helper function to check if one or more of a specific kind of entity is present in the current
|
|
70
|
+
-- room. It uses the `countEntities` helper function to determine this.
|
|
71
|
+
--
|
|
72
|
+
-- @param entityType Default is -1. -1 matches every entity type.
|
|
73
|
+
-- @param variant Default is -1. -1 matches every variant.
|
|
74
|
+
-- @param subType Default is -1. -1 matches every sub-type.
|
|
75
|
+
-- @param ignoreFriendly Default is false.
|
|
76
|
+
function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreFriendly)
|
|
77
|
+
if entityType == nil then
|
|
78
|
+
entityType = -1
|
|
79
|
+
end
|
|
80
|
+
if variant == nil then
|
|
81
|
+
variant = -1
|
|
82
|
+
end
|
|
83
|
+
if subType == nil then
|
|
84
|
+
subType = -1
|
|
85
|
+
end
|
|
86
|
+
if ignoreFriendly == nil then
|
|
87
|
+
ignoreFriendly = false
|
|
88
|
+
end
|
|
89
|
+
local count = ____exports.countEntities(
|
|
90
|
+
nil,
|
|
91
|
+
entityType,
|
|
92
|
+
variant,
|
|
93
|
+
subType,
|
|
94
|
+
ignoreFriendly
|
|
95
|
+
)
|
|
96
|
+
return count > 0
|
|
97
|
+
end
|
|
69
98
|
--- Given an array of entities, this helper function returns the closest one to a provided reference
|
|
70
99
|
-- entity.
|
|
71
100
|
--
|
package/functions/log.lua
CHANGED
|
@@ -229,7 +229,7 @@ function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
|
|
|
229
229
|
if numMatchedEntities == 0 then
|
|
230
230
|
msg = msg .. "(no entities matched)\n"
|
|
231
231
|
else
|
|
232
|
-
msg = msg .. ("(" .. tostring(numMatchedEntities)) .. " total entities)\n"
|
|
232
|
+
msg = msg .. ((("(" .. tostring(numMatchedEntities)) .. " total ") .. (numMatchedEntities == 1 and "entity" or "entities")) .. ")\n"
|
|
233
233
|
end
|
|
234
234
|
____exports.log(msg)
|
|
235
235
|
end
|
|
@@ -336,7 +336,7 @@ function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
|
|
|
336
336
|
if numMatchedEntities == 0 then
|
|
337
337
|
msg = msg .. "(no grid entities matched)\n"
|
|
338
338
|
else
|
|
339
|
-
msg = msg .. ("(" .. tostring(numMatchedEntities)) .. " total grid entities)\n"
|
|
339
|
+
msg = msg .. ((("(" .. tostring(numMatchedEntities)) .. " total grid ") .. (numMatchedEntities == 1 and "entity" or "entities")) .. ")\n"
|
|
340
340
|
end
|
|
341
341
|
____exports.log(msg)
|
|
342
342
|
end
|
package/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { removeFadeIn, restoreFadeIn } from "./features/fadeInRemover";
|
|
|
20
20
|
export { disableFastReset, enableFastReset } from "./features/fastReset";
|
|
21
21
|
export { forgottenSwitch } from "./features/forgottenSwitch";
|
|
22
22
|
export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
|
|
23
|
+
export { removePersistentEntity, spawnPersistentEntity, } from "./features/persistentEntities";
|
|
23
24
|
export { addCollectible, getPlayerInventory } from "./features/playerInventory";
|
|
24
25
|
export * from "./features/ponyDetection";
|
|
25
26
|
export { preventCollectibleRotation } from "./features/preventCollectibleRotation";
|
package/index.lua
CHANGED
|
@@ -167,6 +167,13 @@ do
|
|
|
167
167
|
local getCollectibleItemPoolType = ____getCollectibleItemPoolType.getCollectibleItemPoolType
|
|
168
168
|
____exports.getCollectibleItemPoolType = getCollectibleItemPoolType
|
|
169
169
|
end
|
|
170
|
+
do
|
|
171
|
+
local ____persistentEntities = require("features.persistentEntities")
|
|
172
|
+
local removePersistentEntity = ____persistentEntities.removePersistentEntity
|
|
173
|
+
local spawnPersistentEntity = ____persistentEntities.spawnPersistentEntity
|
|
174
|
+
____exports.removePersistentEntity = removePersistentEntity
|
|
175
|
+
____exports.spawnPersistentEntity = spawnPersistentEntity
|
|
176
|
+
end
|
|
170
177
|
do
|
|
171
178
|
local ____playerInventory = require("features.playerInventory")
|
|
172
179
|
local addCollectible = ____playerInventory.addCollectible
|
package/initFeatures.lua
CHANGED
|
@@ -17,6 +17,8 @@ local ____forgottenSwitch = require("features.forgottenSwitch")
|
|
|
17
17
|
local forgottenSwitchInit = ____forgottenSwitch.forgottenSwitchInit
|
|
18
18
|
local ____getCollectibleItemPoolType = require("features.getCollectibleItemPoolType")
|
|
19
19
|
local getCollectibleItemPoolTypeInit = ____getCollectibleItemPoolType.getCollectibleItemPoolTypeInit
|
|
20
|
+
local ____persistentEntities = require("features.persistentEntities")
|
|
21
|
+
local persistentEntitiesInit = ____persistentEntities.persistentEntitiesInit
|
|
20
22
|
local ____playerInventory = require("features.playerInventory")
|
|
21
23
|
local playerInventoryInit = ____playerInventory.playerInventoryInit
|
|
22
24
|
local ____ponyDetection = require("features.ponyDetection")
|
|
@@ -42,6 +44,7 @@ function ____exports.initFeaturesMinor(self, mod)
|
|
|
42
44
|
fastResetInit(nil, mod)
|
|
43
45
|
forgottenSwitchInit(nil, mod)
|
|
44
46
|
getCollectibleItemPoolTypeInit(nil, mod)
|
|
47
|
+
persistentEntitiesInit(nil, mod)
|
|
45
48
|
playerInventoryInit(nil, mod)
|
|
46
49
|
ponyDetectionInit(nil, mod)
|
|
47
50
|
preventCollectibleRotationInit(nil, mod)
|