Skip to content

Commit 838b1d9

Browse files
committed
Merge branch 'dev' into LabAPI
2 parents 6f63c3e + 2d5086f commit 838b1d9

File tree

24 files changed

+303
-99
lines changed

24 files changed

+303
-99
lines changed

EXILED/Exiled.API/Enums/SpawnLocationType.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,30 @@ public enum SpawnLocationType
143143
/// Just inside the LCZ WC door.
144144
/// </summary>
145145
InsideLczWc,
146+
147+
/// <summary>
148+
/// Inside the Glass Box in GR-18.
149+
/// </summary>
150+
InsideGr18Glass,
151+
152+
/// <summary>
153+
/// Inside 106's Primary Door
154+
/// </summary>
155+
Inside106Primary,
156+
157+
/// <summary>
158+
/// Inside 106's Secondary Door
159+
/// </summary>
160+
Inside106Secondary,
161+
162+
/// <summary>
163+
/// Inside 939 Cryo Chamber
164+
/// </summary>
165+
Inside939Cryo,
166+
167+
/// <summary>
168+
/// Inside SCP-079's Armory
169+
/// </summary>
170+
Inside079Armory,
146171
}
147172
}

EXILED/Exiled.API/Extensions/EffectTypeExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ or EffectType.Disabled or EffectType.Ensnared or EffectType.Exhausted or EffectT
175175
/// <seealso cref="IsHealing(EffectType)"/>
176176
public static bool IsPositive(this EffectType effect) => effect is EffectType.BodyshotReduction or EffectType.DamageReduction
177177
or EffectType.Invigorated or EffectType.Invisible or EffectType.MovementBoost or EffectType.RainbowTaste
178-
or EffectType.Scp207 or EffectType.Scp1853 or EffectType.Vitality or EffectType.AntiScp207 or EffectType.Ghostly;
178+
or EffectType.Scp207 or EffectType.Scp1853 or EffectType.Vitality or EffectType.AntiScp207 or EffectType.Ghostly or EffectType.Scp1344;
179179

180180
/// <summary>
181181
/// Returns whether the provided <paramref name="effect"/> affects the player's movement speed.

EXILED/Exiled.API/Extensions/SpawnExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static class SpawnExtensions
3434
SpawnLocationType.Inside914,
3535
SpawnLocationType.Inside049Armory,
3636
SpawnLocationType.InsideLczCafe,
37+
SpawnLocationType.Inside939Cryo,
3738
};
3839

3940
/// <summary>
@@ -102,6 +103,11 @@ public static Vector3 GetPosition(this SpawnLocationType location)
102103
SpawnLocationType.Inside173Connector => "173_CONNECTOR",
103104
SpawnLocationType.InsideEscapePrimary => "ESCAPE_PRIMARY",
104105
SpawnLocationType.InsideEscapeSecondary => "ESCAPE_SECONDARY",
106+
SpawnLocationType.InsideGr18Glass => "GR18_INNER",
107+
SpawnLocationType.Inside106Primary => "106_PRIMARY",
108+
SpawnLocationType.Inside106Secondary => "106_SECONDARY",
109+
SpawnLocationType.Inside939Cryo => "939_CRYO",
110+
SpawnLocationType.Inside079Armory => "079_ARMORY",
105111
_ => default,
106112
};
107113
}

EXILED/Exiled.API/Features/Core/UserSettings/SettingBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ public static void SendToAll(Func<Player, bool> predicate)
218218
/// <param name="player">Target player.</param>
219219
public static void SendToPlayer(Player player) => ServerSpecificSettingsSync.SendToPlayer(player.ReferenceHub);
220220

221+
/// <summary>
222+
/// Syncs specific settings with the specified target.
223+
/// </summary>
224+
/// <param name="player">Target player.</param>
225+
/// <param name="settings">Settings to send to the player.</param>
226+
public static void SendToPlayer(Player player, IEnumerable<SettingBase> settings) =>
227+
ServerSpecificSettingsSync.SendToPlayer(player.ReferenceHub, settings.Select(setting => setting.Base).ToArray());
228+
221229
/// <summary>
222230
/// Registers all settings from the specified collection.
223231
/// </summary>

