isaacscript-common 20.17.0 → 20.18.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
CHANGED
|
@@ -3269,6 +3269,16 @@ declare class DisableInputs extends Feature {
|
|
|
3269
3269
|
/** This is also the distance that a player spawns from the door that they enter a room from. */
|
|
3270
3270
|
export declare const DISTANCE_OF_GRID_TILE = 40;
|
|
3271
3271
|
|
|
3272
|
+
/**
|
|
3273
|
+
* Helper function to check if one or more matching entities exist in the current room. It uses the
|
|
3274
|
+
* `doesEntityExist` helper function to determine this.
|
|
3275
|
+
*
|
|
3276
|
+
* @param entityTypes An array or set of the entity types that you want to check for. Will return
|
|
3277
|
+
* true if any of the provided entity types exist.
|
|
3278
|
+
* @param ignoreFriendly Optional. Default is false.
|
|
3279
|
+
*/
|
|
3280
|
+
export declare function doesAnyEntityExist(entityTypes: EntityType[] | readonly EntityType[] | Set<EntityType> | ReadonlySet<EntityType>, ignoreFriendly?: boolean): boolean;
|
|
3281
|
+
|
|
3272
3282
|
/**
|
|
3273
3283
|
* Helper function to check if one or more of a specific kind of entity is present in the current
|
|
3274
3284
|
* room. It uses the `countEntities` helper function to determine this.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 20.
|
|
3
|
+
isaacscript-common 20.18.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -19715,13 +19715,167 @@ function ____exports.spriteEquals(self, sprite1, sprite2, layerID, xStart, xFini
|
|
|
19715
19715
|
end
|
|
19716
19716
|
return true
|
|
19717
19717
|
end
|
|
19718
|
+
return ____exports
|
|
19719
|
+
end,
|
|
19720
|
+
["src.classes.DefaultMap"] = function(...)
|
|
19721
|
+
local ____lualib = require("lualib_bundle")
|
|
19722
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
19723
|
+
local Map = ____lualib.Map
|
|
19724
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
19725
|
+
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
19726
|
+
local __TS__New = ____lualib.__TS__New
|
|
19727
|
+
local ____exports = {}
|
|
19728
|
+
local ____types = require("src.functions.types")
|
|
19729
|
+
local isFunction = ____types.isFunction
|
|
19730
|
+
local isPrimitive = ____types.isPrimitive
|
|
19731
|
+
____exports.DefaultMap = __TS__Class()
|
|
19732
|
+
local DefaultMap = ____exports.DefaultMap
|
|
19733
|
+
DefaultMap.name = "DefaultMap"
|
|
19734
|
+
__TS__ClassExtends(DefaultMap, Map)
|
|
19735
|
+
function DefaultMap.prototype.____constructor(self, defaultValueOrFactoryFunction, initializerArray)
|
|
19736
|
+
local argIsPrimitive = isPrimitive(nil, defaultValueOrFactoryFunction)
|
|
19737
|
+
local argIsFunction = isFunction(nil, defaultValueOrFactoryFunction)
|
|
19738
|
+
if not argIsPrimitive and not argIsFunction then
|
|
19739
|
+
error(("Failed to instantiate a DefaultMap since the provided default value was of type \"" .. __TS__TypeOf(defaultValueOrFactoryFunction)) .. "\". This error usually means that you are trying to use an array (or some other non-primitive data structure that is passed by reference) as the default value. Instead, return the data structure in a factory function, like \"() => []\". See the DefaultMap documentation for more details.")
|
|
19740
|
+
end
|
|
19741
|
+
Map.prototype.____constructor(self, initializerArray)
|
|
19742
|
+
if argIsFunction then
|
|
19743
|
+
self.defaultValue = nil
|
|
19744
|
+
self.defaultValueFactory = defaultValueOrFactoryFunction
|
|
19745
|
+
else
|
|
19746
|
+
self.defaultValue = defaultValueOrFactoryFunction
|
|
19747
|
+
self.defaultValueFactory = nil
|
|
19748
|
+
end
|
|
19749
|
+
end
|
|
19750
|
+
function DefaultMap.prototype.getAndSetDefault(self, key, ...)
|
|
19751
|
+
local value = Map.prototype.get(self, key)
|
|
19752
|
+
if value ~= nil then
|
|
19753
|
+
return value
|
|
19754
|
+
end
|
|
19755
|
+
local defaultValue = self:getDefaultValue(...)
|
|
19756
|
+
self:set(key, defaultValue)
|
|
19757
|
+
return defaultValue
|
|
19758
|
+
end
|
|
19759
|
+
function DefaultMap.prototype.getDefaultValue(self, ...)
|
|
19760
|
+
if self.defaultValue ~= nil then
|
|
19761
|
+
return self.defaultValue
|
|
19762
|
+
end
|
|
19763
|
+
if self.defaultValueFactory ~= nil then
|
|
19764
|
+
return self:defaultValueFactory(...)
|
|
19765
|
+
end
|
|
19766
|
+
error("A DefaultMap was incorrectly instantiated.")
|
|
19767
|
+
end
|
|
19768
|
+
function DefaultMap.prototype.getConstructorArg(self)
|
|
19769
|
+
if self.defaultValue ~= nil then
|
|
19770
|
+
return self.defaultValue
|
|
19771
|
+
end
|
|
19772
|
+
if self.defaultValueFactory ~= nil then
|
|
19773
|
+
return self.defaultValueFactory
|
|
19774
|
+
end
|
|
19775
|
+
error("A DefaultMap was incorrectly instantiated.")
|
|
19776
|
+
end
|
|
19777
|
+
local function test(self)
|
|
19778
|
+
local myDefaultMapBoolean = __TS__New(____exports.DefaultMap, false)
|
|
19779
|
+
local myDefaultMapBooleanFactory = __TS__New(
|
|
19780
|
+
____exports.DefaultMap,
|
|
19781
|
+
function() return false end
|
|
19782
|
+
)
|
|
19783
|
+
local myDefaultMapBooleanWithoutParams = __TS__New(____exports.DefaultMap, false)
|
|
19784
|
+
local myDefaultMapNumber = __TS__New(____exports.DefaultMap, 123)
|
|
19785
|
+
local myDefaultMapNumberFactory = __TS__New(
|
|
19786
|
+
____exports.DefaultMap,
|
|
19787
|
+
function() return 123 end
|
|
19788
|
+
)
|
|
19789
|
+
local myDefaultMapNumberWithoutParams = __TS__New(____exports.DefaultMap, 123)
|
|
19790
|
+
local myDefaultMapString = __TS__New(____exports.DefaultMap, "foo")
|
|
19791
|
+
local myDefaultMapStringFactory = __TS__New(
|
|
19792
|
+
____exports.DefaultMap,
|
|
19793
|
+
function() return "foo" end
|
|
19794
|
+
)
|
|
19795
|
+
local myDefaultMapStringWithoutParams = __TS__New(____exports.DefaultMap, "foo")
|
|
19796
|
+
local myDefaultMapArray = __TS__New(
|
|
19797
|
+
____exports.DefaultMap,
|
|
19798
|
+
function() return {} end
|
|
19799
|
+
)
|
|
19800
|
+
local myDefaultMapArrayWithoutParams = __TS__New(
|
|
19801
|
+
____exports.DefaultMap,
|
|
19802
|
+
function() return {} end
|
|
19803
|
+
)
|
|
19804
|
+
local myDefaultMapMap = __TS__New(
|
|
19805
|
+
____exports.DefaultMap,
|
|
19806
|
+
function() return __TS__New(Map) end
|
|
19807
|
+
)
|
|
19808
|
+
local myDefaultMapMapWithoutParams = __TS__New(
|
|
19809
|
+
____exports.DefaultMap,
|
|
19810
|
+
function() return __TS__New(Map) end
|
|
19811
|
+
)
|
|
19812
|
+
end
|
|
19813
|
+
return ____exports
|
|
19814
|
+
end,
|
|
19815
|
+
["src.interfaces.TSTLClassMetatable"] = function(...)
|
|
19816
|
+
local ____exports = {}
|
|
19817
|
+
return ____exports
|
|
19818
|
+
end,
|
|
19819
|
+
["src.types.TSTLClass"] = function(...)
|
|
19820
|
+
local ____exports = {}
|
|
19821
|
+
return ____exports
|
|
19822
|
+
end,
|
|
19823
|
+
["src.functions.tstlClass"] = function(...)
|
|
19824
|
+
local ____exports = {}
|
|
19825
|
+
local ____types = require("src.functions.types")
|
|
19826
|
+
local isTable = ____types.isTable
|
|
19827
|
+
function ____exports.getTSTLClassConstructor(self, object)
|
|
19828
|
+
if not isTable(nil, object) then
|
|
19829
|
+
return nil
|
|
19830
|
+
end
|
|
19831
|
+
local metatable = getmetatable(object)
|
|
19832
|
+
if metatable == nil then
|
|
19833
|
+
return nil
|
|
19834
|
+
end
|
|
19835
|
+
return metatable.constructor
|
|
19836
|
+
end
|
|
19837
|
+
function ____exports.getTSTLClassName(self, object)
|
|
19838
|
+
local constructor = ____exports.getTSTLClassConstructor(nil, object)
|
|
19839
|
+
if constructor == nil then
|
|
19840
|
+
return nil
|
|
19841
|
+
end
|
|
19842
|
+
return constructor.name
|
|
19843
|
+
end
|
|
19844
|
+
function ____exports.isDefaultMap(self, object)
|
|
19845
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
19846
|
+
return className == "DefaultMap"
|
|
19847
|
+
end
|
|
19848
|
+
function ____exports.isTSTLClass(self, object)
|
|
19849
|
+
local tstlClassName = ____exports.getTSTLClassName(nil, object)
|
|
19850
|
+
return tstlClassName ~= nil
|
|
19851
|
+
end
|
|
19852
|
+
function ____exports.isTSTLMap(self, object)
|
|
19853
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
19854
|
+
return className == "Map"
|
|
19855
|
+
end
|
|
19856
|
+
function ____exports.isTSTLSet(self, object)
|
|
19857
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
19858
|
+
return className == "Set"
|
|
19859
|
+
end
|
|
19860
|
+
function ____exports.newTSTLClass(self, oldClass)
|
|
19861
|
+
local constructor = ____exports.getTSTLClassConstructor(nil, oldClass)
|
|
19862
|
+
if constructor == nil then
|
|
19863
|
+
error("Failed to instantiate a new TypeScriptToLua class since the provided old class does not have a metatable/constructor.")
|
|
19864
|
+
end
|
|
19865
|
+
local newClass = {}
|
|
19866
|
+
local newClassMetatable = setmetatable(newClass, constructor.prototype)
|
|
19867
|
+
newClassMetatable:____constructor()
|
|
19868
|
+
return newClass
|
|
19869
|
+
end
|
|
19718
19870
|
return ____exports
|
|
19719
19871
|
end,
|
|
19720
19872
|
["src.functions.entities"] = function(...)
|
|
19721
19873
|
local ____lualib = require("lualib_bundle")
|
|
19874
|
+
local Set = ____lualib.Set
|
|
19875
|
+
local __TS__Spread = ____lualib.__TS__Spread
|
|
19876
|
+
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
19722
19877
|
local __TS__StringSplit = ____lualib.__TS__StringSplit
|
|
19723
19878
|
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
19724
|
-
local Set = ____lualib.Set
|
|
19725
19879
|
local __TS__New = ____lualib.__TS__New
|
|
19726
19880
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
19727
19881
|
local ____exports = {}
|
|
@@ -19743,6 +19897,8 @@ local isRNG = ____rng.isRNG
|
|
|
19743
19897
|
local newRNG = ____rng.newRNG
|
|
19744
19898
|
local ____sprites = require("src.functions.sprites")
|
|
19745
19899
|
local setSpriteOpacity = ____sprites.setSpriteOpacity
|
|
19900
|
+
local ____tstlClass = require("src.functions.tstlClass")
|
|
19901
|
+
local isTSTLSet = ____tstlClass.isTSTLSet
|
|
19746
19902
|
local ____types = require("src.functions.types")
|
|
19747
19903
|
local asNumber = ____types.asNumber
|
|
19748
19904
|
local isPrimitive = ____types.isPrimitive
|
|
@@ -19813,6 +19969,22 @@ function ____exports.countEntities(self, entityType, variant, subType, ignoreFri
|
|
|
19813
19969
|
)
|
|
19814
19970
|
return #entities
|
|
19815
19971
|
end
|
|
19972
|
+
function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
|
|
19973
|
+
if ignoreFriendly == nil then
|
|
19974
|
+
ignoreFriendly = false
|
|
19975
|
+
end
|
|
19976
|
+
local entityTypesArray = isTSTLSet(nil, entityTypes) and ({__TS__Spread(entityTypes:values())}) or entityTypes
|
|
19977
|
+
return __TS__ArraySome(
|
|
19978
|
+
entityTypesArray,
|
|
19979
|
+
function(____, entityType) return ____exports.countEntities(
|
|
19980
|
+
nil,
|
|
19981
|
+
entityType,
|
|
19982
|
+
-1,
|
|
19983
|
+
-1,
|
|
19984
|
+
ignoreFriendly
|
|
19985
|
+
) end
|
|
19986
|
+
)
|
|
19987
|
+
end
|
|
19816
19988
|
function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreFriendly)
|
|
19817
19989
|
if entityType == nil then
|
|
19818
19990
|
entityType = -1
|
|
@@ -20415,158 +20587,6 @@ function ____exports.setToBitFlags(self, set)
|
|
|
20415
20587
|
end
|
|
20416
20588
|
return flags
|
|
20417
20589
|
end
|
|
20418
|
-
return ____exports
|
|
20419
|
-
end,
|
|
20420
|
-
["src.classes.DefaultMap"] = function(...)
|
|
20421
|
-
local ____lualib = require("lualib_bundle")
|
|
20422
|
-
local __TS__Class = ____lualib.__TS__Class
|
|
20423
|
-
local Map = ____lualib.Map
|
|
20424
|
-
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
20425
|
-
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
20426
|
-
local __TS__New = ____lualib.__TS__New
|
|
20427
|
-
local ____exports = {}
|
|
20428
|
-
local ____types = require("src.functions.types")
|
|
20429
|
-
local isFunction = ____types.isFunction
|
|
20430
|
-
local isPrimitive = ____types.isPrimitive
|
|
20431
|
-
____exports.DefaultMap = __TS__Class()
|
|
20432
|
-
local DefaultMap = ____exports.DefaultMap
|
|
20433
|
-
DefaultMap.name = "DefaultMap"
|
|
20434
|
-
__TS__ClassExtends(DefaultMap, Map)
|
|
20435
|
-
function DefaultMap.prototype.____constructor(self, defaultValueOrFactoryFunction, initializerArray)
|
|
20436
|
-
local argIsPrimitive = isPrimitive(nil, defaultValueOrFactoryFunction)
|
|
20437
|
-
local argIsFunction = isFunction(nil, defaultValueOrFactoryFunction)
|
|
20438
|
-
if not argIsPrimitive and not argIsFunction then
|
|
20439
|
-
error(("Failed to instantiate a DefaultMap since the provided default value was of type \"" .. __TS__TypeOf(defaultValueOrFactoryFunction)) .. "\". This error usually means that you are trying to use an array (or some other non-primitive data structure that is passed by reference) as the default value. Instead, return the data structure in a factory function, like \"() => []\". See the DefaultMap documentation for more details.")
|
|
20440
|
-
end
|
|
20441
|
-
Map.prototype.____constructor(self, initializerArray)
|
|
20442
|
-
if argIsFunction then
|
|
20443
|
-
self.defaultValue = nil
|
|
20444
|
-
self.defaultValueFactory = defaultValueOrFactoryFunction
|
|
20445
|
-
else
|
|
20446
|
-
self.defaultValue = defaultValueOrFactoryFunction
|
|
20447
|
-
self.defaultValueFactory = nil
|
|
20448
|
-
end
|
|
20449
|
-
end
|
|
20450
|
-
function DefaultMap.prototype.getAndSetDefault(self, key, ...)
|
|
20451
|
-
local value = Map.prototype.get(self, key)
|
|
20452
|
-
if value ~= nil then
|
|
20453
|
-
return value
|
|
20454
|
-
end
|
|
20455
|
-
local defaultValue = self:getDefaultValue(...)
|
|
20456
|
-
self:set(key, defaultValue)
|
|
20457
|
-
return defaultValue
|
|
20458
|
-
end
|
|
20459
|
-
function DefaultMap.prototype.getDefaultValue(self, ...)
|
|
20460
|
-
if self.defaultValue ~= nil then
|
|
20461
|
-
return self.defaultValue
|
|
20462
|
-
end
|
|
20463
|
-
if self.defaultValueFactory ~= nil then
|
|
20464
|
-
return self:defaultValueFactory(...)
|
|
20465
|
-
end
|
|
20466
|
-
error("A DefaultMap was incorrectly instantiated.")
|
|
20467
|
-
end
|
|
20468
|
-
function DefaultMap.prototype.getConstructorArg(self)
|
|
20469
|
-
if self.defaultValue ~= nil then
|
|
20470
|
-
return self.defaultValue
|
|
20471
|
-
end
|
|
20472
|
-
if self.defaultValueFactory ~= nil then
|
|
20473
|
-
return self.defaultValueFactory
|
|
20474
|
-
end
|
|
20475
|
-
error("A DefaultMap was incorrectly instantiated.")
|
|
20476
|
-
end
|
|
20477
|
-
local function test(self)
|
|
20478
|
-
local myDefaultMapBoolean = __TS__New(____exports.DefaultMap, false)
|
|
20479
|
-
local myDefaultMapBooleanFactory = __TS__New(
|
|
20480
|
-
____exports.DefaultMap,
|
|
20481
|
-
function() return false end
|
|
20482
|
-
)
|
|
20483
|
-
local myDefaultMapBooleanWithoutParams = __TS__New(____exports.DefaultMap, false)
|
|
20484
|
-
local myDefaultMapNumber = __TS__New(____exports.DefaultMap, 123)
|
|
20485
|
-
local myDefaultMapNumberFactory = __TS__New(
|
|
20486
|
-
____exports.DefaultMap,
|
|
20487
|
-
function() return 123 end
|
|
20488
|
-
)
|
|
20489
|
-
local myDefaultMapNumberWithoutParams = __TS__New(____exports.DefaultMap, 123)
|
|
20490
|
-
local myDefaultMapString = __TS__New(____exports.DefaultMap, "foo")
|
|
20491
|
-
local myDefaultMapStringFactory = __TS__New(
|
|
20492
|
-
____exports.DefaultMap,
|
|
20493
|
-
function() return "foo" end
|
|
20494
|
-
)
|
|
20495
|
-
local myDefaultMapStringWithoutParams = __TS__New(____exports.DefaultMap, "foo")
|
|
20496
|
-
local myDefaultMapArray = __TS__New(
|
|
20497
|
-
____exports.DefaultMap,
|
|
20498
|
-
function() return {} end
|
|
20499
|
-
)
|
|
20500
|
-
local myDefaultMapArrayWithoutParams = __TS__New(
|
|
20501
|
-
____exports.DefaultMap,
|
|
20502
|
-
function() return {} end
|
|
20503
|
-
)
|
|
20504
|
-
local myDefaultMapMap = __TS__New(
|
|
20505
|
-
____exports.DefaultMap,
|
|
20506
|
-
function() return __TS__New(Map) end
|
|
20507
|
-
)
|
|
20508
|
-
local myDefaultMapMapWithoutParams = __TS__New(
|
|
20509
|
-
____exports.DefaultMap,
|
|
20510
|
-
function() return __TS__New(Map) end
|
|
20511
|
-
)
|
|
20512
|
-
end
|
|
20513
|
-
return ____exports
|
|
20514
|
-
end,
|
|
20515
|
-
["src.interfaces.TSTLClassMetatable"] = function(...)
|
|
20516
|
-
local ____exports = {}
|
|
20517
|
-
return ____exports
|
|
20518
|
-
end,
|
|
20519
|
-
["src.types.TSTLClass"] = function(...)
|
|
20520
|
-
local ____exports = {}
|
|
20521
|
-
return ____exports
|
|
20522
|
-
end,
|
|
20523
|
-
["src.functions.tstlClass"] = function(...)
|
|
20524
|
-
local ____exports = {}
|
|
20525
|
-
local ____types = require("src.functions.types")
|
|
20526
|
-
local isTable = ____types.isTable
|
|
20527
|
-
function ____exports.getTSTLClassConstructor(self, object)
|
|
20528
|
-
if not isTable(nil, object) then
|
|
20529
|
-
return nil
|
|
20530
|
-
end
|
|
20531
|
-
local metatable = getmetatable(object)
|
|
20532
|
-
if metatable == nil then
|
|
20533
|
-
return nil
|
|
20534
|
-
end
|
|
20535
|
-
return metatable.constructor
|
|
20536
|
-
end
|
|
20537
|
-
function ____exports.getTSTLClassName(self, object)
|
|
20538
|
-
local constructor = ____exports.getTSTLClassConstructor(nil, object)
|
|
20539
|
-
if constructor == nil then
|
|
20540
|
-
return nil
|
|
20541
|
-
end
|
|
20542
|
-
return constructor.name
|
|
20543
|
-
end
|
|
20544
|
-
function ____exports.isDefaultMap(self, object)
|
|
20545
|
-
local className = ____exports.getTSTLClassName(nil, object)
|
|
20546
|
-
return className == "DefaultMap"
|
|
20547
|
-
end
|
|
20548
|
-
function ____exports.isTSTLClass(self, object)
|
|
20549
|
-
local tstlClassName = ____exports.getTSTLClassName(nil, object)
|
|
20550
|
-
return tstlClassName ~= nil
|
|
20551
|
-
end
|
|
20552
|
-
function ____exports.isTSTLMap(self, object)
|
|
20553
|
-
local className = ____exports.getTSTLClassName(nil, object)
|
|
20554
|
-
return className == "Map"
|
|
20555
|
-
end
|
|
20556
|
-
function ____exports.isTSTLSet(self, object)
|
|
20557
|
-
local className = ____exports.getTSTLClassName(nil, object)
|
|
20558
|
-
return className == "Set"
|
|
20559
|
-
end
|
|
20560
|
-
function ____exports.newTSTLClass(self, oldClass)
|
|
20561
|
-
local constructor = ____exports.getTSTLClassConstructor(nil, oldClass)
|
|
20562
|
-
if constructor == nil then
|
|
20563
|
-
error("Failed to instantiate a new TypeScriptToLua class since the provided old class does not have a metatable/constructor.")
|
|
20564
|
-
end
|
|
20565
|
-
local newClass = {}
|
|
20566
|
-
local newClassMetatable = setmetatable(newClass, constructor.prototype)
|
|
20567
|
-
newClassMetatable:____constructor()
|
|
20568
|
-
return newClass
|
|
20569
|
-
end
|
|
20570
20590
|
return ____exports
|
|
20571
20591
|
end,
|
|
20572
20592
|
["src.functions.doors"] = function(...)
|
|
@@ -13,6 +13,15 @@ import { EntityID } from "../types/EntityID";
|
|
|
13
13
|
* @param ignoreFriendly Optional. Default is false.
|
|
14
14
|
*/
|
|
15
15
|
export declare function countEntities(entityType?: EntityType, variant?: number, subType?: number, ignoreFriendly?: boolean): int;
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to check if one or more matching entities exist in the current room. It uses the
|
|
18
|
+
* `doesEntityExist` helper function to determine this.
|
|
19
|
+
*
|
|
20
|
+
* @param entityTypes An array or set of the entity types that you want to check for. Will return
|
|
21
|
+
* true if any of the provided entity types exist.
|
|
22
|
+
* @param ignoreFriendly Optional. Default is false.
|
|
23
|
+
*/
|
|
24
|
+
export declare function doesAnyEntityExist(entityTypes: EntityType[] | readonly EntityType[] | Set<EntityType> | ReadonlySet<EntityType>, ignoreFriendly?: boolean): boolean;
|
|
16
25
|
/**
|
|
17
26
|
* Helper function to check if one or more of a specific kind of entity is present in the current
|
|
18
27
|
* room. It uses the `countEntities` helper function to determine this.
|
|
@@ -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;AAoB7C;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,UAAU,GAAE,UAAe,EAC3B,OAAO,SAAK,EACZ,OAAO,SAAK,EACZ,cAAc,UAAQ,GACrB,GAAG,CAcL;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EACP,UAAU,EAAE,GACZ,SAAS,UAAU,EAAE,GACrB,GAAG,CAAC,UAAU,CAAC,GACf,WAAW,CAAC,UAAU,CAAC,EAC3B,cAAc,UAAQ,GACrB,OAAO,CAQT;AAED;;;;;;;;GAQG;AACH,wBA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;;;;;;GAeG;AACH,wBAAgB,KAAK,CACnB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,MAAM,GAAG,GAAG,EACjC,QAAQ,GAAE,MAAmB,EAC7B,OAAO,GAAE,MAAM,GAAG,SAAqB,EACvC,SAAS,GAAE,IAAI,GAAG,GAAG,GAAG,SAAqB,GAC5C,MAAM,CA4CR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,MAAM,GAAG,GAAG,EACjC,QAAQ,GAAE,MAAmB,EAC7B,OAAO,GAAE,MAAM,GAAG,SAAqB,EACvC,SAAS,GAAE,IAAI,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"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__Spread = ____lualib.__TS__Spread
|
|
4
|
+
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
2
5
|
local __TS__StringSplit = ____lualib.__TS__StringSplit
|
|
3
6
|
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
4
|
-
local Set = ____lualib.Set
|
|
5
7
|
local __TS__New = ____lualib.__TS__New
|
|
6
8
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
7
9
|
local ____exports = {}
|
|
@@ -23,6 +25,8 @@ local isRNG = ____rng.isRNG
|
|
|
23
25
|
local newRNG = ____rng.newRNG
|
|
24
26
|
local ____sprites = require("src.functions.sprites")
|
|
25
27
|
local setSpriteOpacity = ____sprites.setSpriteOpacity
|
|
28
|
+
local ____tstlClass = require("src.functions.tstlClass")
|
|
29
|
+
local isTSTLSet = ____tstlClass.isTSTLSet
|
|
26
30
|
local ____types = require("src.functions.types")
|
|
27
31
|
local asNumber = ____types.asNumber
|
|
28
32
|
local isPrimitive = ____types.isPrimitive
|
|
@@ -107,6 +111,28 @@ function ____exports.countEntities(self, entityType, variant, subType, ignoreFri
|
|
|
107
111
|
)
|
|
108
112
|
return #entities
|
|
109
113
|
end
|
|
114
|
+
--- Helper function to check if one or more matching entities exist in the current room. It uses the
|
|
115
|
+
-- `doesEntityExist` helper function to determine this.
|
|
116
|
+
--
|
|
117
|
+
-- @param entityTypes An array or set of the entity types that you want to check for. Will return
|
|
118
|
+
-- true if any of the provided entity types exist.
|
|
119
|
+
-- @param ignoreFriendly Optional. Default is false.
|
|
120
|
+
function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
|
|
121
|
+
if ignoreFriendly == nil then
|
|
122
|
+
ignoreFriendly = false
|
|
123
|
+
end
|
|
124
|
+
local entityTypesArray = isTSTLSet(nil, entityTypes) and ({__TS__Spread(entityTypes:values())}) or entityTypes
|
|
125
|
+
return __TS__ArraySome(
|
|
126
|
+
entityTypesArray,
|
|
127
|
+
function(____, entityType) return ____exports.countEntities(
|
|
128
|
+
nil,
|
|
129
|
+
entityType,
|
|
130
|
+
-1,
|
|
131
|
+
-1,
|
|
132
|
+
ignoreFriendly
|
|
133
|
+
) end
|
|
134
|
+
)
|
|
135
|
+
end
|
|
110
136
|
--- Helper function to check if one or more of a specific kind of entity is present in the current
|
|
111
137
|
-- room. It uses the `countEntities` helper function to determine this.
|
|
112
138
|
--
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
|
9
9
|
import { getRandom } from "./random";
|
|
10
10
|
import { isRNG, newRNG } from "./rng";
|
|
11
11
|
import { setSpriteOpacity } from "./sprites";
|
|
12
|
+
import { isTSTLSet } from "./tstlClass";
|
|
12
13
|
import { asNumber, isPrimitive } from "./types";
|
|
13
14
|
import { doesVectorHaveLength, isVector, vectorToString } from "./vector";
|
|
14
15
|
|
|
@@ -54,6 +55,31 @@ export function countEntities(
|
|
|
54
55
|
return entities.length;
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Helper function to check if one or more matching entities exist in the current room. It uses the
|
|
60
|
+
* `doesEntityExist` helper function to determine this.
|
|
61
|
+
*
|
|
62
|
+
* @param entityTypes An array or set of the entity types that you want to check for. Will return
|
|
63
|
+
* true if any of the provided entity types exist.
|
|
64
|
+
* @param ignoreFriendly Optional. Default is false.
|
|
65
|
+
*/
|
|
66
|
+
export function doesAnyEntityExist(
|
|
67
|
+
entityTypes:
|
|
68
|
+
| EntityType[]
|
|
69
|
+
| readonly EntityType[]
|
|
70
|
+
| Set<EntityType>
|
|
71
|
+
| ReadonlySet<EntityType>,
|
|
72
|
+
ignoreFriendly = false,
|
|
73
|
+
): boolean {
|
|
74
|
+
const entityTypesArray = isTSTLSet(entityTypes)
|
|
75
|
+
? [...entityTypes.values()]
|
|
76
|
+
: (entityTypes as EntityType[]);
|
|
77
|
+
|
|
78
|
+
return entityTypesArray.some((entityType) =>
|
|
79
|
+
countEntities(entityType, -1, -1, ignoreFriendly),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
57
83
|
/**
|
|
58
84
|
* Helper function to check if one or more of a specific kind of entity is present in the current
|
|
59
85
|
* room. It uses the `countEntities` helper function to determine this.
|