isaacscript-common 20.18.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.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 20.18.0
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
 
@@ -19906,6 +19906,53 @@ local ____vector = require("src.functions.vector")
19906
19906
  local doesVectorHaveLength = ____vector.doesVectorHaveLength
19907
19907
  local isVector = ____vector.isVector
19908
19908
  local vectorToString = ____vector.vectorToString
19909
+ function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
19910
+ if entityType == nil then
19911
+ entityType = -1
19912
+ end
19913
+ if variant == nil then
19914
+ variant = -1
19915
+ end
19916
+ if subType == nil then
19917
+ subType = -1
19918
+ end
19919
+ if ignoreFriendly == nil then
19920
+ ignoreFriendly = false
19921
+ end
19922
+ if not ignoreFriendly then
19923
+ return Isaac.CountEntities(nil, entityType, variant, subType)
19924
+ end
19925
+ local entities = Isaac.FindByType(
19926
+ entityType,
19927
+ variant,
19928
+ subType,
19929
+ false,
19930
+ ignoreFriendly
19931
+ )
19932
+ return #entities
19933
+ end
19934
+ function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreFriendly)
19935
+ if entityType == nil then
19936
+ entityType = -1
19937
+ end
19938
+ if variant == nil then
19939
+ variant = -1
19940
+ end
19941
+ if subType == nil then
19942
+ subType = -1
19943
+ end
19944
+ if ignoreFriendly == nil then
19945
+ ignoreFriendly = false
19946
+ end
19947
+ local count = ____exports.countEntities(
19948
+ nil,
19949
+ entityType,
19950
+ variant,
19951
+ subType,
19952
+ ignoreFriendly
19953
+ )
19954
+ return count > 0
19955
+ end
19909
19956
  function setPrimitiveEntityFields(self, entity, metatable, entityFields)
19910
19957
  local propGetTable = metatable.__propget
19911
19958
  if propGetTable == nil then
@@ -19944,31 +19991,6 @@ local DAMAGE_FLASH_COLOR = Color(
19944
19991
  0 / 255,
19945
19992
  0 / 255
19946
19993
  )
19947
- function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
19948
- if entityType == nil then
19949
- entityType = -1
19950
- end
19951
- if variant == nil then
19952
- variant = -1
19953
- end
19954
- if subType == nil then
19955
- subType = -1
19956
- end
19957
- if ignoreFriendly == nil then
19958
- ignoreFriendly = false
19959
- end
19960
- if not ignoreFriendly then
19961
- return Isaac.CountEntities(nil, entityType, variant, subType)
19962
- end
19963
- local entities = Isaac.FindByType(
19964
- entityType,
19965
- variant,
19966
- subType,
19967
- false,
19968
- ignoreFriendly
19969
- )
19970
- return #entities
19971
- end
19972
19994
  function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
19973
19995
  if ignoreFriendly == nil then
19974
19996
  ignoreFriendly = false
@@ -19976,7 +19998,7 @@ function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
19976
19998
  local entityTypesArray = isTSTLSet(nil, entityTypes) and ({__TS__Spread(entityTypes:values())}) or entityTypes
19977
19999
  return __TS__ArraySome(
19978
20000
  entityTypesArray,
19979
- function(____, entityType) return ____exports.countEntities(
20001
+ function(____, entityType) return ____exports.doesEntityExist(
19980
20002
  nil,
19981
20003
  entityType,
19982
20004
  -1,
@@ -19985,28 +20007,6 @@ function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
19985
20007
  ) end
19986
20008
  )
19987
20009
  end
19988
- function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreFriendly)
19989
- if entityType == nil then
19990
- entityType = -1
19991
- end
19992
- if variant == nil then
19993
- variant = -1
19994
- end
19995
- if subType == nil then
19996
- subType = -1
19997
- end
19998
- if ignoreFriendly == nil then
19999
- ignoreFriendly = false
20000
- end
20001
- local count = ____exports.countEntities(
20002
- nil,
20003
- entityType,
20004
- variant,
20005
- subType,
20006
- ignoreFriendly
20007
- )
20008
- return count > 0
20009
- end
20010
20010
  function ____exports.getClosestEntityTo(self, referenceEntity, entities, filterFunc)
20011
20011
  local closestEntity
20012
20012
  local closestDistance = math.huge
@@ -34,6 +34,68 @@ local ____vector = require("src.functions.vector")
34
34
  local doesVectorHaveLength = ____vector.doesVectorHaveLength
35
35
  local isVector = ____vector.isVector
36
36
  local vectorToString = ____vector.vectorToString
