@@ -14,7 +14,9 @@ namespace Exiled.API.Features.Doors
14
14
using Exiled . API . Enums ;
15
15
using Exiled . API . Extensions ;
16
16
using Exiled . API . Features . Core ;
17
+ using Exiled . API . Features . Hazards ;
17
18
using Exiled . API . Interfaces ;
19
+ using global ::Hazards ;
18
20
using Interactables . Interobjects ;
19
21
using Interactables . Interobjects . DoorUtils ;
20
22
using MEC ;
@@ -309,6 +311,31 @@ public static Door Get(DoorVariant doorVariant)
309
311
return DoorVariantToDoor [ doorVariant ] ;
310
312
}
311
313
314
+ /// <summary>
315
+ /// Gets the <see cref="Door"/> by <see cref="DoorVariant"/>.
316
+ /// </summary>
317
+ /// <param name="doorVariant">The <see cref="DoorVariant"/> to convert into an door.</param>
318
+ /// <typeparam name="T">The specified <see cref="Door"/> type.</typeparam>
319
+ /// <returns>The door wrapper for the given <see cref="DoorVariant"/>.</returns>
320
+ public static T Get < T > ( DoorVariant doorVariant )
321
+ where T : Door => Get ( doorVariant ) as T ;
322
+
323
+ /// <summary>
324
+ /// Gets a <see cref="Door"/> given the specified <see cref="DoorType"/>.
325
+ /// </summary>
326
+ /// <param name="doorType">The <see cref="DoorType"/> to search for.</param>
327
+ /// <returns>The <see cref="Door"/> with the given <see cref="DoorType"/> or <see langword="null"/> if not found.</returns>
328
+ public static Door Get ( DoorType doorType ) => List . FirstOrDefault ( x => x . Type == doorType ) ;
329
+
330
+ /// <summary>
331
+ /// Gets the <see cref="Door"/> by <see cref="DoorVariant"/>.
332
+ /// </summary>
333
+ /// <param name="doorType">The <see cref="DoorVariant"/> to convert into an door.</param>
334
+ /// <typeparam name="T">The specified <see cref="Door"/> type.</typeparam>
335
+ /// <returns>The door wrapper for the given <see cref="DoorVariant"/>.</returns>
336
+ public static T Get < T > ( DoorType doorType )
337
+ where T : Door => Get ( doorType ) as T ;
338
+
312
339
/// <summary>
313
340
/// Gets a <see cref="Door"/> given the specified name.
314
341
/// </summary>
@@ -320,27 +347,22 @@ public static Door Get(string name)
320
347
return nameExtension is null ? null : Get ( nameExtension . TargetDoor ) ;
321
348
}
322
349
350
+ /// <summary>
351
+ /// Gets the <see cref="Door"/> by <see cref="DoorVariant"/>.
352
+ /// </summary>
353
+ /// <param name="name">The name to search for.</param>
354
+ /// <typeparam name="T">The specified <see cref="Door"/> type.</typeparam>
355
+ /// <returns>The door wrapper for the given <see cref="DoorVariant"/>.</returns>
356
+ public static T Get < T > ( string name )
357
+ where T : Door => Get ( name ) as T ;
358
+
323
359
/// <summary>
324
360
/// Gets the door object associated with a specific <see cref="UnityEngine.GameObject"/>, or creates a new one if there isn't one.
325
361
/// </summary>
326
362
/// <param name="gameObject">The base-game <see cref="UnityEngine.GameObject"/>.</param>
327
363
/// <returns>The <see cref="Door"/> with the given name or <see langword="null"/> if not found.</returns>
328
364
public static Door Get ( GameObject gameObject ) => gameObject is null ? null : Get ( gameObject . GetComponentInChildren < DoorVariant > ( ) ) ;
329
365
330
- /// <summary>
331
- /// Gets a <see cref="IEnumerable{T}"/> of <see cref="Door"/> filtered based on a predicate.
332
- /// </summary>
333
- /// <param name="predicate">The condition to satify.</param>
334
- /// <returns>A <see cref="IEnumerable{T}"/> of <see cref="Door"/> which contains elements that satify the condition.</returns>
335
- public static IEnumerable < Door > Get ( Func < Door , bool > predicate ) => List . Where ( predicate ) ;
336
-
337
- /// <summary>
338
- /// Gets a <see cref="Door"/> given the specified <see cref="DoorType"/>.
339
- /// </summary>
340
- /// <param name="doorType">The <see cref="DoorType"/> to search for.</param>
341
- /// <returns>The <see cref="Door"/> with the given <see cref="DoorType"/> or <see langword="null"/> if not found.</returns>
342
- public static Door Get ( DoorType doorType ) => List . FirstOrDefault ( x => x . Type == doorType ) ;
343
-
344
366
/// <summary>
345
367
/// Returns the closest <see cref="Door"/> to the given <paramref name="position"/>.
346
368
/// </summary>
@@ -367,6 +389,13 @@ public static Door Random(ZoneType type = ZoneType.Unspecified, bool onlyUnbroke
367
389
return doors [ UnityEngine . Random . Range ( 0 , doors . Count ) ] ;
368
390
}
369
391
392
+ /// <summary>
393
+ /// Gets a <see cref="IEnumerable{T}"/> of <see cref="Door"/> filtered based on a predicate.
394
+ /// </summary>
395
+ /// <param name="predicate">The condition to satify.</param>
396
+ /// <returns>A <see cref="IEnumerable{T}"/> of <see cref="Door"/> which contains elements that satify the condition.</returns>
397
+ public static IEnumerable < Door > Get ( Func < Door , bool > predicate ) => List . Where ( predicate ) ;
398
+
370
399
/// <summary>
371
400
/// Locks all <see cref="Door">doors</see> given the specified <see cref="ZoneType"/>.
372
401
/// </summary>
0 commit comments