EXILED/Exiled.API/Features/Items/Firearm.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -364,30 +364,29 @@ public static Firearm Create(FirearmType type)
364364
/// <param name="identifier">The <see cref="AttachmentIdentifier"/> to add.</param>
365365
public void AddAttachment(AttachmentIdentifier identifier)
366366
{
367-
uint toRemove = 0;
368-
uint code = 1;
367+
// Fallback addedCode onto AvailableAttachments' code in case it's 0
368+
uint addedCode = identifier.Code == 0
369+
? AvailableAttachments[FirearmType].FirstOrDefault(attId => attId.Name == identifier.Name).Code
370+
: identifier.Code;
371+
372+
// Look for conflicting attachment (attachment that occupies the same slot)
373+
uint conflicting = 0;
374+
uint current = 1;
369375

370376
foreach (Attachment attachment in Base.Attachments)
371377
{
372378
if (attachment.Slot == identifier.Slot && attachment.IsEnabled)
373379
{
374-
toRemove = code;
380+
conflicting = current;
375381
break;
376382
}
377383

378-
code *= 2;
384+
current *= 2;
379385
}
380386

381-
uint newCode = identifier.Code == 0
382-
? AvailableAttachments[FirearmType].FirstOrDefault(
383-
attId =>
384-
attId.Name == identifier.Name).Code
385-
: identifier.Code;
386-
387-
Base.ApplyAttachmentsCode((Base.GetCurrentAttachmentsCode() & ~toRemove) | newCode, true);
388-
389-
// TODO Not finish
390-
// Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode());
387+
uint code = Base.ValidateAttachmentsCode((Base.GetCurrentAttachmentsCode() & ~conflicting) | addedCode);
388+
Base.ApplyAttachmentsCode(code, false);
389+
AttachmentCodeSync.ServerSetCode(Serial, code);
391390
}
392391

393392
/// <summary>

EXILED/Exiled.API/Features/Map.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace Exiled.API.Features
1313
using System.Collections.ObjectModel;
1414
using System.Linq;
1515

16+
using CommandSystem.Commands.RemoteAdmin.Cleanup;
17+
using Decals;
1618
using Enums;
1719
using Exiled.API.Extensions;
1820
using Exiled.API.Features.Hazards;
@@ -27,6 +29,7 @@ namespace Exiled.API.Features
2729
using PlayerRoles.Ragdolls;
2830
using UnityEngine;
2931
using Utils;
32+
using Utils.Networking;
3033

3134
using Object = UnityEngine.Object;
3235

@@ -130,6 +133,17 @@ public static void Broadcast(ushort duration, string message, global::Broadcast.
130133
Server.Broadcast.RpcAddElement(message, duration, type);
131134
}
132135

136+
/// <summary>
137+
/// Broadcasts delegate invocation result to all <see cref="Player">players</see>.
138+
/// </summary>
139+
/// <param name="duration">The duration in seconds.</param>
140+
/// <param name="func">The delegate whose invocation result will be the message.</param>
141+
public static void Broadcast(ushort duration, Func<Player, string> func)
142+
{
143+
foreach (Player player in Player.List)
144+
player.Broadcast(duration, func.Invoke(player));
145+
}
146+
133147
/// <summary>
134148
/// Shows a hint to all <see cref="Player">players</see>.
135149
/// </summary>
@@ -271,6 +285,19 @@ public static void CleanAllRagdolls(IEnumerable<Ragdoll> ragDolls)
271285
ragDoll.Destroy();
272286
}
273287

288+
/// <summary>
289+
/// Destroy specified amount of specified <see cref="DecalPoolType"/> object.
290+
/// </summary>
291+
/// <param name="decalType">Decal type to destroy.</param>
292+
/// <param name="amount">Amount of decals to destroy.</param>
293+
public static void Clean(DecalPoolType decalType, int amount) => new DecalCleanupMessage(decalType, amount).SendToAuthenticated();
294+
295+
/// <summary>
296+
/// Destroy all specified <see cref="DecalPoolType"/> objects.
297+
/// </summary>
298+
/// <param name="decalType">Decal type to destroy.</param>
299+
public static void Clean(DecalPoolType decalType) => Clean(decalType, int.MaxValue);
300+
274301
/// <summary>
275302
/// Places a blood decal.
276303
/// </summary>

EXILED/Exiled.API/Features/Pickups/FirearmPickup.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Exiled.API.Features.Pickups
99
{
10+
using System;
11+
1012
using Exiled.API.Interfaces;
1113

1214
using InventorySystem.Items;
@@ -56,7 +58,8 @@ internal FirearmPickup(ItemType type)
5658
/// <summary>
5759
/// Gets a value indicating whether the pickup is already distributed.
5860
/// </summary>
59-
public bool IsDistributed { get; internal set; }
61+
[Obsolete("Feature deprecated")]
62+
public bool IsDistributed { get; }
6063

6164
/// <summary>
6265
/// Gets or sets a value indicating how much ammo can contain this <see cref="FirearmPickup"/>.
@@ -104,7 +107,7 @@ public int Ammo
104107
}
105108