37
+ --- Helper function to count the number of entities in room. Use this over the vanilla
38
+ -- `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
39
+ -- enemies.
40
+ --
41
+ -- @param entityType Optional. Default is -1, which matches every entity type.
42
+ -- @param variant Optional. Default is -1, which matches every variant.
43
+ -- @param subType Optional. Default is -1, which matches every sub-type.
44
+ -- @param ignoreFriendly Optional. Default is false.
45
+ function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
46
+ if entityType == nil then
47
+ entityType = -1
48
+ end
49
+ if variant == nil then
50
+ variant = -1
51
+ end
52
+ if subType == nil then
53
+ subType = -1
54
+ end
55
+ if ignoreFriendly == nil then
56
+ ignoreFriendly = false
57
+ end
58
+ if not ignoreFriendly then
59
+ return Isaac.CountEntities(nil, entityType, variant, subType)
60
+ end
61
+ local entities = Isaac.FindByType(
62
+ entityType,
63
+ variant,
64
+ subType,
65
+ false,
66
+ ignoreFriendly
67
+ )
68
+ return #entities
69
+ end
70
+ --- Helper function to check if one or more of a specific kind of entity is present in the current
71
+ -- room. It uses the `countEntities` helper function to determine this.
72
+ --
73
+ -- @param entityType Optional. Default is -1, which matches every entity type.
74
+ -- @param variant Optional. Default is -1, which matches every variant.
75
+ -- @param subType Optional. Default is -1, which matches every sub-type.
76
+ -- @param ignoreFriendly Optional. Default is false.
77
+ function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreFriendly)
78
+ if entityType == nil then
79
+ entityType = -1
80
+ end
81
+ if variant == nil then
82
+ variant = -1
83
+ end
84
+ if subType == nil then
85
+ subType = -1
86
+ end
87
+ if ignoreFriendly == nil then
88
+ ignoreFriendly = false
89
+ end
90
+ local count = ____exports.countEntities(
91
+ nil,
92
+ entityType,
93
+ variant,
94
+ subType,
95
+ ignoreFriendly
96
+ )
97
+ return count > 0
98
+ end
37
99
  function setPrimitiveEntityFields(self, entity, metatable, entityFields)
38
100
  local propGetTable = metatable.__propget
39
101
  if propGetTable == nil then
@@ -78,39 +140,6 @@ local DAMAGE_FLASH_COLOR = Color(
78
140
  0 / 255,
79
141
  0 / 255
80
142
  )
81
- --- Helper function to count the number of entities in room. Use this over the vanilla
82
- -- `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
83
- -- enemies.
84
- --
85
- -- @param entityType Optional. Default is -1, which matches every entity type.
86
- -- @param variant Optional. Default is -1, which matches every variant.
87
- -- @param subType Optional. Default is -1, which matches every sub-type.
88
- -- @param ignoreFriendly Optional. Default is false.
89
- function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
90
- if entityType == nil then
91
- entityType = -1
92
- end
93
- if variant == nil then
94
- variant = -1
95
- end
96
- if subType == nil then
97
- subType = -1
98
- end
99
- if ignoreFriendly == nil then
100
- ignoreFriendly = false
101
- end
102
- if not ignoreFriendly then
103
- return Isaac.CountEntities(nil, entityType, variant, subType)
104
- end
105
- local entities = Isaac.FindByType(
106
- entityType,
107
- variant,
108
- subType,
109
- false,
110
- ignoreFriendly
111
- )
112
- return #entities
113
- end
114
143
  --- Helper function to check if one or more matching entities exist in the current room. It uses the
115
144
  -- `doesEntityExist` helper function to determine this.
116
145
  --
@@ -124,7 +153,7 @@ function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
124
153
  local entityTypesArray = isTSTLSet(nil, entityTypes) and ({__TS__Spread(entityTypes:values())}) or entityTypes
125
154
  return __TS__ArraySome(
126
155
  entityTypesArray,
127
- function(____, entityType) return ____exports.countEntities(
156
+ function(____, entityType) return ____exports.doesEntityExist(
128
157
  nil,
129
158
  entityType,
130
159
  -1,
@@ -133,35 +162,6 @@ function ____exports.doesAnyEntityExist(self, entityTypes, ignoreFriendly)
133
162
  ) end
134
163
  )
135
164
  end
136
- --- Helper function to check if one or more of a specific kind of entity is present in the current
137
- -- room. It uses the `countEntities` helper function to determine this.
138
- --
139
- -- @param entityType Optional. Default is -1, which matches every entity type.
140
- -- @param variant Optional. Default is -1, which matches every variant.
141
- -- @param subType Optional. Default is -1, which matches every sub-type.
142
- -- @param ignoreFriendly Optional. Default is false.
143
- function ____exports.doesEntityExist(self, entityType, variant, subType, ignoreFriendly)
144
- if entityType == nil then
145
- entityType = -1
146
- end
147
- if variant == nil then
148
- variant = -1
149
- end
150
- if subType == nil then
151
- subType = -1
152
- end
153
- if ignoreFriendly == nil then
154
- ignoreFriendly = false
155
- end
156
- local count = ____exports.countEntities(
157
- nil,
158
- entityType,
159
- variant,
160
- subType,
161
- ignoreFriendly
162
- )
163
- return count > 0
164
- end
165
165
  --- Given an array of entities, this helper function returns the closest one to a provided reference
166
166
  -- entity.
167
167
  --
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "20.18.0",
3
+ "version": "20.18.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -76,7 +76,7 @@ export function doesAnyEntityExist(
76
76
  : (entityTypes as EntityType[]);
77
77
 
78
78
  return entityTypesArray.some((entityType) =>
79
- countEntities(entityType, -1, -1, ignoreFriendly),
79
+ doesEntityExist(entityType, -1, -1, ignoreFriendly),
80
80
  );
81
81
  }
82
82