-
Notifications
You must be signed in to change notification settings - Fork 181
/
Keycard.cs
81 lines (71 loc) · 2.71 KB
/
Keycard.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// -----------------------------------------------------------------------
// <copyright file="Keycard.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------
namespace Exiled.API.Features.Items
{
using Exiled.API.Enums;
using Exiled.API.Features.Pickups;
using Exiled.API.Interfaces;
using InventorySystem.Items.Keycards;
using KeycardPickup = Pickups.KeycardPickup;
/// <summary>
/// A wrapper class for <see cref="KeycardItem"/>.
/// </summary>
public class Keycard : Item, IWrapper<KeycardItem>
{
/// <summary>
/// Initializes a new instance of the <see cref="Keycard"/> class.
/// </summary>
/// <param name="itemBase">The base <see cref="KeycardItem"/> class.</param>
public Keycard(KeycardItem itemBase)
: base(itemBase)
{
Base = itemBase;
}
/// <summary>
/// Initializes a new instance of the <see cref="Keycard"/> class.
/// </summary>
/// <param name="type">The <see cref="ItemType"/> of the keycard.</param>
internal Keycard(ItemType type)
: this((KeycardItem)Server.Host.Inventory.CreateItemInstance(new(type, 0), false))
{
}
/// <summary>
/// Gets the <see cref="KeycardItem"/> that this class is encapsulating.
/// </summary>
public new KeycardItem Base { get; }
/// <summary>
/// Gets or sets the <see cref="KeycardPermissions"/> of the keycard.
/// </summary>
public KeycardPermissions Permissions
{
get => (KeycardPermissions)Base.Permissions;
set => Base.Permissions = (Interactables.Interobjects.DoorUtils.KeycardPermissions)value;
}
/// <summary>
/// Clones current <see cref="Keycard"/> object.
/// </summary>
/// <returns> New <see cref="Keycard"/> object. </returns>
public override Item Clone() => new Keycard(Type)
{
Permissions = Permissions,
};
/// <summary>
/// Returns the Keycard in a human readable format.
/// </summary>
/// <returns>A string containing Keycard-related data.</returns>
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{Permissions}|";
/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
{
base.ReadPickupInfo(pickup);
if (pickup is KeycardPickup keycardPickup)
{
Permissions = keycardPickup.Permissions;
}
}
}
}