106109
/// <summary>
107-
/// Gets or sets a ammo drain per shoot.
110+
/// Gets or sets the ammo drain per shoot.
108111
/// </summary>
109112
/// <remarks>
110113
/// Always <see langword="1"/> by default.
@@ -121,19 +124,16 @@ public uint Attachments
121124
set => Base.Worldmodel.Setup(Base.CurId, Base.Worldmodel.WorldmodelType, value);
122125
}
123126

124-
/// <inheritdoc />
125-
public override void Spawn()
126-
{
127-
base.Spawn();
128-
if (!IsDistributed)
129-
Base.OnDistributed();
130-
}
127+
/// <summary>
128+
/// Initializes the item as if it was spawned naturally by map generation.
129+
/// </summary>
130+
public void Distribute() => Base.OnDistributed();
131131

132132
/// <summary>
133-
/// Returns the FirearmPickup in a human readable format.
133+
/// Returns the FirearmPickup in a human-readable format.
134134
/// </summary>
135135
/// <returns>A string containing FirearmPickup related data.</returns>
136-
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{IsDistributed}| -{/*Ammo*/0}-";
136+
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}*";
137137

138138
/// <inheritdoc/>
139139
internal override void ReadItemInfo(Items.Item item)

EXILED/Exiled.API/Features/Player.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public Player(GameObject gameObject)
137137
/// <summary>
138138
/// Gets a list of all <see cref="Player"/>'s on the server.
139139
/// </summary>
140-
public static IReadOnlyCollection<Player> List => Dictionary.Values.Where(x => !x.IsNPC).ToList();
140+
public static IReadOnlyCollection<Player> List => Dictionary.Values.ToList();
141141

142142
/// <summary>
143143
/// Gets a <see cref="Dictionary{TKey, TValue}"/> containing cached <see cref="Player"/> and their user ids.
@@ -2913,6 +2913,26 @@ public bool TryAddCandy(CandyKindID candyType)
29132913
return true;
29142914
}
29152915

2916+
/// <summary>
2917+
/// Removes specific candy from the players <see cref="Scp330"/>.
2918+
/// </summary>
2919+
/// <param name="candyType">The <see cref="CandyKindID"/> to remove.</param>
2920+
/// <param name="removeAll">Remove all candy of that type.</param>
2921+
/// <returns><see langword="true"/> if a candy was removed.</returns>
2922+
public bool TryRemoveCandу(CandyKindID candyType, bool removeAll = false)
2923+
{
2924+
foreach (Item item in Items)
2925+
{
2926+
if (item is not Scp330 bag)
2927+
continue;
2928+
2929+
if (bag.RemoveCandy(candyType, removeAll) > 0)
2930+
return true;
2931+
}
2932+
2933+
return false;
2934+
}
2935+
29162936
/// <summary>
29172937
/// Resets the player's inventory to the provided list of items, clearing any items it already possess.
29182938
/// </summary>

EXILED/Exiled.API/Features/Server.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,20 @@ public static int MaxPlayerCount
174174
/// Read the VSR for more info about its usage.
175175
/// </remarks>
176176
/// </summary>
177+
[Obsolete("This field has been deleted because it used the wrong field (TransparentlyModded)")]
177178
public static bool IsHeavilyModded
179+
{
180+
get => false;
181+
set => _ = value;
182+
}
183+
184+
/// <summary>
185+
/// Gets or sets a value indicating whether the server is marked as Transparently Modded.
186+
/// <remarks>
187+
/// It is not used now, wait for a new VSR update.
188+
/// </remarks>
189+
/// </summary>
190+
public static bool IsTransparentlyModded
178191
{
179192
get => ServerConsole.TransparentlyModdedServerConfig;
180193
set => ServerConsole.TransparentlyModdedServerConfig = value;

EXILED/Exiled.API/Features/Toys/AdminToy.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ public Vector3 Scale
115115
}
116116
}
117117

118+
/// <summary>
119+
/// Gets the <see cref="UnityEngine.GameObject"/> of the toy.
120+
/// </summary>
121+
public GameObject GameObject => AdminToyBase.gameObject;
122+
123+
/// <summary>
124+
/// Gets the <see cref="UnityEngine.Transform"/> of the toy.
125+
/// </summary>
126+
public Transform Transform => AdminToyBase.transform;
127+
118128
/// <summary>
119129
/// Gets or sets the movement smoothing value of the toy.
120130
/// <para>

0 commit comments

Comments
 (0)