isaacscript-common 20.17.0 → 20.18.1
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.1
|
|
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
|
|
@@ -19750,44 +19906,6 @@ local ____vector = require("src.functions.vector")
|
|
|
19750
19906
|
local doesVectorHaveLength = ____vector.doesVectorHaveLength
|
|
19751
19907
|
local isVector = ____vector.isVector
|
|
19752
19908
|
local vectorToString = ____vector.vectorToString
|
|
19753
|
-
function setPrimitiveEntityFields(self, entity, metatable, entityFields)
|
|
19754
|
-
local propGetTable = metatable.__propget
|
|
19755
|
-
if propGetTable == nil then
|
|
19756
|
-
error("Failed to get the \"__propget\" table for an entity.")
|
|
19757
|
-
end
|
|
19758
|
-
for key in pairs(propGetTable) do
|
|
19759
|
-
local indexKey = key
|
|
19760
|
-
local value = entity[indexKey]
|
|
19761
|
-
if isPrimitive(nil, value) then
|
|
19762
|
-
entityFields[indexKey] = value
|
|
19763
|
-
elseif isVector(nil, value) then
|
|
19764
|
-
entityFields[indexKey] = vectorToString(nil, value)
|
|
19765
|
-
end
|
|
19766
|
-
end
|
|
19767
|
-
end
|
|
19768
|
-
function ____exports.removeEntities(self, entities, cap)
|
|
19769
|
-
if #entities == 0 then
|
|
19770
|
-
return {}
|
|
19771
|
-
end
|
|
19772
|
-
local entitiesRemoved = {}
|
|
19773
|
-
for ____, entity in ipairs(entities) do
|
|
19774
|
-
entity:Remove()
|
|
19775
|
-
entitiesRemoved[#entitiesRemoved + 1] = entity
|
|
19776
|
-
if cap ~= nil and #entitiesRemoved >= cap then
|
|
19777
|
-
break
|
|
19778
|
-
end
|
|
19779
|
-
end
|
|
19780
|
-
return entitiesRemoved
|
|
19781
|
-
end
|
|
19782
|
-
local DAMAGE_FLASH_COLOR = Color(
|
|
19783
|
-
0.5,
|
|
19784
|
-
0.5,
|
|
19785
|
-
0.5,
|
|
19786
|
-
1,
|
|
19787
|
-
200 / 255,
|
|
19788
|
-
0 / 255,
|
|
19789
|
-
0 / 255
|
|
19790
|
-
)
|
|
19791
19909
|
function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
|
|
19792
19910
|
if entityType == nil then
|
|
19793
19911
|
entityType = -1
|
|
@@ -19835,6 +19953,60 @@ function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreF
|
|
|
19835
19953
|
)
|
|
19836
19954
|
return count > 0
|
|
19837
19955
|
end
|
|
19956
|
+
function setPrimitiveEntityFields(self, entity, metatable, entityFields)
|
|
19957
|
+
local propGetTable = metatable.__propget
|
|
19958
|
+
if propGetTable == nil then
|
|
19959
|
+
error("Failed to get the \"__propget\" table for an entity.")
|
|
19960
|
+
end
|
|
19961
|
+
for key in pairs(propGetTable) do
|
|
19962
|
+
local indexKey = key
|
|
19963
|
+
local value = entity[indexKey]
|
|
19964
|
+
if isPrimitive(nil, value) then
|
|
19965
|
+
entityFields[indexKey] = value
|
|
19966
|
+
elseif isVector(nil, value) then
|
|
19967
|
+
entityFields[indexKey] = vectorToString(nil, value)
|
|
19968
|
+
end
|
|
19969
|
+
end
|
|
19970
|
+
end
|
|
19971
|
+
function ____exports.removeEntities(self, entities, cap)
|
|
19972
|
+
if #entities == 0 then
|
|
19973
|
+
return {}
|
|
19974
|
+
end
|
|
19975
|
+
local entitiesRemoved = {}
|
|
19976
|
+
for ____, entity in ipairs(entities) do
|
|
19977
|
+
entity:Remove()
|
|
19978
|
+
entitiesRemoved[#entitiesRemoved + 1] = entity
|
|
19979
|
+
if cap ~= nil and #entitiesRemoved >= cap then
|
|
19980
|
+
break
|
|
19981
|
+
end
|
|
19982
|
+
end
|
|
19983
|
+
return entitiesRemoved
|
|
19984
|
+
end
|
|
19985
|
+
local DAMAGE_FLASH_COLOR = Color(
|
|
19986
|
+
0.5,
|
|
19987
|
+
0.5,
|
|
19988
|
+
0.5,
|
|
19989
|
+
1,
|
|
19990
|
+
200 / 255,
|
|
19991
|
+
0 / 255,
|
|
19992
|
+
0 / 255
|
|
19993
|
+
)
|
|
19994
|
+
function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
|
|
19995
|
+
if ignoreFriendly == nil then
|
|
19996
|
+
ignoreFriendly = false
|
|
19997
|
+
end
|
|
19998
|
+
local entityTypesArray = isTSTLSet(nil, entityTypes) and ({__TS__Spread(entityTypes:values())}) or entityTypes
|
|
19999
|
+
return __TS__ArraySome(
|
|
20000
|
+
entityTypesArray,
|
|
20001
|
+
function(____, entityType) return ____exports.doesEntityExist(
|
|
20002
|
+
nil,
|
|
20003
|
+
entityType,
|
|
20004
|
+
-1,
|
|
20005
|
+
-1,
|
|
20006
|
+
ignoreFriendly
|
|
20007
|
+
) end
|
|
20008
|
+
)
|
|
20009
|
+
end
|
|
19838
20010
|
function ____exports.getClosestEntityTo(self, referenceEntity, entities, filterFunc)
|
|
19839
20011
|
local closestEntity
|
|
19840
20012
|
local closestDistance = math.huge
|
|
@@ -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,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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AG,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
|
|
@@ -30,50 +34,6 @@ local ____vector = require("src.functions.vector")
|
|
|
30
34
|
local doesVectorHaveLength = ____vector.doesVectorHaveLength
|
|
31
35
|
local isVector = ____vector.isVector
|
|
32
36
|
local vectorToString = ____vector.vectorToString
|
|
33
|
-
function setPrimitiveEntityFields(self, entity, metatable, entityFields)
|
|
34
|
-
local propGetTable = metatable.__propget
|
|
35
|
-
if propGetTable == nil then
|
|
36
|
-
error("Failed to get the \"__propget\" table for an entity.")
|
|
37
|
-
end
|
|
38
|
-
for key in pairs(propGetTable) do
|
|
39
|
-
local indexKey = key
|
|
40
|
-
local value = entity[indexKey]
|
|
41
|
-
if isPrimitive(nil, value) then
|
|
42
|
-
entityFields[indexKey] = value
|
|
43
|
-
elseif isVector(nil, value) then
|
|
44
|
-
entityFields[indexKey] = vectorToString(nil, value)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
--- Helper function to remove all of the entities in the supplied array.
|
|
49
|
-
--
|
|
50
|
-
-- @param entities The array of entities to remove.
|
|
51
|
-
-- @param cap Optional. If specified, will only remove the given amount of entities.
|
|
52
|
-
-- @returns An array of the entities that were removed.
|
|
53
|
-
function ____exports.removeEntities(self, entities, cap)
|
|
54
|
-
if #entities == 0 then
|
|
55
|
-
return {}
|
|
56
|
-
end
|
|
57
|
-
local entitiesRemoved = {}
|
|
58
|
-
for ____, entity in ipairs(entities) do
|
|
59
|
-
entity:Remove()
|
|
60
|
-
entitiesRemoved[#entitiesRemoved + 1] = entity
|
|
61
|
-
if cap ~= nil and #entitiesRemoved >= cap then
|
|
62
|
-
break
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
return entitiesRemoved
|
|
66
|
-
end
|
|
67
|
-
--- From DeadInfinity.
|
|
68
|
-
local DAMAGE_FLASH_COLOR = Color(
|
|
69
|
-
0.5,
|
|
70
|
-
0.5,
|
|
71
|
-
0.5,
|
|
72
|
-
1,
|
|
73
|
-
200 / 255,
|
|
74
|
-
0 / 255,
|
|
75
|
-
0 / 255
|
|
76
|
-
)
|
|
77
37
|
--- Helper function to count the number of entities in room. Use this over the vanilla
|
|
78
38
|
-- `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
|
|
79
39
|
-- enemies.
|
|
@@ -136,6 +96,72 @@ function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreF
|
|
|
136
96
|
)
|
|
137
97
|
return count > 0
|
|
138
98
|
end
|
|
99
|
+
function setPrimitiveEntityFields(self, entity, metatable, entityFields)
|
|
100
|
+
local propGetTable = metatable.__propget
|
|
101
|
+
if propGetTable == nil then
|
|
102
|
+
error("Failed to get the \"__propget\" table for an entity.")
|
|
103
|
+
end
|
|
104
|
+
for key in pairs(propGetTable) do
|
|
105
|
+
local indexKey = key
|
|
106
|
+
local value = entity[indexKey]
|
|
107
|
+
if isPrimitive(nil, value) then
|
|
108
|
+
entityFields[indexKey] = value
|
|
109
|
+
elseif isVector(nil, value) then
|
|
110
|
+
entityFields[indexKey] = vectorToString(nil, value)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
--- Helper function to remove all of the entities in the supplied array.
|
|
115
|
+
--
|
|
116
|
+
-- @param entities The array of entities to remove.
|
|
117
|
+
-- @param cap Optional. If specified, will only remove the given amount of entities.
|
|
118
|
+
-- @returns An array of the entities that were removed.
|
|
119
|
+
function ____exports.removeEntities(self, entities, cap)
|
|
120
|
+
if #entities == 0 then
|
|
121
|
+
return {}
|
|
122
|
+
end
|
|
123
|
+
local entitiesRemoved = {}
|
|
124
|
+
for ____, entity in ipairs(entities) do
|
|
125
|
+
entity:Remove()
|
|
126
|
+
entitiesRemoved[#entitiesRemoved + 1] = entity
|
|
127
|
+
if cap ~= nil and #entitiesRemoved >= cap then
|
|
128
|
+
break
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
return entitiesRemoved
|
|
132
|
+
end
|
|
133
|
+
--- From DeadInfinity.
|
|
134
|
+
local DAMAGE_FLASH_COLOR = Color(
|
|
135
|
+
0.5,
|
|
136
|
+
0.5,
|
|
137
|
+
0.5,
|
|
138
|
+
1,
|
|
139
|
+
200 / 255,
|
|
140
|
+
0 / 255,
|
|
141
|
+
0 / 255
|
|
142
|
+
)
|
|
143
|
+
--- Helper function to check if one or more matching entities exist in the current room. It uses the
|
|
144
|
+
-- `doesEntityExist` helper function to determine this.
|
|
145
|
+
--
|
|
146
|
+
-- @param entityTypes An array or set of the entity types that you want to check for. Will return
|
|
147
|
+
-- true if any of the provided entity types exist.
|
|
148
|
+
-- @param ignoreFriendly Optional. Default is false.
|
|
149
|
+
function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
|
|
150
|
+
if ignoreFriendly == nil then
|
|
151
|
+
ignoreFriendly = false
|
|
152
|
+
end
|
|
153
|
+
local entityTypesArray = isTSTLSet(nil, entityTypes) and ({__TS__Spread(entityTypes:values())}) or entityTypes
|
|
154
|
+
return __TS__ArraySome(
|
|
155
|
+
entityTypesArray,
|
|
156
|
+
function(____, entityType) return ____exports.doesEntityExist(
|
|
157
|
+
nil,
|
|
158
|
+
entityType,
|
|
159
|
+
-1,
|
|
160
|
+
-1,
|
|
161
|
+
ignoreFriendly
|
|
162
|
+
) end
|
|
163
|
+
)
|
|
164
|
+
end
|
|
139
165
|
--- Given an array of entities, this helper function returns the closest one to a provided reference
|
|
140
166
|
-- entity.
|
|
141
167
|
--
|
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
|
+
doesEntityExist(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.
|