Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/nuget/EXILED/Lib.Harmony-2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 authored Nov 22, 2024
2 parents 5d9370a + 15b2b67 commit fc962bf
Show file tree
Hide file tree
Showing 41 changed files with 4,903 additions and 78 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ GitHub:
- any-glob-to-any-file: .github/** # Any modifications to github related files

Events: # Add the 'Events' label
- changed-files:
- any-glob-to-any-file: EXILED/Exiled.Events/** # Any Modifications to events
- all-globs-to-all-files: '!EXILED/Exiled.Events/Patches/**/*' # Exept modifications to transpiler files

- all:
- changed-files:
- any-glob-to-any-file: 'EXILED/Exiled.Events/**/*'
- all-globs-to-all-files: '!EXILED/Exiled.Events/Patches/**/*'
API: # Add the 'API' label
- changed-files:
- any-glob-to-any-file: EXILED/Exiled.API/** # Any modifications to the API
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
shell: pwsh
run: |
./build.ps1 -BuildNuGet
$File = (Get-ChildItem -Path . -Include 'EXILED-OFFICIAL.*.nupkg' -Recurse).Name
$File = (Get-ChildItem -Path . -Include 'ExMod.Exiled.*.nupkg' -Recurse).Name
Out-File -FilePath ${{ github.env }} -InputObject "PackageFile=$File" -Encoding utf-8 -Append
- name: Upload nuget package
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Dotnet Setup
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.x

- run: dotnet tool update -g docfx

- name: Setup .NET Core SDK
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
shell: pwsh
run: |
./build.ps1 -BuildNuGet
$File = (Get-ChildItem -Path . -Include 'EXILED-OFFICIAL.*.nupkg' -Recurse).Name
$File = (Get-ChildItem -Path . -Include 'ExMod.Exiled.*.nupkg' -Recurse).Name
Out-File -FilePath ${{ github.env }} -InputObject "PackageFile=$File" -Encoding utf-8 -Append
- name: Upload artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
shell: pwsh
run: |
./build.ps1 -BuildNuGet
$File = (Get-ChildItem -Path . -Include 'EXILED-OFFICIAL.*.nupkg' -Recurse).Name
$File = (Get-ChildItem -Path . -Include 'ExMod.Exiled.*.nupkg' -Recurse).Name
Out-File -FilePath ${{ github.env }} -InputObject "PackageFile=$File" -Encoding utf-8 -Append
- name: Push NuGet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
shell: pwsh
run: |
./build.ps1
$File = (Get-ChildItem -Path . -Include 'EXILED-OFFICIAL.*.nupkg' -Recurse).Name
$File = (Get-ChildItem -Path . -Include 'ExMod.Exiled.*.nupkg' -Recurse).Name
Out-File -FilePath ${{ github.env }} -InputObject "PackageFile=$File" -Encoding utf-8 -Append
- name: Get references
Expand Down
2 changes: 1 addition & 1 deletion EXILED/EXILED.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">8.12.2</Version>
<Version Condition="$(Version) == ''">8.14.1</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

Expand Down
8 changes: 8 additions & 0 deletions EXILED/EXILED.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exiled.CreditTags", "Exiled
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exiled.CustomRoles", "Exiled.CustomRoles\Exiled.CustomRoles.csproj", "{417C3309-8B93-4218-A1D1-D4BB7B09BE0F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "docs", "docs\docs.csproj", "{BE130A80-6819-44C6-AA1B-BF068DEA67FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -74,6 +76,12 @@ Global
{417C3309-8B93-4218-A1D1-D4BB7B09BE0F}.Installer|Any CPU.ActiveCfg = Installer|Any CPU
{417C3309-8B93-4218-A1D1-D4BB7B09BE0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{417C3309-8B93-4218-A1D1-D4BB7B09BE0F}.Release|Any CPU.Build.0 = Release|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Installer|Any CPU.ActiveCfg = Installer|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Installer|Any CPU.Build.0 = Installer|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions EXILED/Exiled.API/Features/Items/Scp330.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ internal Scp330()
/// </summary>
public CandyKindID ExposedType { get; set; } = CandyKindID.None;

/// <summary>
/// Gets or sets the candy that will be added to the bag. Used for events.
/// </summary>
internal CandyKindID CandyToAdd { get; set; } = CandyKindID.None;

/// <summary>
/// Adds a specific candy to the bag.
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions EXILED/Exiled.API/Features/Lockers/Chamber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ public Chamber(LockerChamber chamber, Locker locker)
/// <inheritdoc/>
public Quaternion Rotation => Base.transform.rotation;

/// <summary>
/// Gets the <see cref="Chamber"/> <see cref="UnityEngine.GameObject"/>.
/// </summary>
public GameObject GameObject => Base.gameObject;

/// <summary>
/// Gets the <see cref="Chamber"/> <see cref="UnityEngine.Transform"/>.
/// </summary>
public Transform Transform => Base.transform;

/// <summary>
/// Gets or sets all pickups that should be spawned when the door is initially opened.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions EXILED/Exiled.API/Features/Lockers/Locker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public Locker(BaseLocker locker)
/// </summary>
public LockerType Type { get; }

/// <summary>
/// Gets the <see cref="Locker"/> <see cref="UnityEngine.GameObject"/>.
/// </summary>
public GameObject GameObject => Base.gameObject;

/// <summary>
/// Gets the <see cref="Locker"/> <see cref="UnityEngine.Transform"/>.
/// </summary>
Expand Down
116 changes: 108 additions & 8 deletions EXILED/Exiled.API/Features/Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Exiled.API.Features
using CentralAuth;
using CommandSystem;
using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features.Components;
using Exiled.API.Features.Roles;
using Footprinting;
Expand Down Expand Up @@ -142,6 +141,7 @@ public override Vector3 Position
/// <param name="userId">The userID of the NPC.</param>
/// <param name="position">The position to spawn the NPC.</param>
/// <returns>The <see cref="Npc"/> spawned.</returns>
[Obsolete("This metod is marked as obsolet due to a bug that make player have the same id. Use Npc.Spawn(string) instead")]
public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId = PlayerAuthenticationManager.DedicatedId, Vector3? position = null)
{
GameObject newObject = UnityEngine.Object.Instantiate(Mirror.NetworkManager.singleton.playerPrefab);
Expand Down Expand Up @@ -208,18 +208,118 @@ public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId
return npc;
}

/// <summary>
/// Spawns an NPC based on the given parameters.
/// </summary>
/// <param name="name">The name of the NPC.</param>
/// <param name="role">The RoleTypeId of the NPC, defaulting to None.</param>
/// <param name="ignored">Whether the NPC should be ignored by round ending checks.</param>
/// <param name="userId">The userID of the NPC for authentication. Defaults to the Dedicated ID.</param>
/// <param name="position">The position where the NPC should spawn. If null, the default spawn location is used.</param>
/// <returns>The <see cref="Npc"/> spawned.</returns>
public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ignored = false, string userId = PlayerAuthenticationManager.DedicatedId, Vector3? position = null)
{
GameObject newObject = UnityEngine.Object.Instantiate(Mirror.NetworkManager.singleton.playerPrefab);

Npc npc = new(newObject)
{
IsNPC = true,
};

FakeConnection fakeConnection = new(npc.Id);

try
{
if (userId == PlayerAuthenticationManager.DedicatedId)
{
npc.ReferenceHub.authManager.SyncedUserId = userId;
try
{
npc.ReferenceHub.authManager.InstanceMode = ClientInstanceMode.DedicatedServer;
}
catch (Exception e)
{
Log.Debug($"Ignore: {e.Message}");
}
}
else
{
npc.ReferenceHub.authManager.InstanceMode = ClientInstanceMode.Unverified;
npc.ReferenceHub.authManager._privUserId = userId == string.Empty ? $"Dummy-{npc.Id}@localhost" : userId;
}
}
catch (Exception e)
{
Log.Debug($"Ignore: {e.Message}");
}

try
{
npc.ReferenceHub.roleManager.InitializeNewRole(RoleTypeId.None, RoleChangeReason.None);
}
catch (Exception e)
{
Log.Debug($"Ignore: {e.Message}");
}

NetworkServer.AddPlayerForConnection(fakeConnection, newObject);

npc.ReferenceHub.nicknameSync.Network_myNickSync = name;
Dictionary.Add(newObject, npc);

Timing.CallDelayed(0.5f, () =>
{
npc.Role.Set(role, SpawnReason.RoundStart, position is null ? RoleSpawnFlags.All : RoleSpawnFlags.AssignInventory);

if (position is not null)
npc.Position = position.Value;
});

if (ignored)
Round.IgnoredPlayers.Add(npc.ReferenceHub);

return npc;
}

/// <summary>
/// Destroys all NPCs currently spawned.
/// </summary>
public static void DestroyAll()
{
foreach (Npc npc in List)
npc.Destroy();
}

/// <summary>
/// Destroys the NPC.
/// </summary>
public void Destroy()
{
NetworkConnectionToClient conn = ReferenceHub.connectionToClient;
if (ReferenceHub._playerId.Value <= RecyclablePlayerId._autoIncrement)
ReferenceHub._playerId.Destroy();
ReferenceHub.OnDestroy();
CustomNetworkManager.TypedSingleton.OnServerDisconnect(conn);
Dictionary.Remove(GameObject);
Object.Destroy(GameObject);
try
{
Round.IgnoredPlayers.Remove(ReferenceHub);
NetworkConnectionToClient conn = ReferenceHub.connectionToClient;
ReferenceHub.OnDestroy();
CustomNetworkManager.TypedSingleton.OnServerDisconnect(conn);
Dictionary.Remove(GameObject);
Object.Destroy(GameObject);
}
catch (Exception e)
{
Log.Error($"Error while destroying a NPC: {e.Message}");
}
}

/// <summary>
/// Schedules the destruction of the NPC after a delay.
/// </summary>
/// <param name="time">The delay in seconds before the NPC is destroyed.</param>
public void LateDestroy(float time)
{
Timing.CallDelayed(time, () =>
{
this?.Destroy();
});
}
}
}
68 changes: 51 additions & 17 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -715,23 +715,7 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences
public Vector3 Scale
{
get => ReferenceHub.transform.localScale;
set
{
if (value == Scale)
return;

try
{
ReferenceHub.transform.localScale = value;

foreach (Player target in List)
Server.SendSpawnMessage?.Invoke(null, new object[] { NetworkIdentity, target.Connection });
}
catch (Exception exception)
{
Log.Error($"{nameof(Scale)} error: {exception}");
}
}
set => SetScale(value, List);
}

/// <summary>
Expand Down Expand Up @@ -2070,6 +2054,56 @@ public void Disconnect(string reason = null) =>
/// </summary>
public void ResetStamina() => Stamina = StaminaStat.MaxValue;

/// <summary>
/// Sets the scale of a player on the server side.
/// </summary>
/// <param name="scale">The scale to set.</param>
/// <param name="viewers">Who should see the updated scale.</param>
public void SetScale(Vector3 scale, IEnumerable<Player> viewers)
{
if (scale == Scale)
return;

try
{
ReferenceHub.transform.localScale = scale;

foreach (Player target in viewers)
Server.SendSpawnMessage?.Invoke(null, new object[] { NetworkIdentity, target.Connection });
}
catch (Exception exception)
{
Log.Error($"{nameof(SetScale)} error: {exception}");
}
}

/// <summary>
/// Sets the scale of the player for other players.
/// </summary>
/// <param name="fakeScale">The scale to set to.</param>
/// <param name="viewers">Who should see the fake scale.</param>
public void SetFakeScale(Vector3 fakeScale, IEnumerable<Player> viewers)
{
Vector3 currentScale = Scale;

if (fakeScale == currentScale)
return;

try
{
ReferenceHub.transform.localScale = fakeScale;

foreach (Player target in viewers)
Server.SendSpawnMessage.Invoke(null, new object[] { NetworkIdentity, target.Connection });

ReferenceHub.transform.localScale = currentScale;
}
catch (Exception ex)
{
Log.Error($"{nameof(SetFakeScale)}: {ex}");
}
}

/// <summary>
/// Gets a user's SCP preference.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions EXILED/Exiled.API/Features/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public static class Round
/// </summary>
public static bool IsLobby => !(IsEnded || IsStarted);

/// <summary>
/// Gets a value indicating the last ClassList.
/// </summary>
/// <remarks>this value is only updated when Round is <see cref="InProgress"/> and not <see cref="IsLocked"/>.</remarks>
public static RoundSummary.SumInfo_ClassList LastClassList { get; internal set; }

/// <summary>
/// Gets or sets a value indicating the amount of Chaos Targets remaining.
/// </summary>
Expand Down Expand Up @@ -121,6 +127,7 @@ public static int Kills
public static int SurvivingSCPs
{
get => RoundSummary.SurvivingSCPs;
[Obsolete("This value is rewritten by NW every time it's used", true)]
set => RoundSummary.SurvivingSCPs = value;
}

Expand Down
Loading

0 comments on commit fc962bf

Please sign in to comment.