isaacscript-common 1.2.279 → 1.2.282
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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
declare type ConversionHeartSubType = HeartSubType.HEART_SOUL | HeartSubType.HEART_BLACK;
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to make a character that has the same health mechanic as Blue Baby (red heart
|
|
5
|
+
* containers --> soul hearts) or Dark Judas (red heart containers --> black hearts).
|
|
6
|
+
*
|
|
7
|
+
* Call this function once at the beginning of your mod to declare the health conversion type.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerCharacterHealthConversion(playerType: PlayerType | int, conversionHeartSubType: ConversionHeartSubType): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local postPEffectUpdate, convertRedHeartContainers, removeRedHearts, prePickupCollisionHeart, characterHealthReplacementMap
|
|
6
|
+
local ____featuresInitialized = require("featuresInitialized")
|
|
7
|
+
local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
|
|
8
|
+
local ____pickups = require("functions.pickups")
|
|
9
|
+
local isRedHeart = ____pickups.isRedHeart
|
|
10
|
+
local ____utils = require("functions.utils")
|
|
11
|
+
local ensureAllCases = ____utils.ensureAllCases
|
|
12
|
+
function postPEffectUpdate(self, player)
|
|
13
|
+
local character = player:GetPlayerType()
|
|
14
|
+
local conversionHeartSubType = characterHealthReplacementMap:get(character)
|
|
15
|
+
if conversionHeartSubType == nil then
|
|
16
|
+
return
|
|
17
|
+
end
|
|
18
|
+
convertRedHeartContainers(nil, player, conversionHeartSubType)
|
|
19
|
+
removeRedHearts(nil, player)
|
|
20
|
+
end
|
|
21
|
+
function convertRedHeartContainers(self, player, heartSubType)
|
|
22
|
+
local maxHearts = player:GetMaxHearts()
|
|
23
|
+
if maxHearts == 0 then
|
|
24
|
+
return
|
|
25
|
+
end
|
|
26
|
+
player:AddMaxHearts(maxHearts * -1, false)
|
|
27
|
+
repeat
|
|
28
|
+
local ____switch7 = heartSubType
|
|
29
|
+
local ____cond7 = ____switch7 == HeartSubType.HEART_SOUL
|
|
30
|
+
if ____cond7 then
|
|
31
|
+
do
|
|
32
|
+
player:AddSoulHearts(maxHearts)
|
|
33
|
+
return
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
____cond7 = ____cond7 or ____switch7 == HeartSubType.HEART_BLACK
|
|
37
|
+
if ____cond7 then
|
|
38
|
+
do
|
|
39
|
+
player:AddBlackHearts(maxHearts)
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
do
|
|
44
|
+
do
|
|
45
|
+
ensureAllCases(nil, heartSubType)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
until true
|
|
49
|
+
end
|
|
50
|
+
function removeRedHearts(self, player)
|
|
51
|
+
local hearts = player:GetHearts()
|
|
52
|
+
if hearts > 0 then
|
|
53
|
+
player:AddHearts(hearts * -1)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
function prePickupCollisionHeart(self, pickup, collider)
|
|
57
|
+
if not isRedHeart(nil, pickup) then
|
|
58
|
+
return nil
|
|
59
|
+
end
|
|
60
|
+
local player = collider:ToPlayer()
|
|
61
|
+
if player == nil then
|
|
62
|
+
return nil
|
|
63
|
+
end
|
|
64
|
+
local character = player:GetPlayerType()
|
|
65
|
+
local conversionHeartSubType = characterHealthReplacementMap:get(character)
|
|
66
|
+
if conversionHeartSubType == nil then
|
|
67
|
+
return nil
|
|
68
|
+
end
|
|
69
|
+
return false
|
|
70
|
+
end
|
|
71
|
+
local FEATURE_NAME = "character health manager"
|
|
72
|
+
characterHealthReplacementMap = __TS__New(Map)
|
|
73
|
+
function ____exports.characterStatsInit(self, mod)
|
|
74
|
+
mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
|
|
75
|
+
mod:AddCallback(ModCallbacks.MC_PRE_PICKUP_COLLISION, prePickupCollisionHeart, 10)
|
|
76
|
+
end
|
|
77
|
+
function ____exports.registerCharacterHealthConversion(self, playerType, conversionHeartSubType)
|
|
78
|
+
errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
|
|
79
|
+
characterHealthReplacementMap:set(playerType, conversionHeartSubType)
|
|
80
|
+
end
|
|
81
|
+
return ____exports
|
|
@@ -32,7 +32,8 @@ export declare function getRoomGridIndexesForType(...roomTypes: RoomType[]): int
|
|
|
32
32
|
export declare function getRoomItemPoolType(): ItemPoolType;
|
|
33
33
|
/**
|
|
34
34
|
* Helper function to get the room descriptor for every room on the level. Uses the `Level.GetRooms`
|
|
35
|
-
* method to accomplish this.
|
|
35
|
+
* method to accomplish this. Rooms without data are assumed to be non-existent and are not added to
|
|
36
|
+
* the list.
|
|
36
37
|
*
|
|
37
38
|
* @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
38
39
|
* extra-dimensional rooms are automatically be generated and can be seen when you iterate over the
|
|
@@ -41,7 +42,10 @@ export declare function getRoomItemPoolType(): ItemPoolType;
|
|
|
41
42
|
export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
|
|
42
43
|
/**
|
|
43
44
|
* Helper function to get the room descriptor for every room on the level in a specific dimension.
|
|
44
|
-
* Uses the `Level.GetRooms` method to accomplish this.
|
|
45
|
+
* Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
|
|
46
|
+
* non-existent and are not added to the list.
|
|
47
|
+
*
|
|
48
|
+
* @returns A map of room ListIndex to RoomDescriptor.
|
|
45
49
|
*/
|
|
46
50
|
export declare function getRoomsOfDimension(dimension: Dimension): RoomDescriptor[];
|
|
47
51
|
/**
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -3,9 +3,10 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
|
3
3
|
local Set = ____lualib.Set
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
6
|
+
local Map = ____lualib.Map
|
|
7
|
+
local __TS__Spread = ____lualib.__TS__Spread
|
|
6
8
|
local __TS__StringIncludes = ____lualib.__TS__StringIncludes
|
|
7
9
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
8
|
-
local Map = ____lualib.Map
|
|
9
10
|
local ____exports = {}
|
|
10
11
|
local ____cachedClasses = require("cachedClasses")
|
|
11
12
|
local game = ____cachedClasses.game
|
|
@@ -47,14 +48,14 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
47
48
|
end
|
|
48
49
|
local level = game:GetLevel()
|
|
49
50
|
local roomList = level:GetRooms()
|
|
50
|
-
local
|
|
51
|
+
local roomsMap = __TS__New(Map)
|
|
51
52
|
if includeExtraDimensionalRooms then
|
|
52
53
|
do
|
|
53
54
|
local i = 0
|
|
54
55
|
while i < roomList.Size do
|
|
55
56
|
local roomDescriptor = roomList:Get(i)
|
|
56
|
-
if roomDescriptor ~= nil then
|
|
57
|
-
|
|
57
|
+
if roomDescriptor ~= nil and roomDescriptor.Data ~= nil then
|
|
58
|
+
roomsMap:set(roomDescriptor.ListIndex, roomDescriptor)
|
|
58
59
|
end
|
|
59
60
|
i = i + 1
|
|
60
61
|
end
|
|
@@ -64,14 +65,14 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
64
65
|
local i = 0
|
|
65
66
|
while i <= MAX_ROOM_INDEX do
|
|
66
67
|
local roomDescriptor = level:GetRoomByIdx(i)
|
|
67
|
-
if roomDescriptor ~= nil then
|
|
68
|
-
|
|
68
|
+
if roomDescriptor.Data ~= nil then
|
|
69
|
+
roomsMap:set(roomDescriptor.ListIndex, roomDescriptor)
|
|
69
70
|
end
|
|
70
71
|
i = i + 1
|
|
71
72
|
end
|
|
72
73
|
end
|
|
73
74
|
end
|
|
74
|
-
return
|
|
75
|
+
return {__TS__Spread(roomsMap:values())}
|
|
75
76
|
end
|
|
76
77
|
function ____exports.inDeathCertificateArea(self)
|
|
77
78
|
local roomStageID = getRoomStageID(nil)
|
|
@@ -136,18 +137,18 @@ function ____exports.getRoomItemPoolType(self)
|
|
|
136
137
|
end
|
|
137
138
|
function ____exports.getRoomsOfDimension(self, dimension)
|
|
138
139
|
local level = game:GetLevel()
|
|
139
|
-
local
|
|
140
|
+
local roomsMap = __TS__New(Map)
|
|
140
141
|
do
|
|
141
142
|
local i = 0
|
|
142
143
|
while i <= MAX_ROOM_INDEX do
|
|
143
144
|
local roomDescriptor = level:GetRoomByIdx(i, dimension)
|
|
144
|
-
if roomDescriptor ~= nil then
|
|
145
|
-
|
|
145
|
+
if roomDescriptor.Data ~= nil then
|
|
146
|
+
roomsMap:set(roomDescriptor.ListIndex, roomDescriptor)
|
|
146
147
|
end
|
|
147
148
|
i = i + 1
|
|
148
149
|
end
|
|
149
150
|
end
|
|
150
|
-
return
|
|
151
|
+
return {__TS__Spread(roomsMap:values())}
|
|
151
152
|
end
|
|
152
153
|
function ____exports.in2x1Room(self)
|
|
153
154
|
local room = game:GetRoom()
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export * from "./enums/PillEffectClass";
|
|
|
12
12
|
export * from "./enums/PillEffectType";
|
|
13
13
|
export * from "./enums/PocketItemType";
|
|
14
14
|
export * from "./enums/SerializationType";
|
|
15
|
-
export
|
|
15
|
+
export { registerCharacterHealthConversion } from "./features/characterHealthConversion";
|
|
16
|
+
export { registerCharacterStats } from "./features/characterStats";
|
|
16
17
|
export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/deployJSONRoom";
|
|
17
18
|
export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
|
|
18
19
|
export { disableAllSound, enableAllSound } from "./features/disableSound";
|
package/dist/index.lua
CHANGED
|
@@ -111,12 +111,14 @@ do
|
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
do
|
|
114
|
-
local
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
local ____characterHealthConversion = require("features.characterHealthConversion")
|
|
115
|
+
local registerCharacterHealthConversion = ____characterHealthConversion.registerCharacterHealthConversion
|
|
116
|
+
____exports.registerCharacterHealthConversion = registerCharacterHealthConversion
|
|
117
|
+
end
|
|
118
|
+
do
|
|
119
|
+
local ____characterStats = require("features.characterStats")
|
|
120
|
+
local registerCharacterStats = ____characterStats.registerCharacterStats
|
|
121
|
+
____exports.registerCharacterStats = registerCharacterStats
|
|
120
122
|
end
|
|
121
123
|
do
|
|
122
124
|
local ____deployJSONRoom = require("features.deployJSONRoom")
|