isaacscript-common 20.4.0 → 20.5.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 +47 -10
- package/dist/isaacscript-common.lua +83 -95
- package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.d.ts +0 -11
- package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.d.ts.map +1 -1
- package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.lua +3 -28
- package/dist/src/enums/ModCallbackCustom.d.ts +29 -2
- package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/src/functions/entities.d.ts +8 -0
- package/dist/src/functions/entities.d.ts.map +1 -1
- package/dist/src/functions/entities.lua +11 -0
- package/dist/src/functions/sprites.d.ts +8 -0
- package/dist/src/functions/sprites.d.ts.map +1 -1
- package/dist/src/functions/sprites.lua +12 -0
- package/package.json +1 -1
- package/src/classes/features/callbackLogic/SlotDestroyedDetection.ts +2 -52
- package/src/enums/ModCallbackCustom.ts +29 -2
- package/src/functions/entities.ts +13 -0
- package/src/functions/sprites.ts +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -3123,12 +3123,6 @@ export declare function deserializeRNG(rng: SerializedRNG): RNG;
|
|
|
3123
3123
|
*/
|
|
3124
3124
|
export declare function deserializeVector(vector: SerializedVector): Vector;
|
|
3125
3125
|
|
|
3126
|
-
declare type DespawnedSlotTuple = [
|
|
3127
|
-
gameFrame: int,
|
|
3128
|
-
position: Vector,
|
|
3129
|
-
entityPtr: EntityPtr
|
|
3130
|
-
];
|
|
3131
|
-
|
|
3132
3126
|
/** For `EntityType.EFFECT` (1000), `EffectVariant.DICE_FLOOR` (76). */
|
|
3133
3127
|
export declare const DICE_FLOOR_TRIGGER_SQUARE_SIZE = 75;
|
|
3134
3128
|
|
|
@@ -10211,8 +10205,35 @@ export declare enum ModCallbackCustom {
|
|
|
10211
10205
|
*/
|
|
10212
10206
|
POST_SLOT_COLLISION = 87,
|
|
10213
10207
|
/**
|
|
10214
|
-
* Fires from the `
|
|
10215
|
-
*
|
|
10208
|
+
* Fires from the `POST_SLOT_UPDATE` or the `POST_ENTITY_REMOVE` callback when a slot machine is
|
|
10209
|
+
* destroyed or a beggar is removed.
|
|
10210
|
+
*
|
|
10211
|
+
* This callback will fire in four different kinds of situations:
|
|
10212
|
+
*
|
|
10213
|
+
* 1. When slot machine entities (e.g. `SlotVariant.SLOT_MACHINE` and
|
|
10214
|
+
* `SlotVariant.BLOOD_DONATION_MACHINE`) are destroyed with an explosion. When this happens,
|
|
10215
|
+
* they typically stay in the room and can be pushed around. This state is detected via a
|
|
10216
|
+
* change in the `GridCollisionClass`.
|
|
10217
|
+
* 2. When slot machine entities pay out with a collectible item. When this happens, they
|
|
10218
|
+
* immediately despawn without playing any special animation.
|
|
10219
|
+
* 3. When beggar entities (e.g. `SlotVariant.BEGGAR` and `SlotVariant.SHELL_GAME`) are destroyed
|
|
10220
|
+
* with an explosion. When this happens, they immediately despawn without playing any special
|
|
10221
|
+
* animation.
|
|
10222
|
+
* 4. When beggar entities pay out with a collectible item. When this happens, they despawn after
|
|
10223
|
+
* playing the "Teleport" animation. (This is not technically a "destruction" event, but the
|
|
10224
|
+
* callback will fire for this to remain consistent with the other types of slot entities.)
|
|
10225
|
+
*
|
|
10226
|
+
* Depending on the specific types of slot removal that you need to detect, you can filter using:
|
|
10227
|
+
*
|
|
10228
|
+
* 1. The `isSlotMachine` helper function to differentiate between slot machines and beggars.
|
|
10229
|
+
* 2. The passed callback argument of `SlotDestructionType` to differentiate between bombed slots
|
|
10230
|
+
* and slots that paid out with a collectible item.
|
|
10231
|
+
*
|
|
10232
|
+
* Note that when a Crane Game explodes after paying out three collectibles, the
|
|
10233
|
+
* `SlotDestructionType` will be equal to `SlotDestructionType.NORMAL` instead of
|
|
10234
|
+
* `SlotDestructionType.COLLECTIBLE_PAYOUT` like you might expect. (This is because it only
|
|
10235
|
+
* explodes after a short delay, and when doing so, it produces rewards in the same way that would
|
|
10236
|
+
* happen if you bombed it.)
|
|
10216
10237
|
*
|
|
10217
10238
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
10218
10239
|
* - You can provide an optional third argument that will make the callback only fire if it
|
|
@@ -13896,6 +13917,15 @@ export declare function setDisplayFlags(displayFlagsMap: Map<int, BitFlags<Displ
|
|
|
13896
13917
|
*/
|
|
13897
13918
|
export declare function setEntityDamageFlash(entity: Entity): void;
|
|
13898
13919
|
|
|
13920
|
+
/**
|
|
13921
|
+
* Helper function to keep an entity's color the same values as it already is but set the opacity to
|
|
13922
|
+
* a specific value.
|
|
13923
|
+
*
|
|
13924
|
+
* @param entity The entity to set.
|
|
13925
|
+
* @param alpha A value between 0 and 1 that represents the fade amount.
|
|
13926
|
+
*/
|
|
13927
|
+
export declare function setEntityOpacity(entity: Entity, alpha: float): void;
|
|
13928
|
+
|
|
13899
13929
|
/**
|
|
13900
13930
|
* Helper function to set the position of every entity in the room based on a map of positions. If
|
|
13901
13931
|
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
@@ -14005,6 +14035,15 @@ export declare function setRoomVisible(roomGridIndex: int | undefined, updateVis
|
|
|
14005
14035
|
/** Helper function to set a seed to an RNG object using Blade's recommended shift index. */
|
|
14006
14036
|
export declare function setSeed(rng: RNG, seed: Seed): void;
|
|
14007
14037
|
|
|
14038
|
+
/**
|
|
14039
|
+
* Helper function to keep a sprite's color the same values as it already is but set the opacity to
|
|
14040
|
+
* a specific value.
|
|
14041
|
+
*
|
|
14042
|
+
* @param sprite The sprite to set.
|
|
14043
|
+
* @param alpha A value between 0 and 1 that represents the fade amount.
|
|
14044
|
+
*/
|
|
14045
|
+
export declare function setSpriteOpacity(sprite: Sprite, alpha: float): void;
|
|
14046
|
+
|
|
14008
14047
|
/**
|
|
14009
14048
|
* Helper function to warp to a new stage/level.
|
|
14010
14049
|
*
|
|
@@ -14121,13 +14160,11 @@ declare class SlotDestroyedDetection extends Feature {
|
|
|
14121
14160
|
v: {
|
|
14122
14161
|
room: {
|
|
14123
14162
|
destroyedSlotSet: Set<PtrHash>;
|
|
14124
|
-
despawnedSlots: DespawnedSlotTuple[];
|
|
14125
14163
|
};
|
|
14126
14164
|
};
|
|
14127
14165
|
private postSlotDestroyed;
|
|
14128
14166
|
private roomHistory;
|
|
14129
14167
|
constructor(postSlotDestroyed: PostSlotDestroyed, roomHistory: RoomHistory);
|
|
14130
|
-
private postPickupInitCollectible;
|
|
14131
14168
|
private postEntityRemoveSlot;
|
|
14132
14169
|
private postEntityRemoveSlotMachine;
|
|
14133
14170
|
private postEntityRemoveBeggar;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 20.
|
|
3
|
+
isaacscript-common 20.5.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -19640,6 +19640,79 @@ return ____exports
|
|
|
19640
19640
|
end,
|
|
19641
19641
|
["src.types.EntityID"] = function(...)
|
|
19642
19642
|
local ____exports = {}
|
|
19643
|
+
return ____exports
|
|
19644
|
+
end,
|
|
19645
|
+
["src.functions.sprites"] = function(...)
|
|
19646
|
+
local ____exports = {}
|
|
19647
|
+
local ____constants = require("src.core.constants")
|
|
19648
|
+
local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
|
|
19649
|
+
local VectorZero = ____constants.VectorZero
|
|
19650
|
+
local ____color = require("src.functions.color")
|
|
19651
|
+
local copyColor = ____color.copyColor
|
|
19652
|
+
local ____kColor = require("src.functions.kColor")
|
|
19653
|
+
local kColorEquals = ____kColor.kColorEquals
|
|
19654
|
+
local ____utils = require("src.functions.utils")
|
|
19655
|
+
local eRange = ____utils.eRange
|
|
19656
|
+
function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
|
|
19657
|
+
local kColor1 = sprite1:GetTexel(position, VectorZero, 1, layerID)
|
|
19658
|
+
local kColor2 = sprite2:GetTexel(position, VectorZero, 1, layerID)
|
|
19659
|
+
return kColorEquals(nil, kColor1, kColor2)
|
|
19660
|
+
end
|
|
19661
|
+
function ____exports.clearSprite(self, sprite, ...)
|
|
19662
|
+
local layerIDs = {...}
|
|
19663
|
+
if #layerIDs == 0 then
|
|
19664
|
+
local numLayers = sprite:GetLayerCount()
|
|
19665
|
+
layerIDs = eRange(nil, numLayers)
|
|
19666
|
+
end
|
|
19667
|
+
for ____, layerID in ipairs(layerIDs) do
|
|
19668
|
+
sprite:ReplaceSpritesheet(layerID, EMPTY_PNG_PATH)
|
|
19669
|
+
end
|
|
19670
|
+
sprite:LoadGraphics()
|
|
19671
|
+
end
|
|
19672
|
+
function ____exports.getLastFrameOfAnimation(self, sprite, animation)
|
|
19673
|
+
local currentAnimation = sprite:GetAnimation()
|
|
19674
|
+
local currentFrame = sprite:GetFrame()
|
|
19675
|
+
if animation ~= nil and animation ~= currentAnimation then
|
|
19676
|
+
sprite:SetAnimation(animation)
|
|
19677
|
+
end
|
|
19678
|
+
sprite:SetLastFrame()
|
|
19679
|
+
local finalFrame = sprite:GetFrame()
|
|
19680
|
+
if animation ~= nil and animation ~= currentAnimation then
|
|
19681
|
+
sprite:Play(currentAnimation, true)
|
|
19682
|
+
end
|
|
19683
|
+
sprite:SetFrame(currentFrame)
|
|
19684
|
+
return finalFrame
|
|
19685
|
+
end
|
|
19686
|
+
function ____exports.setSpriteOpacity(self, sprite, alpha)
|
|
19687
|
+
local fadedColor = copyColor(nil, sprite.Color)
|
|
19688
|
+
fadedColor.A = alpha
|
|
19689
|
+
sprite.Color = fadedColor
|
|
19690
|
+
end
|
|
19691
|
+
function ____exports.spriteEquals(self, sprite1, sprite2, layerID, xStart, xFinish, xIncrement, yStart, yFinish, yIncrement)
|
|
19692
|
+
do
|
|
19693
|
+
local x = xStart
|
|
19694
|
+
while x <= xFinish do
|
|
19695
|
+
do
|
|
19696
|
+
local y = yStart
|
|
19697
|
+
while y <= yFinish do
|
|
19698
|
+
local position = Vector(x, y)
|
|
19699
|
+
if not ____exports.texelEquals(
|
|
19700
|
+
nil,
|
|
19701
|
+
sprite1,
|
|
19702
|
+
sprite2,
|
|
19703
|
+
position,
|
|
19704
|
+
layerID
|
|
19705
|
+
) then
|
|
19706
|
+
return false
|
|
19707
|
+
end
|
|
19708
|
+
y = y + yIncrement
|
|
19709
|
+
end
|
|
19710
|
+
end
|
|
19711
|
+
x = x + xIncrement
|
|
19712
|
+
end
|
|
19713
|
+
end
|
|
19714
|
+
return true
|
|
19715
|
+
end
|
|
19643
19716
|
return ____exports
|
|
19644
19717
|
end,
|
|
19645
19718
|
["src.functions.entities"] = function(...)
|
|
@@ -19666,6 +19739,8 @@ local getRandom = ____random.getRandom
|
|
|
19666
19739
|
local ____rng = require("src.functions.rng")
|
|
19667
19740
|
local isRNG = ____rng.isRNG
|
|
19668
19741
|
local newRNG = ____rng.newRNG
|
|
19742
|
+
local ____sprites = require("src.functions.sprites")
|
|
19743
|
+
local setSpriteOpacity = ____sprites.setSpriteOpacity
|
|
19669
19744
|
local ____types = require("src.functions.types")
|
|
19670
19745
|
local asNumber = ____types.asNumber
|
|
19671
19746
|
local isPrimitive = ____types.isPrimitive
|
|
@@ -19930,6 +20005,10 @@ end
|
|
|
19930
20005
|
function ____exports.setEntityDamageFlash(self, entity)
|
|
19931
20006
|
entity:SetColor(DAMAGE_FLASH_COLOR, 2, 0)
|
|
19932
20007
|
end
|
|
20008
|
+
function ____exports.setEntityOpacity(self, entity, alpha)
|
|
20009
|
+
local sprite = entity:GetSprite()
|
|
20010
|
+
setSpriteOpacity(nil, sprite, alpha)
|
|
20011
|
+
end
|
|
19933
20012
|
function ____exports.setEntityRandomColor(self, entity)
|
|
19934
20013
|
local rng = newRNG(nil, entity.InitSeed)
|
|
19935
20014
|
local r = getRandom(nil, rng)
|
|
@@ -20899,72 +20978,6 @@ function ____exports.setRoomData(self, roomGridIndex, roomData)
|
|
|
20899
20978
|
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
20900
20979
|
roomDescriptor.Data = roomData
|
|
20901
20980
|
end
|
|
20902
|
-
return ____exports
|
|
20903
|
-
end,
|
|
20904
|
-
["src.functions.sprites"] = function(...)
|
|
20905
|
-
local ____exports = {}
|
|
20906
|
-
local ____constants = require("src.core.constants")
|
|
20907
|
-
local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
|
|
20908
|
-
local VectorZero = ____constants.VectorZero
|
|
20909
|
-
local ____kColor = require("src.functions.kColor")
|
|
20910
|
-
local kColorEquals = ____kColor.kColorEquals
|
|
20911
|
-
local ____utils = require("src.functions.utils")
|
|
20912
|
-
local eRange = ____utils.eRange
|
|
20913
|
-
function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
|
|
20914
|
-
local kColor1 = sprite1:GetTexel(position, VectorZero, 1, layerID)
|
|
20915
|
-
local kColor2 = sprite2:GetTexel(position, VectorZero, 1, layerID)
|
|
20916
|
-
return kColorEquals(nil, kColor1, kColor2)
|
|
20917
|
-
end
|
|
20918
|
-
function ____exports.clearSprite(self, sprite, ...)
|
|
20919
|
-
local layerIDs = {...}
|
|
20920
|
-
if #layerIDs == 0 then
|
|
20921
|
-
local numLayers = sprite:GetLayerCount()
|
|
20922
|
-
layerIDs = eRange(nil, numLayers)
|
|
20923
|
-
end
|
|
20924
|
-
for ____, layerID in ipairs(layerIDs) do
|
|
20925
|
-
sprite:ReplaceSpritesheet(layerID, EMPTY_PNG_PATH)
|
|
20926
|
-
end
|
|
20927
|
-
sprite:LoadGraphics()
|
|
20928
|
-
end
|
|
20929
|
-
function ____exports.getLastFrameOfAnimation(self, sprite, animation)
|
|
20930
|
-
local currentAnimation = sprite:GetAnimation()
|
|
20931
|
-
local currentFrame = sprite:GetFrame()
|
|
20932
|
-
if animation ~= nil and animation ~= currentAnimation then
|
|
20933
|
-
sprite:SetAnimation(animation)
|
|
20934
|
-
end
|
|
20935
|
-
sprite:SetLastFrame()
|
|
20936
|
-
local finalFrame = sprite:GetFrame()
|
|
20937
|
-
if animation ~= nil and animation ~= currentAnimation then
|
|
20938
|
-
sprite:Play(currentAnimation, true)
|
|
20939
|
-
end
|
|
20940
|
-
sprite:SetFrame(currentFrame)
|
|
20941
|
-
return finalFrame
|
|
20942
|
-
end
|
|
20943
|
-
function ____exports.spriteEquals(self, sprite1, sprite2, layerID, xStart, xFinish, xIncrement, yStart, yFinish, yIncrement)
|
|
20944
|
-
do
|
|
20945
|
-
local x = xStart
|
|
20946
|
-
while x <= xFinish do
|
|
20947
|
-
do
|
|
20948
|
-
local y = yStart
|
|
20949
|
-
while y <= yFinish do
|
|
20950
|
-
local position = Vector(x, y)
|
|
20951
|
-
if not ____exports.texelEquals(
|
|
20952
|
-
nil,
|
|
20953
|
-
sprite1,
|
|
20954
|
-
sprite2,
|
|
20955
|
-
position,
|
|
20956
|
-
layerID
|
|
20957
|
-
) then
|
|
20958
|
-
return false
|
|
20959
|
-
end
|
|
20960
|
-
y = y + yIncrement
|
|
20961
|
-
end
|
|
20962
|
-
end
|
|
20963
|
-
x = x + xIncrement
|
|
20964
|
-
end
|
|
20965
|
-
end
|
|
20966
|
-
return true
|
|
20967
|
-
end
|
|
20968
20981
|
return ____exports
|
|
20969
20982
|
end,
|
|
20970
20983
|
["src.functions.collectibles"] = function(...)
|
|
@@ -34209,17 +34222,12 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescri
|
|
|
34209
34222
|
local EntityGridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityGridCollisionClass
|
|
34210
34223
|
local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
|
|
34211
34224
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
34212
|
-
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
|
|
34213
|
-
local ____cachedClasses = require("src.core.cachedClasses")
|
|
34214
|
-
local game = ____cachedClasses.game
|
|
34215
34225
|
local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
|
|
34216
34226
|
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
34217
34227
|
local ____SlotDestructionType = require("src.enums.SlotDestructionType")
|
|
34218
34228
|
local SlotDestructionType = ____SlotDestructionType.SlotDestructionType
|
|
34219
34229
|
local ____slots = require("src.functions.slots")
|
|
34220
34230
|
local isSlotMachine = ____slots.isSlotMachine
|
|
34221
|
-
local ____vector = require("src.functions.vector")
|
|
34222
|
-
local vectorEquals = ____vector.vectorEquals
|
|
34223
34231
|
local ____Feature = require("src.classes.private.Feature")
|
|
34224
34232
|
local Feature = ____Feature.Feature
|
|
34225
34233
|
____exports.SlotDestroyedDetection = __TS__Class()
|
|
@@ -34228,23 +34236,7 @@ SlotDestroyedDetection.name = "SlotDestroyedDetection"
|
|
|
34228
34236
|
__TS__ClassExtends(SlotDestroyedDetection, Feature)
|
|
34229
34237
|
function SlotDestroyedDetection.prototype.____constructor(self, postSlotDestroyed, roomHistory)
|
|
34230
34238
|
Feature.prototype.____constructor(self)
|
|
34231
|
-
self.v = {room = {
|
|
34232
|
-
destroyedSlotSet = __TS__New(Set),
|
|
34233
|
-
despawnedSlots = {}
|
|
34234
|
-
}}
|
|
34235
|
-
self.postPickupInitCollectible = function(____, pickup)
|
|
34236
|
-
local gameFrameCount = game:GetFrameCount()
|
|
34237
|
-
for ____, despawnedSlotTuple in ipairs(self.v.room.despawnedSlots) do
|
|
34238
|
-
local gameFrame, position, entityPtr = table.unpack(despawnedSlotTuple)
|
|
34239
|
-
if gameFrame == gameFrameCount and vectorEquals(nil, position, pickup.Position) then
|
|
34240
|
-
local entity = entityPtr.Ref
|
|
34241
|
-
if entity ~= nil then
|
|
34242
|
-
local slot = entity
|
|
34243
|
-
self.postSlotDestroyed:fire(slot, SlotDestructionType.COLLECTIBLE_PAYOUT)
|
|
34244
|
-
end
|
|
34245
|
-
end
|
|
34246
|
-
end
|
|
34247
|
-
end
|
|
34239
|
+
self.v = {room = {destroyedSlotSet = __TS__New(Set)}}
|
|
34248
34240
|
self.postEntityRemoveSlot = function(____, entity)
|
|
34249
34241
|
local slot = entity
|
|
34250
34242
|
if self.roomHistory:isLeavingRoom() then
|
|
@@ -34264,17 +34256,13 @@ function SlotDestroyedDetection.prototype.____constructor(self, postSlotDestroye
|
|
|
34264
34256
|
end
|
|
34265
34257
|
self:checkDestroyedFromCollisionClass(slot)
|
|
34266
34258
|
end
|
|
34267
|
-
self.callbacksUsed = {{ModCallback.
|
|
34259
|
+
self.callbacksUsed = {{ModCallback.POST_ENTITY_REMOVE, self.postEntityRemoveSlot, {EntityType.SLOT}}}
|
|
34268
34260
|
self.customCallbacksUsed = {{ModCallbackCustom.POST_SLOT_UPDATE, self.postSlotUpdate}}
|
|
34269
34261
|
self.postSlotDestroyed = postSlotDestroyed
|
|
34270
34262
|
self.roomHistory = roomHistory
|
|
34271
34263
|
end
|
|
34272
34264
|
function SlotDestroyedDetection.prototype.postEntityRemoveSlotMachine(self, slot)
|
|
34273
|
-
|
|
34274
|
-
local entityPtr = EntityPtr(slot)
|
|
34275
|
-
local despawnedSlotTuple = {gameFrameCount, slot.Position, entityPtr}
|
|
34276
|
-
local ____self_v_room_despawnedSlots_0 = self.v.room.despawnedSlots
|
|
34277
|
-
____self_v_room_despawnedSlots_0[#____self_v_room_despawnedSlots_0 + 1] = despawnedSlotTuple
|
|
34265
|
+
self.postSlotDestroyed:fire(slot, SlotDestructionType.COLLECTIBLE_PAYOUT)
|
|
34278
34266
|
end
|
|
34279
34267
|
function SlotDestroyedDetection.prototype.postEntityRemoveBeggar(self, slot)
|
|
34280
34268
|
local sprite = slot:GetSprite()
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
-
/// <reference types="isaac-typescript-definitions" />
|
|
4
1
|
import { PostSlotDestroyed } from "../../callbacks/PostSlotDestroyed";
|
|
5
2
|
import { Feature } from "../../private/Feature";
|
|
6
3
|
import { RoomHistory } from "../other/RoomHistory";
|
|
7
|
-
type DespawnedSlotTuple = [
|
|
8
|
-
gameFrame: int,
|
|
9
|
-
position: Vector,
|
|
10
|
-
entityPtr: EntityPtr
|
|
11
|
-
];
|
|
12
4
|
export declare class SlotDestroyedDetection extends Feature {
|
|
13
5
|
v: {
|
|
14
6
|
room: {
|
|
15
7
|
destroyedSlotSet: Set<PtrHash>;
|
|
16
|
-
despawnedSlots: DespawnedSlotTuple[];
|
|
17
8
|
};
|
|
18
9
|
};
|
|
19
10
|
private postSlotDestroyed;
|
|
20
11
|
private roomHistory;
|
|
21
12
|
constructor(postSlotDestroyed: PostSlotDestroyed, roomHistory: RoomHistory);
|
|
22
|
-
private postPickupInitCollectible;
|
|
23
13
|
private postEntityRemoveSlot;
|
|
24
14
|
private postEntityRemoveSlotMachine;
|
|
25
15
|
private postEntityRemoveBeggar;
|
|
@@ -32,5 +22,4 @@ export declare class SlotDestroyedDetection extends Feature {
|
|
|
32
22
|
*/
|
|
33
23
|
private checkDestroyedFromCollisionClass;
|
|
34
24
|
}
|
|
35
|
-
export {};
|
|
36
25
|
//# sourceMappingURL=SlotDestroyedDetection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlotDestroyedDetection.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/callbackLogic/SlotDestroyedDetection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SlotDestroyedDetection.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/callbackLogic/SlotDestroyedDetection.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,sBAAuB,SAAQ,OAAO;IACjC,CAAC;;;;MAIf;IAEF,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,WAAW,CAAc;gBAErB,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW;IAsB1E,OAAO,CAAC,oBAAoB,CAc1B;IAEF,OAAO,CAAC,2BAA2B;IAInC,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,cAAc,CASpB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,gCAAgC;CAOzC"}
|
|
@@ -8,17 +8,12 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
|
|
|
8
8
|
local EntityGridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.EntityGridCollisionClass
|
|
9
9
|
local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
|
|
10
10
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
11
|
-
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
|
|
12
|
-
local ____cachedClasses = require("src.core.cachedClasses")
|
|
13
|
-
local game = ____cachedClasses.game
|
|
14
11
|
local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
|
|
15
12
|
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
|
|
16
13
|
local ____SlotDestructionType = require("src.enums.SlotDestructionType")
|
|
17
14
|
local SlotDestructionType = ____SlotDestructionType.SlotDestructionType
|
|
18
15
|
local ____slots = require("src.functions.slots")
|
|
19
16
|
local isSlotMachine = ____slots.isSlotMachine
|
|
20
|
-
local ____vector = require("src.functions.vector")
|
|
21
|
-
local vectorEquals = ____vector.vectorEquals
|
|
22
17
|
local ____Feature = require("src.classes.private.Feature")
|
|
23
18
|
local Feature = ____Feature.Feature
|
|
24
19
|
____exports.SlotDestroyedDetection = __TS__Class()
|
|
@@ -27,23 +22,7 @@ SlotDestroyedDetection.name = "SlotDestroyedDetection"
|
|
|
27
22
|
__TS__ClassExtends(SlotDestroyedDetection, Feature)
|
|
28
23
|
function SlotDestroyedDetection.prototype.____constructor(self, postSlotDestroyed, roomHistory)
|
|
29
24
|
Feature.prototype.____constructor(self)
|
|
30
|
-
self.v = {room = {
|
|
31
|
-
destroyedSlotSet = __TS__New(Set),
|
|
32
|
-
despawnedSlots = {}
|
|
33
|
-
}}
|
|
34
|
-
self.postPickupInitCollectible = function(____, pickup)
|
|
35
|
-
local gameFrameCount = game:GetFrameCount()
|
|
36
|
-
for ____, despawnedSlotTuple in ipairs(self.v.room.despawnedSlots) do
|
|
37
|
-
local gameFrame, position, entityPtr = table.unpack(despawnedSlotTuple)
|
|
38
|
-
if gameFrame == gameFrameCount and vectorEquals(nil, position, pickup.Position) then
|
|
39
|
-
local entity = entityPtr.Ref
|
|
40
|
-
if entity ~= nil then
|
|
41
|
-
local slot = entity
|
|
42
|
-
self.postSlotDestroyed:fire(slot, SlotDestructionType.COLLECTIBLE_PAYOUT)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
25
|
+
self.v = {room = {destroyedSlotSet = __TS__New(Set)}}
|
|
47
26
|
self.postEntityRemoveSlot = function(____, entity)
|
|
48
27
|
local slot = entity
|
|
49
28
|
if self.roomHistory:isLeavingRoom() then
|
|
@@ -63,17 +42,13 @@ function SlotDestroyedDetection.prototype.____constructor(self, postSlotDestroye
|
|
|
63
42
|
end
|
|
64
43
|
self:checkDestroyedFromCollisionClass(slot)
|
|
65
44
|
end
|
|
66
|
-
self.callbacksUsed = {{ModCallback.
|
|
45
|
+
self.callbacksUsed = {{ModCallback.POST_ENTITY_REMOVE, self.postEntityRemoveSlot, {EntityType.SLOT}}}
|
|
67
46
|
self.customCallbacksUsed = {{ModCallbackCustom.POST_SLOT_UPDATE, self.postSlotUpdate}}
|
|
68
47
|
self.postSlotDestroyed = postSlotDestroyed
|
|
69
48
|
self.roomHistory = roomHistory
|
|
70
49
|
end
|
|
71
50
|
function SlotDestroyedDetection.prototype.postEntityRemoveSlotMachine(self, slot)
|
|
72
|
-
|
|
73
|
-
local entityPtr = EntityPtr(slot)
|
|
74
|
-
local despawnedSlotTuple = {gameFrameCount, slot.Position, entityPtr}
|
|
75
|
-
local ____self_v_room_despawnedSlots_0 = self.v.room.despawnedSlots
|
|
76
|
-
____self_v_room_despawnedSlots_0[#____self_v_room_despawnedSlots_0 + 1] = despawnedSlotTuple
|
|
51
|
+
self.postSlotDestroyed:fire(slot, SlotDestructionType.COLLECTIBLE_PAYOUT)
|
|
77
52
|
end
|
|
78
53
|
function SlotDestroyedDetection.prototype.postEntityRemoveBeggar(self, slot)
|
|
79
54
|
local sprite = slot:GetSprite()
|
|
@@ -1536,8 +1536,35 @@ export declare enum ModCallbackCustom {
|
|
|
1536
1536
|
*/
|
|
1537
1537
|
POST_SLOT_COLLISION = 87,
|
|
1538
1538
|
/**
|
|
1539
|
-
* Fires from the `
|
|
1540
|
-
*
|
|
1539
|
+
* Fires from the `POST_SLOT_UPDATE` or the `POST_ENTITY_REMOVE` callback when a slot machine is
|
|
1540
|
+
* destroyed or a beggar is removed.
|
|
1541
|
+
*
|
|
1542
|
+
* This callback will fire in four different kinds of situations:
|
|
1543
|
+
*
|
|
1544
|
+
* 1. When slot machine entities (e.g. `SlotVariant.SLOT_MACHINE` and
|
|
1545
|
+
* `SlotVariant.BLOOD_DONATION_MACHINE`) are destroyed with an explosion. When this happens,
|
|
1546
|
+
* they typically stay in the room and can be pushed around. This state is detected via a
|
|
1547
|
+
* change in the `GridCollisionClass`.
|
|
1548
|
+
* 2. When slot machine entities pay out with a collectible item. When this happens, they
|
|
1549
|
+
* immediately despawn without playing any special animation.
|
|
1550
|
+
* 3. When beggar entities (e.g. `SlotVariant.BEGGAR` and `SlotVariant.SHELL_GAME`) are destroyed
|
|
1551
|
+
* with an explosion. When this happens, they immediately despawn without playing any special
|
|
1552
|
+
* animation.
|
|
1553
|
+
* 4. When beggar entities pay out with a collectible item. When this happens, they despawn after
|
|
1554
|
+
* playing the "Teleport" animation. (This is not technically a "destruction" event, but the
|
|
1555
|
+
* callback will fire for this to remain consistent with the other types of slot entities.)
|
|
1556
|
+
*
|
|
1557
|
+
* Depending on the specific types of slot removal that you need to detect, you can filter using:
|
|
1558
|
+
*
|
|
1559
|
+
* 1. The `isSlotMachine` helper function to differentiate between slot machines and beggars.
|
|
1560
|
+
* 2. The passed callback argument of `SlotDestructionType` to differentiate between bombed slots
|
|
1561
|
+
* and slots that paid out with a collectible item.
|
|
1562
|
+
*
|
|
1563
|
+
* Note that when a Crane Game explodes after paying out three collectibles, the
|
|
1564
|
+
* `SlotDestructionType` will be equal to `SlotDestructionType.NORMAL` instead of
|
|
1565
|
+
* `SlotDestructionType.COLLECTIBLE_PAYOUT` like you might expect. (This is because it only
|
|
1566
|
+
* explodes after a short delay, and when doing so, it produces rewards in the same way that would
|
|
1567
|
+
* happen if you bombed it.)
|
|
1541
1568
|
*
|
|
1542
1569
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1543
1570
|
* - You can provide an optional third argument that will make the callback only fire if it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModCallbackCustom.d.ts","sourceRoot":"","sources":["../../../src/enums/ModCallbackCustom.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,oBAAY,iBAAiB;IAC3B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,sBAAsB,IAAA;IAEtB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sBAAsB,IAAA;IAEtB;;;;;;;;;;;;;;;;;OAiBG;IACH,mBAAmB,IAAA;IAEnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,mBAAmB,IAAA;IAEnB;;;;;;;;;;;OAWG;IACH,oBAAoB,IAAA;IAEpB;;;;;;;;;;;OAWG;IACH,mBAAmB,IAAA;IAEnB;;;;;;;;;;;;OAYG;IACH,kBAAkB,IAAA;IAElB;;;;;;;;;;;;;;;OAeG;IACH,mBAAmB,IAAA;IAEnB;;;;;;OAMG;IACH,eAAe,IAAA;IAEf;;;;;;;;;;;;;;OAcG;IACH,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AgB,KAAA;IAEhB;;;;;;;;;;OAUG;IACH,kBAAkB,KAAA;IAElB;;;;;;;;;;OAUG;IACH,kBAAkB,KAAA;IAElB;;;;;;;;;;;;;;;;OAgBG;IACH,mBAAmB,KAAA;IAEnB;;;;;;;;;;;;;;;OAeG;IACH,wBAAwB,KAAA;IAExB;;;;;;;;;;OAUG;IACH,eAAe,KAAA;IAEf;;;;;;;;;;OAUG;IACH,eAAe,KAAA;IAEf;;;;;;;;;;;;;;;;;OAiBG;IACH,mBAAmB,KAAA;IAEnB;;;;;;;;;;;;;OAaG;IACH,kBAAkB,KAAA;IAElB;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,MAAA;IAEjB;;;;;;;;;;;;;;;;;OAiBG;IACH,iBAAiB,MAAA;IAEjB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,uBAAuB,MAAA;IAEvB;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,MAAA;IAEhB;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,MAAA;IAEf;;;;;;;;;;;;OAYG;IACH,aAAa,MAAA;IAEb;;;;;;;;;;;;;;;;;;;OAmBG;IACH,wBAAwB,MAAA;IAExB;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB,MAAA;IAErB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,4BAA4B,MAAA;CAC7B"}
|
|
@@ -172,6 +172,14 @@ export declare function rerollEnemy(entity: Entity): Entity | undefined;
|
|
|
172
172
|
* it.
|
|
173
173
|
*/
|
|
174
174
|
export declare function setEntityDamageFlash(entity: Entity): void;
|
|
175
|
+
/**
|
|
176
|
+
* Helper function to keep an entity's color the same values as it already is but set the opacity to
|
|
177
|
+
* a specific value.
|
|
178
|
+
*
|
|
179
|
+
* @param entity The entity to set.
|
|
180
|
+
* @param alpha A value between 0 and 1 that represents the fade amount.
|
|
181
|
+
*/
|
|
182
|
+
export declare function setEntityOpacity(entity: Entity, alpha: float): void;
|
|
175
183
|
export declare function setEntityRandomColor(entity: Entity): void;
|
|
176
184
|
/**
|
|
177
185
|
* Helper function to spawn an entity. Use this instead of the `Isaac.Spawn` method if you do not
|
|
@@ -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;AAK1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/functions/entities.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAK1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAmB7C;;;;;;;;;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,GACrB,OAAO,CAGT;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS,EACpD,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,CAAC,EAAE,EACb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,GAClC,CAAC,GAAG,SAAS,CAgBf;AAED,wFAAwF;AACxF,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,QAAQ,GACjB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,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,GAAG,GAAG,GAAG,SAAqB,GAC5C,MAAM,CAWR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,MAAM,GAAG,GAAG,EACjC,SAAS,EAAE,IAAI,GAAG,GAAG,EACrB,QAAQ,GAAE,MAAmB,EAC7B,OAAO,GAAE,MAAM,GAAG,SAAqB,GACtC,MAAM,CAUR"}
|
|
@@ -21,6 +21,8 @@ local getRandom = ____random.getRandom
|
|
|
21
21
|
local ____rng = require("src.functions.rng")
|
|
22
22
|
local isRNG = ____rng.isRNG
|
|
23
23
|
local newRNG = ____rng.newRNG
|
|
24
|
+
local ____sprites = require("src.functions.sprites")
|
|
25
|
+
local setSpriteOpacity = ____sprites.setSpriteOpacity
|
|
24
26
|
local ____types = require("src.functions.types")
|
|
25
27
|
local asNumber = ____types.asNumber
|
|
26
28
|
local isPrimitive = ____types.isPrimitive
|
|
@@ -403,6 +405,15 @@ end
|
|
|
403
405
|
function ____exports.setEntityDamageFlash(self, entity)
|
|
404
406
|
entity:SetColor(DAMAGE_FLASH_COLOR, 2, 0)
|
|
405
407
|
end
|
|
408
|
+
--- Helper function to keep an entity's color the same values as it already is but set the opacity to
|
|
409
|
+
-- a specific value.
|
|
410
|
+
--
|
|
411
|
+
-- @param entity The entity to set.
|
|
412
|
+
-- @param alpha A value between 0 and 1 that represents the fade amount.
|
|
413
|
+
function ____exports.setEntityOpacity(self, entity, alpha)
|
|
414
|
+
local sprite = entity:GetSprite()
|
|
415
|
+
setSpriteOpacity(nil, sprite, alpha)
|
|
416
|
+
end
|
|
406
417
|
function ____exports.setEntityRandomColor(self, entity)
|
|
407
418
|
local rng = newRNG(nil, entity.InitSeed)
|
|
408
419
|
local r = getRandom(nil, rng)
|
|
@@ -32,6 +32,14 @@ export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
|
|
|
32
32
|
* player animations.
|
|
33
33
|
*/
|
|
34
34
|
export declare function getLastFrameOfAnimation(sprite: Sprite, animation?: string): int;
|
|
35
|
+
/**
|
|
36
|
+
* Helper function to keep a sprite's color the same values as it already is but set the opacity to
|
|
37
|
+
* a specific value.
|
|
38
|
+
*
|
|
39
|
+
* @param sprite The sprite to set.
|
|
40
|
+
* @param alpha A value between 0 and 1 that represents the fade amount.
|
|
41
|
+
*/
|
|
42
|
+
export declare function setSpriteOpacity(sprite: Sprite, alpha: float): void;
|
|
35
43
|
/**
|
|
36
44
|
* Helper function to check if two sprite layers have the same sprite sheet by using the
|
|
37
45
|
* `Sprite.GetTexel` method.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/functions/sprites.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/functions/sprites.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAWpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,GAAG,CAmBL;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAInE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,EACf,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GACd,OAAO,CAaT;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,GAAG,GACX,OAAO,CAIT"}
|
|
@@ -2,6 +2,8 @@ local ____exports = {}
|
|
|
2
2
|
local ____constants = require("src.core.constants")
|
|
3
3
|
local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
|
|
4
4
|
local VectorZero = ____constants.VectorZero
|
|
5
|
+
local ____color = require("src.functions.color")
|
|
6
|
+
local copyColor = ____color.copyColor
|
|
5
7
|
local ____kColor = require("src.functions.kColor")
|
|
6
8
|
local kColorEquals = ____kColor.kColorEquals
|
|
7
9
|
local ____utils = require("src.functions.utils")
|
|
@@ -62,6 +64,16 @@ function ____exports.getLastFrameOfAnimation(self, sprite, animation)
|
|
|
62
64
|
sprite:SetFrame(currentFrame)
|
|
63
65
|
return finalFrame
|
|
64
66
|
end
|
|
67
|
+
--- Helper function to keep a sprite's color the same values as it already is but set the opacity to
|
|
68
|
+
-- a specific value.
|
|
69
|
+
--
|
|
70
|
+
-- @param sprite The sprite to set.
|
|
71
|
+
-- @param alpha A value between 0 and 1 that represents the fade amount.
|
|
72
|
+
function ____exports.setSpriteOpacity(self, sprite, alpha)
|
|
73
|
+
local fadedColor = copyColor(nil, sprite.Color)
|
|
74
|
+
fadedColor.A = alpha
|
|
75
|
+
sprite.Color = fadedColor
|
|
76
|
+
end
|
|
65
77
|
--- Helper function to check if two sprite layers have the same sprite sheet by using the
|
|
66
78
|
-- `Sprite.GetTexel` method.
|
|
67
79
|
--
|
package/package.json
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
// room.
|
|
6
6
|
|
|
7
7
|
// 2) In the specific case of a machine spawning a collectible, the machine will be immediately
|
|
8
|
-
// removed.
|
|
9
|
-
// store all despawning slots in an array and then cross reference the array when a new pickup
|
|
10
|
-
// spawns.
|
|
8
|
+
// removed. Thus, we assume that any despawning slot machine is destroyed in this way.
|
|
11
9
|
|
|
12
10
|
// For beggars, destruction is detected by monitoring for when a beggar despawns mid-room. Beggars
|
|
13
11
|
// that are paying out with a collectible will always be playing the "Teleport" animation.
|
|
@@ -17,28 +15,18 @@ import {
|
|
|
17
15
|
EntityGridCollisionClass,
|
|
18
16
|
EntityType,
|
|
19
17
|
ModCallback,
|
|
20
|
-
PickupVariant,
|
|
21
18
|
} from "isaac-typescript-definitions";
|
|
22
|
-
import { game } from "../../../core/cachedClasses";
|
|
23
19
|
import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
|
|
24
20
|
import { SlotDestructionType } from "../../../enums/SlotDestructionType";
|
|
25
21
|
import { isSlotMachine } from "../../../functions/slots";
|
|
26
|
-
import { vectorEquals } from "../../../functions/vector";
|
|
27
22
|
import { PostSlotDestroyed } from "../../callbacks/PostSlotDestroyed";
|
|
28
23
|
import { Feature } from "../../private/Feature";
|
|
29
24
|
import { RoomHistory } from "../other/RoomHistory";
|
|
30
25
|
|
|
31
|
-
type DespawnedSlotTuple = [
|
|
32
|
-
gameFrame: int,
|
|
33
|
-
position: Vector,
|
|
34
|
-
entityPtr: EntityPtr,
|
|
35
|
-
];
|
|
36
|
-
|
|
37
26
|
export class SlotDestroyedDetection extends Feature {
|
|
38
27
|
public override v = {
|
|
39
28
|
room: {
|
|
40
29
|
destroyedSlotSet: new Set<PtrHash>(),
|
|
41
|
-
despawnedSlots: [] as DespawnedSlotTuple[],
|
|
42
30
|
},
|
|
43
31
|
};
|
|
44
32
|
|
|
@@ -49,13 +37,6 @@ export class SlotDestroyedDetection extends Feature {
|
|
|
49
37
|
super();
|
|
50
38
|
|
|
51
39
|
this.callbacksUsed = [
|
|
52
|
-
// 34
|
|
53
|
-
[
|
|
54
|
-
ModCallback.POST_PICKUP_INIT,
|
|
55
|
-
this.postPickupInitCollectible,
|
|
56
|
-
[PickupVariant.COLLECTIBLE],
|
|
57
|
-
],
|
|
58
|
-
|
|
59
40
|
// 67
|
|
60
41
|
[
|
|
61
42
|
ModCallback.POST_ENTITY_REMOVE,
|
|
@@ -72,30 +53,6 @@ export class SlotDestroyedDetection extends Feature {
|
|
|
72
53
|
this.roomHistory = roomHistory;
|
|
73
54
|
}
|
|
74
55
|
|
|
75
|
-
// ModCallback.POST_PICKUP_INIT (34)
|
|
76
|
-
// PickupVariant.COLLECTIBLE (100)
|
|
77
|
-
private postPickupInitCollectible = (pickup: EntityPickup) => {
|
|
78
|
-
const gameFrameCount = game.GetFrameCount();
|
|
79
|
-
|
|
80
|
-
// Go through the despawning slots to see if they match this pickup.
|
|
81
|
-
for (const despawnedSlotTuple of this.v.room.despawnedSlots) {
|
|
82
|
-
const [gameFrame, position, entityPtr] = despawnedSlotTuple;
|
|
83
|
-
if (
|
|
84
|
-
gameFrame === gameFrameCount &&
|
|
85
|
-
vectorEquals(position, pickup.Position)
|
|
86
|
-
) {
|
|
87
|
-
const entity = entityPtr.Ref;
|
|
88
|
-
if (entity !== undefined) {
|
|
89
|
-
const slot = entity as EntitySlot;
|
|
90
|
-
this.postSlotDestroyed.fire(
|
|
91
|
-
slot,
|
|
92
|
-
SlotDestructionType.COLLECTIBLE_PAYOUT,
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
56
|
// ModCallback.POST_ENTITY_REMOVE (67)
|
|
100
57
|
// EntityType.SLOT (6)
|
|
101
58
|
private postEntityRemoveSlot = (entity: Entity) => {
|
|
@@ -115,14 +72,7 @@ export class SlotDestroyedDetection extends Feature {
|
|
|
115
72
|
};
|
|
116
73
|
|
|
117
74
|
private postEntityRemoveSlotMachine(slot: EntitySlot) {
|
|
118
|
-
|
|
119
|
-
const entityPtr = EntityPtr(slot);
|
|
120
|
-
const despawnedSlotTuple: DespawnedSlotTuple = [
|
|
121
|
-
gameFrameCount,
|
|
122
|
-
slot.Position,
|
|
123
|
-
entityPtr,
|
|
124
|
-
];
|
|
125
|
-
this.v.room.despawnedSlots.push(despawnedSlotTuple);
|
|
75
|
+
this.postSlotDestroyed.fire(slot, SlotDestructionType.COLLECTIBLE_PAYOUT);
|
|
126
76
|
}
|
|
127
77
|
|
|
128
78
|
private postEntityRemoveBeggar(slot: EntitySlot) {
|
|
@@ -1636,8 +1636,35 @@ export enum ModCallbackCustom {
|
|
|
1636
1636
|
POST_SLOT_COLLISION,
|
|
1637
1637
|
|
|
1638
1638
|
/**
|
|
1639
|
-
* Fires from the `
|
|
1640
|
-
*
|
|
1639
|
+
* Fires from the `POST_SLOT_UPDATE` or the `POST_ENTITY_REMOVE` callback when a slot machine is
|
|
1640
|
+
* destroyed or a beggar is removed.
|
|
1641
|
+
*
|
|
1642
|
+
* This callback will fire in four different kinds of situations:
|
|
1643
|
+
*
|
|
1644
|
+
* 1. When slot machine entities (e.g. `SlotVariant.SLOT_MACHINE` and
|
|
1645
|
+
* `SlotVariant.BLOOD_DONATION_MACHINE`) are destroyed with an explosion. When this happens,
|
|
1646
|
+
* they typically stay in the room and can be pushed around. This state is detected via a
|
|
1647
|
+
* change in the `GridCollisionClass`.
|
|
1648
|
+
* 2. When slot machine entities pay out with a collectible item. When this happens, they
|
|
1649
|
+
* immediately despawn without playing any special animation.
|
|
1650
|
+
* 3. When beggar entities (e.g. `SlotVariant.BEGGAR` and `SlotVariant.SHELL_GAME`) are destroyed
|
|
1651
|
+
* with an explosion. When this happens, they immediately despawn without playing any special
|
|
1652
|
+
* animation.
|
|
1653
|
+
* 4. When beggar entities pay out with a collectible item. When this happens, they despawn after
|
|
1654
|
+
* playing the "Teleport" animation. (This is not technically a "destruction" event, but the
|
|
1655
|
+
* callback will fire for this to remain consistent with the other types of slot entities.)
|
|
1656
|
+
*
|
|
1657
|
+
* Depending on the specific types of slot removal that you need to detect, you can filter using:
|
|
1658
|
+
*
|
|
1659
|
+
* 1. The `isSlotMachine` helper function to differentiate between slot machines and beggars.
|
|
1660
|
+
* 2. The passed callback argument of `SlotDestructionType` to differentiate between bombed slots
|
|
1661
|
+
* and slots that paid out with a collectible item.
|
|
1662
|
+
*
|
|
1663
|
+
* Note that when a Crane Game explodes after paying out three collectibles, the
|
|
1664
|
+
* `SlotDestructionType` will be equal to `SlotDestructionType.NORMAL` instead of
|
|
1665
|
+
* `SlotDestructionType.COLLECTIBLE_PAYOUT` like you might expect. (This is because it only
|
|
1666
|
+
* explodes after a short delay, and when doing so, it produces rewards in the same way that would
|
|
1667
|
+
* happen if you bombed it.)
|
|
1641
1668
|
*
|
|
1642
1669
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1643
1670
|
* - You can provide an optional third argument that will make the callback only fire if it
|
|
@@ -8,6 +8,7 @@ import { EntityID } from "../types/EntityID";
|
|
|
8
8
|
import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
9
9
|
import { getRandom } from "./random";
|
|
10
10
|
import { isRNG, newRNG } from "./rng";
|
|
11
|
+
import { setSpriteOpacity } from "./sprites";
|
|
11
12
|
import { asNumber, isPrimitive } from "./types";
|
|
12
13
|
import { isVector, vectorToString } from "./vector";
|
|
13
14
|
|
|
@@ -477,6 +478,18 @@ export function setEntityDamageFlash(entity: Entity): void {
|
|
|
477
478
|
entity.SetColor(DAMAGE_FLASH_COLOR, 2, 0);
|
|
478
479
|
}
|
|
479
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Helper function to keep an entity's color the same values as it already is but set the opacity to
|
|
483
|
+
* a specific value.
|
|
484
|
+
*
|
|
485
|
+
* @param entity The entity to set.
|
|
486
|
+
* @param alpha A value between 0 and 1 that represents the fade amount.
|
|
487
|
+
*/
|
|
488
|
+
export function setEntityOpacity(entity: Entity, alpha: float): void {
|
|
489
|
+
const sprite = entity.GetSprite();
|
|
490
|
+
setSpriteOpacity(sprite, alpha);
|
|
491
|
+
}
|
|
492
|
+
|
|
480
493
|
export function setEntityRandomColor(entity: Entity): void {
|
|
481
494
|
const rng = newRNG(entity.InitSeed);
|
|
482
495
|
|
package/src/functions/sprites.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EMPTY_PNG_PATH, VectorZero } from "../core/constants";
|
|
2
|
+
import { copyColor } from "./color";
|
|
2
3
|
import { kColorEquals } from "./kColor";
|
|
3
4
|
import { eRange } from "./utils";
|
|
4
5
|
|
|
@@ -68,6 +69,19 @@ export function getLastFrameOfAnimation(
|
|
|
68
69
|
return finalFrame;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Helper function to keep a sprite's color the same values as it already is but set the opacity to
|
|
74
|
+
* a specific value.
|
|
75
|
+
*
|
|
76
|
+
* @param sprite The sprite to set.
|
|
77
|
+
* @param alpha A value between 0 and 1 that represents the fade amount.
|
|
78
|
+
*/
|
|
79
|
+
export function setSpriteOpacity(sprite: Sprite, alpha: float): void {
|
|
80
|
+
const fadedColor = copyColor(sprite.Color);
|
|
81
|
+
fadedColor.A = alpha;
|
|
82
|
+
sprite.Color = fadedColor;
|
|
83
|
+
}
|
|
84
|
+
|
|
71
85
|
/**
|
|
72
86
|
* Helper function to check if two sprite layers have the same sprite sheet by using the
|
|
73
87
|
* `Sprite.GetTexel` method.
|