isaacscript-common 1.2.281 → 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
|
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")
|