isaacscript-common 13.3.4 → 14.0.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/index.d.ts +576 -401
- package/dist/isaacscript-common.lua +14654 -13908
- package/dist/src/callbacks/postAmbush.d.ts.map +1 -1
- package/dist/src/callbacks/postAmbush.lua +7 -12
- package/dist/src/callbacks/postBombExploded.lua +3 -3
- package/dist/src/callbacks/postRoomClearChanged.d.ts.map +1 -1
- package/dist/src/callbacks/postRoomClearChanged.lua +3 -5
- package/dist/src/callbacks/subscriptions/{postBoneExploded.d.ts → postBombExploded.d.ts} +1 -1
- package/dist/src/callbacks/subscriptions/{postBoneExploded.d.ts.map → postBombExploded.d.ts.map} +1 -1
- package/dist/src/callbacks/subscriptions/{postBoneExploded.lua → postBombExploded.lua} +0 -0
- package/dist/src/callbacks/subscriptions/postCollectibleEmpty.d.ts +1 -1
- package/dist/src/callbacks/subscriptions/postCollectibleEmpty.d.ts.map +1 -1
- package/dist/src/callbacks/subscriptions/postCollectibleInitFirst.d.ts +1 -1
- package/dist/src/callbacks/subscriptions/postCollectibleInitFirst.d.ts.map +1 -1
- package/dist/src/callbacks/subscriptions/postCursedTeleport.d.ts +4 -2
- package/dist/src/callbacks/subscriptions/postCursedTeleport.d.ts.map +1 -1
- package/dist/src/callbacks/subscriptions/postCursedTeleport.lua +13 -1
- package/dist/src/callbacks/subscriptions/postHolyMantleRemoved.d.ts.map +1 -1
- package/dist/src/callbacks/subscriptions/postHolyMantleRemoved.lua +2 -2
- package/dist/src/callbacks/subscriptions/postPEffectUpdateReordered.d.ts.map +1 -1
- package/dist/src/callbacks/subscriptions/postPEffectUpdateReordered.lua +2 -2
- package/dist/src/classes/ModUpgraded.d.ts +9 -5
- package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
- package/dist/src/classes/ModUpgraded.lua +101 -14
- package/dist/src/classes/callbacks/PostAmbushFinished.d.ts +12 -0
- package/dist/src/classes/callbacks/PostAmbushFinished.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostAmbushFinished.lua +37 -0
- package/dist/src/classes/callbacks/PostAmbushStarted.d.ts +12 -0
- package/dist/src/classes/callbacks/PostAmbushStarted.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostAmbushStarted.lua +37 -0
- package/dist/src/classes/callbacks/PostBombExploded.d.ts +7 -0
- package/dist/src/classes/callbacks/PostBombExploded.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostBombExploded.lua +24 -0
- package/dist/src/classes/callbacks/PostBombInitLate.d.ts +12 -0
- package/dist/src/classes/callbacks/PostBombInitLate.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostBombInitLate.lua +27 -0
- package/dist/src/classes/callbacks/PostBoneSwing.d.ts +15 -0
- package/dist/src/classes/callbacks/PostBoneSwing.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostBoneSwing.lua +43 -0
- package/dist/src/classes/callbacks/PostCollectibleEmpty.d.ts +17 -0
- package/dist/src/classes/callbacks/PostCollectibleEmpty.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostCollectibleEmpty.lua +47 -0
- package/dist/src/classes/callbacks/PostCollectibleInitFirst.d.ts +13 -0
- package/dist/src/classes/callbacks/PostCollectibleInitFirst.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostCollectibleInitFirst.lua +32 -0
- package/dist/src/classes/callbacks/PostCursedTeleport.d.ts +21 -0
- package/dist/src/classes/callbacks/PostCursedTeleport.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostCursedTeleport.lua +113 -0
- package/dist/src/classes/callbacks/PostKnifeInitLate.d.ts +12 -0
- package/dist/src/classes/callbacks/PostKnifeInitLate.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostKnifeInitLate.lua +27 -0
- package/dist/src/classes/callbacks/PostNewRoomEarly.d.ts +14 -0
- package/dist/src/classes/callbacks/PostNewRoomEarly.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostNewRoomEarly.lua +65 -0
- package/dist/src/classes/callbacks/PostPitRender.d.ts +7 -0
- package/dist/src/classes/callbacks/PostPitRender.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostPitRender.lua +24 -0
- package/dist/src/classes/callbacks/PostRoomClearChanged.d.ts +13 -0
- package/dist/src/classes/callbacks/PostRoomClearChanged.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostRoomClearChanged.lua +33 -0
- package/dist/src/classes/callbacks/PostSpikesRender.d.ts +7 -0
- package/dist/src/classes/callbacks/PostSpikesRender.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostSpikesRender.lua +24 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackAmbush.d.ts +10 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackAmbush.d.ts.map +1 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackAmbush.lua +19 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackBomb.d.ts +10 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackBomb.d.ts.map +1 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackBomb.lua +19 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackCollectible.d.ts +10 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackCollectible.d.ts.map +1 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackCollectible.lua +19 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackKnife.d.ts +10 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackKnife.d.ts.map +1 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackKnife.lua +19 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackPit.d.ts +10 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackPit.d.ts.map +1 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackPit.lua +20 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackPlayer.d.ts +10 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackPlayer.d.ts.map +1 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackPlayer.lua +23 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackSpikes.d.ts +10 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackSpikes.d.ts.map +1 -0
- package/dist/src/classes/callbacks/validation/CustomCallbackSpikes.lua +20 -0
- package/dist/src/classes/private/CustomCallback.d.ts +32 -0
- package/dist/src/classes/private/CustomCallback.d.ts.map +1 -0
- package/dist/src/classes/private/CustomCallback.lua +53 -0
- package/dist/src/core/upgradeMod.d.ts.map +1 -1
- package/dist/src/core/upgradeMod.lua +16 -0
- package/dist/src/enums/IsaacScriptCommonFeature.d.ts +35 -0
- package/dist/src/enums/IsaacScriptCommonFeature.d.ts.map +1 -0
- package/dist/src/enums/IsaacScriptCommonFeature.lua +35 -0
- package/dist/src/enums/LadderSubTypeCustom.d.ts +17 -0
- package/dist/src/enums/LadderSubTypeCustom.d.ts.map +1 -0
- package/dist/src/enums/LadderSubTypeCustom.lua +19 -0
- package/dist/src/enums/ModCallbackCustom.d.ts +399 -327
- package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/src/enums/ModCallbackCustom.lua +85 -87
- package/dist/src/enums/ModCallbackCustom2.d.ts +17 -0
- package/dist/src/enums/ModCallbackCustom2.d.ts.map +1 -0
- package/dist/src/enums/ModCallbackCustom2.lua +30 -0
- package/dist/src/features/{setHotkey.d.ts → customHotkeys.d.ts} +1 -1
- package/dist/src/features/customHotkeys.d.ts.map +1 -0
- package/dist/src/features/{setHotkey.lua → customHotkeys.lua} +2 -2
- package/dist/src/features/customPickup.d.ts.map +1 -1
- package/dist/src/features/customPickup.lua +6 -2
- package/dist/src/features/customStage/backdrop.d.ts.map +1 -1
- package/dist/src/features/customStage/backdrop.lua +3 -1
- package/dist/src/features/customStage/shadows.d.ts.map +1 -1
- package/dist/src/features/customStage/shadows.lua +3 -1
- package/dist/src/features/customTrapdoor/init.lua +1 -7
- package/dist/src/features/firstLast.d.ts.map +1 -1
- package/dist/src/features/firstLast.lua +3 -3
- package/dist/src/features/saveDataManager/main.d.ts +5 -2
- package/dist/src/features/saveDataManager/main.d.ts.map +1 -1
- package/dist/src/features/saveDataManager/main.lua +3 -5
- package/dist/src/functions/ambush.d.ts +6 -0
- package/dist/src/functions/ambush.d.ts.map +1 -1
- package/dist/src/functions/ambush.lua +31 -0
- package/dist/src/functions/minimap.d.ts +4 -0
- package/dist/src/functions/minimap.d.ts.map +1 -1
- package/dist/src/functions/minimap.lua +4 -0
- package/dist/src/functions/roomTransition.d.ts +3 -4
- package/dist/src/functions/roomTransition.d.ts.map +1 -1
- package/dist/src/functions/roomTransition.lua +4 -32
- package/dist/src/functions/spawnCollectible.d.ts +24 -5
- package/dist/src/functions/spawnCollectible.d.ts.map +1 -1
- package/dist/src/functions/spawnCollectible.lua +44 -4
- package/dist/src/functions/utils.d.ts +7 -2
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +7 -2
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +26 -10
- package/dist/src/initCustomCallbacks.d.ts.map +1 -1
- package/dist/src/initCustomCallbacks.lua +0 -3
- package/dist/src/initFeatures.lua +3 -3
- package/dist/src/interfaces/private/{AddCallbackParameterCustom.d.ts → AddCallbackParametersCustom.d.ts} +3 -5
- package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -0
- package/dist/src/interfaces/private/{AddCallbackParameterCustom.lua → AddCallbackParametersCustom.lua} +0 -0
- package/dist/src/interfaces/private/AddCallbackParametersCustom2.d.ts +55 -0
- package/dist/src/interfaces/private/AddCallbackParametersCustom2.d.ts.map +1 -0
- package/dist/src/interfaces/private/AddCallbackParametersCustom2.lua +4 -0
- package/dist/src/objects/callbackRegisterFunctions.d.ts +1 -1
- package/dist/src/objects/callbackRegisterFunctions.d.ts.map +1 -1
- package/dist/src/objects/callbackRegisterFunctions.lua +2 -5
- package/dist/src/types/private/AllButFirst.d.ts +5 -0
- package/dist/src/types/private/AllButFirst.d.ts.map +1 -0
- package/dist/src/types/private/AllButFirst.lua +2 -0
- package/dist/src/types/private/CallbackTuple.d.ts +20 -0
- package/dist/src/types/private/CallbackTuple.d.ts.map +1 -0
- package/dist/src/types/private/CallbackTuple.lua +2 -0
- package/dist/src/types/private/MatchingCallbackCustom.d.ts +14 -0
- package/dist/src/types/private/MatchingCallbackCustom.d.ts.map +1 -0
- package/dist/src/types/private/MatchingCallbackCustom.lua +2 -0
- package/package.json +2 -2
- package/src/callbacks/postAmbush.ts +7 -14
- package/src/callbacks/postBombExploded.ts +1 -1
- package/src/callbacks/postBoneSwing.ts +2 -1
- package/src/callbacks/postCollectibleEmpty.ts +2 -0
- package/src/callbacks/postCollectibleInitFirst.ts +2 -0
- package/src/callbacks/postNewRoomEarly.ts +1 -1
- package/src/callbacks/postRoomClearChanged.ts +3 -7
- package/src/callbacks/subscriptions/{postBoneExploded.ts → postBombExploded.ts} +0 -0
- package/src/callbacks/subscriptions/postCollectibleEmpty.ts +1 -1
- package/src/callbacks/subscriptions/postCollectibleInitFirst.ts +1 -1
- package/src/callbacks/subscriptions/postCursedTeleport.ts +24 -1
- package/src/callbacks/subscriptions/postHolyMantleRemoved.ts +9 -2
- package/src/callbacks/subscriptions/postPEffectUpdateReordered.ts +9 -2
- package/src/classes/ModUpgraded.ts +118 -27
- package/src/classes/callbacks/PostAmbushFinished.ts +39 -0
- package/src/classes/callbacks/PostAmbushStarted.ts +39 -0
- package/src/classes/callbacks/PostBombExploded.ts +21 -0
- package/src/classes/callbacks/PostBombInitLate.ts +28 -0
- package/src/classes/callbacks/PostBoneSwing.ts +58 -0
- package/src/classes/callbacks/PostCollectibleEmpty.ts +72 -0
- package/src/classes/callbacks/PostCollectibleInitFirst.ts +37 -0
- package/src/classes/callbacks/PostCursedTeleport.ts +183 -0
- package/src/classes/callbacks/PostKnifeInitLate.ts +28 -0
- package/src/classes/callbacks/PostNewRoomEarly.ts +93 -0
- package/src/classes/callbacks/PostPitRender.ts +21 -0
- package/src/classes/callbacks/PostRoomClearChanged.ts +40 -0
- package/src/classes/callbacks/PostSpikesRender.ts +21 -0
- package/src/classes/callbacks/validation/CustomCallbackAmbush.ts +28 -0
- package/src/classes/callbacks/validation/CustomCallbackBomb.ts +27 -0
- package/src/classes/callbacks/validation/CustomCallbackCollectible.ts +30 -0
- package/src/classes/callbacks/validation/CustomCallbackKnife.ts +27 -0
- package/src/classes/callbacks/validation/CustomCallbackPit.ts +28 -0
- package/src/classes/callbacks/validation/CustomCallbackPlayer.ts +37 -0
- package/src/classes/callbacks/validation/CustomCallbackSpikes.ts +28 -0
- package/src/classes/private/CustomCallback.ts +79 -0
- package/src/core/upgradeMod.ts +16 -2
- package/src/enums/IsaacScriptCommonFeature.ts +34 -0
- package/src/enums/LadderSubTypeCustom.ts +17 -0
- package/src/enums/ModCallbackCustom.ts +314 -243
- package/src/enums/ModCallbackCustom2.ts +17 -0
- package/src/features/{setHotkey.ts → customHotkeys.ts} +2 -2
- package/src/features/customPickup.ts +4 -2
- package/src/features/customStage/backdrop.ts +2 -1
- package/src/features/customStage/shadows.ts +2 -1
- package/src/features/customTrapdoor/init.ts +0 -1
- package/src/features/firstLast.ts +3 -7
- package/src/features/saveDataManager/main.ts +32 -21
- package/src/functions/ambush.ts +26 -1
- package/src/functions/minimap.ts +4 -0
- package/src/functions/roomTransition.ts +3 -27
- package/src/functions/spawnCollectible.ts +44 -4
- package/src/functions/utils.ts +7 -2
- package/src/index.ts +4 -2
- package/src/initCustomCallbacks.ts +1 -2
- package/src/initFeatures.ts +2 -2
- package/src/interfaces/private/{AddCallbackParameterCustom.ts → AddCallbackParametersCustom.ts} +2 -24
- package/src/interfaces/private/AddCallbackParametersCustom2.ts +79 -0
- package/src/objects/callbackRegisterFunctions.ts +2 -4
- package/src/types/private/AllButFirst.ts +6 -0
- package/src/types/private/CallbackTuple.ts +21 -0
- package/src/types/private/MatchingCallbackCustom.ts +26 -0
- package/dist/src/callbacks/postCustomDoorEnter.d.ts +0 -6
- package/dist/src/callbacks/postCustomDoorEnter.d.ts.map +0 -1
- package/dist/src/callbacks/postCustomDoorEnter.lua +0 -199
- package/dist/src/callbacks/subscriptions/postCustomDoorEnter.d.ts +0 -9
- package/dist/src/callbacks/subscriptions/postCustomDoorEnter.d.ts.map +0 -1
- package/dist/src/callbacks/subscriptions/postCustomDoorEnter.lua +0 -29
- package/dist/src/classes/CustomCallback.d.ts +0 -8
- package/dist/src/classes/CustomCallback.d.ts.map +0 -1
- package/dist/src/classes/CustomCallback.lua +0 -28
- package/dist/src/features/customDoor.d.ts +0 -51
- package/dist/src/features/customDoor.d.ts.map +0 -1
- package/dist/src/features/customDoor.lua +0 -53
- package/dist/src/features/setHotkey.d.ts.map +0 -1
- package/dist/src/interfaces/private/AddCallbackParameterCustom.d.ts.map +0 -1
- package/src/callbacks/postCustomDoorEnter.ts +0 -250
- package/src/callbacks/subscriptions/postCustomDoorEnter.ts +0 -42
- package/src/classes/CustomCallback.ts +0 -23
- package/src/features/customDoor.ts +0 -66
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Direction,
|
|
3
|
-
DoorSlot,
|
|
4
|
-
DoorState,
|
|
5
|
-
EffectVariant,
|
|
6
|
-
GridCollisionClass,
|
|
7
|
-
GridEntityType,
|
|
8
|
-
ModCallback,
|
|
9
|
-
} from "isaac-typescript-definitions";
|
|
10
|
-
import { ModUpgraded } from "../classes/ModUpgraded";
|
|
11
|
-
import { game } from "../core/cachedClasses";
|
|
12
|
-
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
|
|
13
|
-
import { saveDataManager } from "../features/saveDataManager/exports";
|
|
14
|
-
import { directionToVector } from "../functions/direction";
|
|
15
|
-
import { doorSlotToDirection } from "../functions/doors";
|
|
16
|
-
import { getEffects, spawnEffect } from "../functions/entitiesSpecific";
|
|
17
|
-
import { getClosestPlayer } from "../functions/players";
|
|
18
|
-
import { asNumber } from "../functions/types";
|
|
19
|
-
import {
|
|
20
|
-
postCustomDoorEnterFire,
|
|
21
|
-
postCustomDoorEnterHasSubscriptions,
|
|
22
|
-
} from "./subscriptions/postCustomDoorEnter";
|
|
23
|
-
|
|
24
|
-
interface EntityEffectCustomDoor extends EntityEffect {
|
|
25
|
-
State: DoorState;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface CustomDoorData {
|
|
29
|
-
slot: DoorSlot;
|
|
30
|
-
state: DoorState;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const POSITION_OFFSET_MULTIPLIER = -23;
|
|
34
|
-
|
|
35
|
-
const initializedEffectVariants = new Set<int>();
|
|
36
|
-
|
|
37
|
-
const v = {
|
|
38
|
-
room: {
|
|
39
|
-
customDoors: new Map<PtrHash, CustomDoorData>(),
|
|
40
|
-
customDoorSlots: new Set<DoorSlot>(),
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export function postCustomDoorEnterInit(): void {
|
|
45
|
-
saveDataManager("postCustomDoorEnter", v, hasSubscriptions);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function hasSubscriptions() {
|
|
49
|
-
return postCustomDoorEnterHasSubscriptions();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function initCustomDoorInternal(
|
|
53
|
-
mod: ModUpgraded,
|
|
54
|
-
effectVariant: EffectVariant,
|
|
55
|
-
): void {
|
|
56
|
-
initializedEffectVariants.add(effectVariant);
|
|
57
|
-
|
|
58
|
-
mod.AddCallback(
|
|
59
|
-
ModCallback.POST_EFFECT_UPDATE,
|
|
60
|
-
postEffectUpdaterCustomEntity,
|
|
61
|
-
effectVariant,
|
|
62
|
-
); // 55
|
|
63
|
-
|
|
64
|
-
mod.AddCallback(
|
|
65
|
-
ModCallback.POST_EFFECT_RENDER,
|
|
66
|
-
postEffectRenderCustomEntity,
|
|
67
|
-
effectVariant,
|
|
68
|
-
); // 56
|
|
69
|
-
|
|
70
|
-
mod.AddCallbackCustom(
|
|
71
|
-
ModCallbackCustom.POST_ROOM_CLEAR_CHANGED,
|
|
72
|
-
(roomClear: boolean) => {
|
|
73
|
-
postRoomClearChanged(roomClear, effectVariant);
|
|
74
|
-
},
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// ModCallback.POST_EFFECT_UPDATE (55)
|
|
79
|
-
function postEffectUpdaterCustomEntity(effect: EntityEffect) {
|
|
80
|
-
const customDoor = effect as EntityEffectCustomDoor;
|
|
81
|
-
|
|
82
|
-
const ptrHash = GetPtrHash(effect);
|
|
83
|
-
const doorData = v.room.customDoors.get(ptrHash);
|
|
84
|
-
if (doorData === undefined) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (doorData.state === customDoor.State) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
doorData.state = customDoor.State;
|
|
92
|
-
|
|
93
|
-
doorChangedState(effect);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function doorChangedState(door: EntityEffectCustomDoor) {
|
|
97
|
-
const room = game.GetRoom();
|
|
98
|
-
|
|
99
|
-
const sprite = door.GetSprite();
|
|
100
|
-
const animation = getAnimationForCustomDoor(door);
|
|
101
|
-
sprite.Play(animation, true);
|
|
102
|
-
|
|
103
|
-
const gridIndex = room.GetGridIndex(door.Position);
|
|
104
|
-
const wall = room.GetGridEntity(gridIndex);
|
|
105
|
-
if (wall !== undefined) {
|
|
106
|
-
wall.CollisionClass =
|
|
107
|
-
door.State === DoorState.OPEN
|
|
108
|
-
? GridCollisionClass.WALL_EXCEPT_PLAYER
|
|
109
|
-
: GridCollisionClass.WALL;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function getAnimationForCustomDoor(door: EntityEffectCustomDoor): string {
|
|
114
|
-
const freshlySpawned = door.FrameCount === 0;
|
|
115
|
-
|
|
116
|
-
switch (door.State) {
|
|
117
|
-
case DoorState.OPEN: {
|
|
118
|
-
return freshlySpawned ? "Opened" : "Open";
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
case DoorState.CLOSED: {
|
|
122
|
-
return freshlySpawned ? "Closed" : "Close";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
default: {
|
|
126
|
-
return "Opened";
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ModCallback.POST_EFFECT_RENDER (56)
|
|
132
|
-
function postEffectRenderCustomEntity(effect: EntityEffect) {
|
|
133
|
-
const ptrHash = GetPtrHash(effect);
|
|
134
|
-
const doorData = v.room.customDoors.get(ptrHash);
|
|
135
|
-
if (doorData === undefined) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const direction = doorSlotToDirection(doorData.slot);
|
|
140
|
-
const player = getClosestPlayer(effect.Position);
|
|
141
|
-
if (isPlayerPastDoorThreshold(effect, player, direction)) {
|
|
142
|
-
postCustomDoorEnterFire(player, effect.Variant, doorData.slot, direction);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function isPlayerPastDoorThreshold(
|
|
147
|
-
effect: EntityEffect,
|
|
148
|
-
player: EntityPlayer,
|
|
149
|
-
direction: Direction,
|
|
150
|
-
) {
|
|
151
|
-
switch (direction) {
|
|
152
|
-
case Direction.NO_DIRECTION: {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// 1
|
|
157
|
-
case Direction.UP: {
|
|
158
|
-
return player.Position.Y <= effect.Position.Y;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// 2
|
|
162
|
-
case Direction.RIGHT: {
|
|
163
|
-
return player.Position.X >= effect.Position.X;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// 3
|
|
167
|
-
case Direction.DOWN: {
|
|
168
|
-
return player.Position.Y >= effect.Position.Y;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// 4
|
|
172
|
-
case Direction.LEFT: {
|
|
173
|
-
return player.Position.X <= effect.Position.X;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ModCallbackCustom.POST_ROOM_CLEAR_CHANGED
|
|
179
|
-
function postRoomClearChanged(
|
|
180
|
-
roomClear: boolean,
|
|
181
|
-
effectVariant: EffectVariant,
|
|
182
|
-
) {
|
|
183
|
-
const state = roomClear ? DoorState.OPEN : DoorState.CLOSED;
|
|
184
|
-
const customDoors = getEffects(effectVariant);
|
|
185
|
-
for (const customDoor of customDoors) {
|
|
186
|
-
customDoor.State = state;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function spawnCustomDoorInternal(
|
|
191
|
-
effectVariant: EffectVariant,
|
|
192
|
-
doorSlot: DoorSlot,
|
|
193
|
-
): EntityEffect {
|
|
194
|
-
if (!initializedEffectVariants.has(effectVariant)) {
|
|
195
|
-
error(
|
|
196
|
-
'In order to spawn custom doors, you must first initialize them with the "initCustomDoor" function at the beginning of your mod.',
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (v.room.customDoorSlots.has(doorSlot)) {
|
|
201
|
-
error(
|
|
202
|
-
`There is already a custom door initialized on door slot: ${doorSlot}`,
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const room = game.GetRoom();
|
|
207
|
-
const roomClear = room.IsClear();
|
|
208
|
-
const position = room.GetDoorSlotPosition(doorSlot);
|
|
209
|
-
const gridEntity = room.GetGridEntityFromPos(position);
|
|
210
|
-
if (gridEntity === undefined) {
|
|
211
|
-
error(
|
|
212
|
-
`Failed to initialize a custom door at slot ${doorSlot} because the wall on that tile does not exist.`,
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const gridEntityType = gridEntity.GetType();
|
|
217
|
-
if (gridEntityType !== GridEntityType.WALL) {
|
|
218
|
-
error(
|
|
219
|
-
`Failed to initialize a custom door at slot ${doorSlot} because there is another grid entity on that tile with a type of: ${gridEntityType}`,
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const effect = spawnEffect(effectVariant, 0, position);
|
|
224
|
-
|
|
225
|
-
// Do initial setup for the door.
|
|
226
|
-
effect.State = roomClear ? DoorState.OPEN : DoorState.CLOSED;
|
|
227
|
-
effect.RenderZOffset = -10000;
|
|
228
|
-
effect.PositionOffset = getPositionOffset(doorSlot);
|
|
229
|
-
const sprite = effect.GetSprite();
|
|
230
|
-
sprite.Rotation = asNumber(doorSlot) * 90 - 90;
|
|
231
|
-
|
|
232
|
-
// Keep track of metadata about this door.
|
|
233
|
-
const ptrHash = GetPtrHash(effect);
|
|
234
|
-
const doorData: CustomDoorData = {
|
|
235
|
-
slot: doorSlot,
|
|
236
|
-
state: effect.State,
|
|
237
|
-
};
|
|
238
|
-
v.room.customDoors.set(ptrHash, doorData);
|
|
239
|
-
v.room.customDoorSlots.add(doorSlot);
|
|
240
|
-
|
|
241
|
-
doorChangedState(effect);
|
|
242
|
-
|
|
243
|
-
return effect;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function getPositionOffset(doorSlot: DoorSlot) {
|
|
247
|
-
const direction = doorSlotToDirection(doorSlot);
|
|
248
|
-
const vector = directionToVector(direction);
|
|
249
|
-
return vector.mul(POSITION_OFFSET_MULTIPLIER);
|
|
250
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Direction, DoorSlot } from "isaac-typescript-definitions";
|
|
2
|
-
|
|
3
|
-
export type PostCustomDoorEnterRegisterParameters = [
|
|
4
|
-
callback: (
|
|
5
|
-
player: EntityPlayer,
|
|
6
|
-
effectVariant: int,
|
|
7
|
-
doorSlot: DoorSlot,
|
|
8
|
-
direction: Direction,
|
|
9
|
-
) => void,
|
|
10
|
-
effectVariant?: int,
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
const subscriptions: PostCustomDoorEnterRegisterParameters[] = [];
|
|
14
|
-
|
|
15
|
-
export function postCustomDoorEnterHasSubscriptions(): boolean {
|
|
16
|
-
return subscriptions.length > 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function postCustomDoorEnterRegister(
|
|
20
|
-
...args: PostCustomDoorEnterRegisterParameters
|
|
21
|
-
): void {
|
|
22
|
-
subscriptions.push(args);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function postCustomDoorEnterFire(
|
|
26
|
-
player: EntityPlayer,
|
|
27
|
-
effectVariant: int,
|
|
28
|
-
doorSlot: DoorSlot,
|
|
29
|
-
direction: Direction,
|
|
30
|
-
): void {
|
|
31
|
-
for (const [callback, callbackEffectVariant] of subscriptions) {
|
|
32
|
-
// Handle the optional 2nd callback argument.
|
|
33
|
-
if (
|
|
34
|
-
callbackEffectVariant !== undefined &&
|
|
35
|
-
callbackEffectVariant !== effectVariant
|
|
36
|
-
) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
callback(player, effectVariant, doorSlot, direction);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
export class CustomCallback<AddParams extends [], FireParams extends []> {
|
|
4
|
-
subscriptions: AddParams[] = [];
|
|
5
|
-
|
|
6
|
-
hasSubscriptions(): boolean {
|
|
7
|
-
return this.subscriptions.length > 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
add(...args: AddParams): void {
|
|
11
|
-
this.subscriptions.push(args);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
remove(callback: AddParams[0]): void {
|
|
15
|
-
const subscriptionIndexMatchingCallback = this.subscriptions.find(
|
|
16
|
-
(subscription) => {
|
|
17
|
-
// const subscriptionCallback = subscription[0];
|
|
18
|
-
},
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fire(...args: FireParams): void {}
|
|
23
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { DoorSlot, EffectVariant } from "isaac-typescript-definitions";
|
|
2
|
-
import {
|
|
3
|
-
initCustomDoorInternal,
|
|
4
|
-
spawnCustomDoorInternal,
|
|
5
|
-
} from "../callbacks/postCustomDoorEnter";
|
|
6
|
-
import { ModUpgraded } from "../classes/ModUpgraded";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* `isaacscript-common` provides custom doors that can be spawned where any wall segment is. If you
|
|
10
|
-
* use this feature, you must first call this initialization function at the beginning of your mod.
|
|
11
|
-
*
|
|
12
|
-
* Each kind of custom door that you create must have an entry in the "content/entities2.xml" file,
|
|
13
|
-
* like so:
|
|
14
|
-
*
|
|
15
|
-
* ```xml
|
|
16
|
-
* <entity id="1000" name="Foo Custom Door" anm2path="grid/door_foo.anm2" />
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* (Custom door entities must have an id of "1000", which corresponds to an effect. If you do not
|
|
20
|
-
* specify the variant, then the game will automatically assign it.)
|
|
21
|
-
*
|
|
22
|
-
* Next, pass the variant into this function:
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* const modVanilla = RegisterMod("My Mod", 1);
|
|
26
|
-
* const mod = upgradeMod(modVanilla);
|
|
27
|
-
* const fooEffectVariant = Isaac.GetEntityVariantByName("Foo Custom Door");
|
|
28
|
-
* initCustomDoor(mod, fooEffectVariant);
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* Also see the `spawnCustomDoor` function.
|
|
32
|
-
*/
|
|
33
|
-
export function initCustomDoor(
|
|
34
|
-
mod: ModUpgraded,
|
|
35
|
-
effectVariant: EffectVariant,
|
|
36
|
-
): void {
|
|
37
|
-
initCustomDoorInternal(mod, effectVariant);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Helper function to spawn a custom door. This is intended to be called from the `POST_NEW_ROOM`
|
|
42
|
-
* callback when the player enters a room that should have a custom door. (You could also call it
|
|
43
|
-
* from another callback if you want the door to appear e.g. after clearing all enemies.)
|
|
44
|
-
*
|
|
45
|
-
* Like other entities, the door is not persistent, so you must spawn it every time when re-entering
|
|
46
|
-
* the room.
|
|
47
|
-
*
|
|
48
|
-
* Handle when a player enters the door by hooking the custom `POST_CUSTOM_DOOR_ENTER` callback.
|
|
49
|
-
*
|
|
50
|
-
* The custom door is an `EntityEffect`. You can manually open or close the door by modifying its
|
|
51
|
-
* state. (The values to use correspond to the `DoorState` enum.)
|
|
52
|
-
*
|
|
53
|
-
* This function will throw a run-time error if:
|
|
54
|
-
* - the door slot already has a vanilla door
|
|
55
|
-
* - the door slot already has a custom door
|
|
56
|
-
* - the tile at the door slot does not have a wall
|
|
57
|
-
*
|
|
58
|
-
* Before using this function, you must first initialize the effect/door variant with the
|
|
59
|
-
* `initCustomDoor` function.
|
|
60
|
-
*/
|
|
61
|
-
export function spawnCustomDoor(
|
|
62
|
-
effectVariant: EffectVariant,
|
|
63
|
-
doorSlot: DoorSlot,
|
|
64
|
-
): EntityEffect {
|
|
65
|
-
return spawnCustomDoorInternal(effectVariant, doorSlot);
|
|
66
|
-
}
|