Skip to content

Commit

Permalink
13.1.x (#226)
Browse files Browse the repository at this point in the history
* Update

* Roles

* Progress on 13.0.0 changes

* Update

* Update 17.04

* Update

* Fix

* Docs update

* Update

* Update Changes

* Update template, fixes.

* Fixes

* Fix

* Add ReserverdSlots.cs Whitelist.cs

* Seperate events into folders.

* Remove not used usings

* Final changes

* Debug logs...

* Master changes

* Update template plugin to properly reflect eventargs

* Update ItemPickup to reflect 13.1 changes
Increment version

* Resolving issue 203 (#204)

resolves #203

* Revert "Resolving issue 203 (#204)"

This reverts commit 32e4e07.

* IsOffline (#207)

* Update package version

* bump version
remove heavily modded field due to removal from basegame

* bump packageversion for nuget

* Update dotnet.yml

* Update dotnet.yml

* Update download-files.txt

* 13.3.0 compatability

* update packageversion to reflect pluginapi version

---------

Co-authored-by: ced777ric <[email protected]>
Co-authored-by: SrLicht <[email protected]>
Co-authored-by: ced777ric <[email protected]>
  • Loading branch information
4 people authored Dec 5, 2023
1 parent f30a546 commit 2749a86
Show file tree
Hide file tree
Showing 460 changed files with 119,065 additions and 3,620 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "master", "dev", "dev2" ]

env:
DEPOT_DOWNLOADER_VERSION: 2.4.7
DEPOT_DOWNLOADER_VERSION: 2.5.0
SL_REFERENCES: D:\a\NwPluginAPI\SCPSL_REFERENCES\SCPSL_Data\Managed
UNITY_REFERENCES: D:\a\NwPluginAPI\SCPSL_REFERENCES\SCPSL_Data\Managed

Expand All @@ -32,7 +32,7 @@ jobs:
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path D:\a\NwPluginAPI\SCPSL_REFERENCES
Start-Process -NoNewWindow -Wait -FilePath "D:\a\NwPluginAPI\DepotDownloader\DepotDownloader.exe" -WorkingDirectory "D:\a\NwPluginAPI\DepotDownloader" -ArgumentList '-app 996560','-beta nightly','-betapassword ${{ secrets.NIGHTLYPASSWORD }}','-dir D:\a\NwPluginAPI\SCPSL_REFERENCES','-filelist "${{ github.workspace }}\download-files.txt"'
Start-Process -NoNewWindow -Wait -FilePath "D:\a\NwPluginAPI\DepotDownloader\DepotDownloader.exe" -WorkingDirectory "D:\a\NwPluginAPI\DepotDownloader" -ArgumentList '-app 996560','-dir D:\a\NwPluginAPI\SCPSL_REFERENCES','-filelist "${{ github.workspace }}\download-files.txt"'
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -41,4 +41,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: PluginAPI
path: ${{ github.workspace }}/NwPluginAPI/bin/Release/net48/PluginAPI.dll
path: ${{ github.workspace }}/NwPluginAPI/bin/Release/net48/PluginAPI.dll
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using NWPluginAPI.Analyzers.Enums;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Simplification;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;

Expand Down
10 changes: 5 additions & 5 deletions Analyzers/NwPluginAPI.Analyzers.Generator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using PluginAPI.Events;
using PluginAPI.Events;
using System.Text;

StringBuilder builder = new StringBuilder();
Expand Down Expand Up @@ -35,19 +35,19 @@

foreach (var ev in EventManager.Events)
{
if (ev.Value.Parameters.Length == 0)
if (ev.Value.Parameters.Count == 0)
builder.AppendLine(" { " + (int)ev.Key + ", new Event() },");
else
{
builder.AppendLine(" { " + (int)ev.Key + ", new Event(");
for (int x = 0; x < ev.Value.Parameters.Length; x++)
for (int x = 0; x < ev.Value.Parameters.Count; x++)
{
var param = ev.Value.Parameters[x];

if (param.BaseType.IsArray)
builder.AppendLine(" new EventParameter(\"" + param.BaseType.GetElementType()?.FullName + "\", true, \"" + param.DefaultIdentifierName + "\")" + (x == (ev.Value.Parameters.Length - 1) ? ") }," : ","));
builder.AppendLine(" new EventParameter(\"" + param.BaseType.GetElementType()?.FullName + "\", true, \"" + param.DefaultIdentifierName + "\")" + (x == (ev.Value.Parameters.Count - 1) ? ") }," : ","));
else
builder.AppendLine(" new EventParameter(\"" + param.BaseType.FullName + "\", false, \"" + param.DefaultIdentifierName + "\")" + (x == (ev.Value.Parameters.Length - 1) ? ") }," : ","));
builder.AppendLine(" new EventParameter(\"" + param.BaseType.FullName + "\", false, \"" + param.DefaultIdentifierName + "\")" + (x == (ev.Value.Parameters.Count - 1) ? ") }," : ","));
}
}
}
Expand Down
206 changes: 206 additions & 0 deletions NwPluginAPI.Docs/log.txt

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions NwPluginAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NwPluginAPI.Analyzers", "An
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NwPluginAPI.Analyzers.Generator", "Analyzers\NwPluginAPI.Analyzers.Generator\NwPluginAPI.Analyzers.Generator.csproj", "{9638A1ED-142B-4487-8DAA-A24E1F42E04C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NwPluginAPI.Docs", "NwPluginAPI.Docs\NwPluginAPI.Docs.csproj", "{3D50BC79-9168-47F3-9805-E0D7502916DF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NwPluginAPI.Docs", "NwPluginAPI.Docs\NwPluginAPI.Docs.csproj", "{3D50BC79-9168-47F3-9805-E0D7502916DF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5079D346-050F-45DF-AF41-067C992CAAFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5079D346-050F-45DF-AF41-067C992CAAFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5079D346-050F-45DF-AF41-067C992CAAFC}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{5079D346-050F-45DF-AF41-067C992CAAFC}.Debug|Any CPU.Build.0 = Release|Any CPU
{5079D346-050F-45DF-AF41-067C992CAAFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5079D346-050F-45DF-AF41-067C992CAAFC}.Release|Any CPU.Build.0 = Release|Any CPU
{E0F1B55A-971A-418D-B45A-CB2C702B6364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0F1B55A-971A-418D-B45A-CB2C702B6364}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0F1B55A-971A-418D-B45A-CB2C702B6364}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{E0F1B55A-971A-418D-B45A-CB2C702B6364}.Debug|Any CPU.Build.0 = Release|Any CPU
{E0F1B55A-971A-418D-B45A-CB2C702B6364}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0F1B55A-971A-418D-B45A-CB2C702B6364}.Release|Any CPU.Build.0 = Release|Any CPU
{4BE5D776-39A9-4532-9390-C59FB45E9571}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BE5D776-39A9-4532-9390-C59FB45E9571}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BE5D776-39A9-4532-9390-C59FB45E9571}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{4BE5D776-39A9-4532-9390-C59FB45E9571}.Debug|Any CPU.Build.0 = Release|Any CPU
{4BE5D776-39A9-4532-9390-C59FB45E9571}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BE5D776-39A9-4532-9390-C59FB45E9571}.Release|Any CPU.Build.0 = Release|Any CPU
{9638A1ED-142B-4487-8DAA-A24E1F42E04C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9638A1ED-142B-4487-8DAA-A24E1F42E04C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9638A1ED-142B-4487-8DAA-A24E1F42E04C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9638A1ED-142B-4487-8DAA-A24E1F42E04C}.Release|Any CPU.Build.0 = Release|Any CPU
{3D50BC79-9168-47F3-9805-E0D7502916DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D50BC79-9168-47F3-9805-E0D7502916DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D50BC79-9168-47F3-9805-E0D7502916DF}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{3D50BC79-9168-47F3-9805-E0D7502916DF}.Debug|Any CPU.Build.0 = Release|Any CPU
{3D50BC79-9168-47F3-9805-E0D7502916DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D50BC79-9168-47F3-9805-E0D7502916DF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
Expand Down
5 changes: 0 additions & 5 deletions NwPluginAPI/Commands/ReloadCommand.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System.Linq;
using System.Reflection;
using PluginAPI.Core;
using PluginAPI.Core.Attributes;

namespace PluginAPI.Commands
{
using CommandSystem;
Expand Down
7 changes: 7 additions & 0 deletions NwPluginAPI/Core/Attributes/EventArgument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

namespace PluginAPI.Core.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class EventArgument : Attribute { }
}
4 changes: 3 additions & 1 deletion NwPluginAPI/Core/Attributes/PluginEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace PluginAPI.Core.Attributes
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class PluginEvent : Attribute
{
public ServerEventType EventType { get; }
public ServerEventType EventType { get; } = ServerEventType.None;

/// <summary>
/// Initializes a new instance of the <see cref="PluginEvent"/> class.
Expand All @@ -19,5 +19,7 @@ public PluginEvent(ServerEventType eventType)
{
EventType = eventType;
}

public PluginEvent() { }
}
}
34 changes: 34 additions & 0 deletions NwPluginAPI/Core/Attributes/PluginRole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using PluginAPI.Enums;
using System;

namespace PluginAPI.Core.Attributes
{
/// <summary>
/// Marks the plugin role.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class PluginRole : Attribute
{
public RoleRegisterType RegisterType;
public int RoleId;

/// <summary>
/// Initializes a new instance of the <see cref="PluginRole"/> class.
/// </summary>
/// <param name="registerType">The type of registered role.</param>
public PluginRole(RoleRegisterType registerType)
{
RegisterType = registerType;
}

/// <summary>
/// Initializes a new instance of the <see cref="PluginRole"/> class.
/// </summary>
/// <param name="registerType">The type of registered role.</param>
public PluginRole(RoleRegisterType registerType, int roleId)
{
RegisterType = registerType;
RoleId = roleId;
}
}
}
3 changes: 0 additions & 3 deletions NwPluginAPI/Core/DamageManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
namespace PluginAPI.Core
{
using Footprinting;
using PlayerStatsSystem;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Manages damage for a player.
Expand Down
4 changes: 2 additions & 2 deletions NwPluginAPI/Core/Facility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static void Reset()
/// </summary>
public static void TurnOffAllLights(float duration = 0)
{
foreach (FlickerableLightController flickerableLightController in FlickerableLightController.Instances)
foreach (RoomLightController flickerableLightController in RoomLightController.Instances)
{
if (duration > 0)
{
Expand All @@ -180,7 +180,7 @@ public static void TurnOffAllLights(float duration = 0)
/// </summary>
public static void TurnOnAllLights()
{
foreach (FlickerableLightController flickerableLightController in FlickerableLightController.Instances)
foreach (RoomLightController flickerableLightController in RoomLightController.Instances)
{
flickerableLightController.NetworkLightsEnabled = true;
}
Expand Down
21 changes: 21 additions & 0 deletions NwPluginAPI/Core/Factories/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ public T GetOrAdd(IGameComponent component)
return ent;
}

/// <summary>
/// Gets entity from factory.
/// </summary>
/// <param name="component">The game component.</param>
/// <returns>Entity.</returns>
public T Get(IGameComponent component)
{
if (Entities.TryGetValue(component, out T entity))
return entity;

if (component is ReferenceHub hb && hb.isLocalPlayer)
{
if (DefaultServer == null)
DefaultServer = Create(component);

return DefaultServer;
}

return default(T);
}

/// <summary>
/// Adds missing entity if not exists.
/// </summary>
Expand Down
10 changes: 8 additions & 2 deletions NwPluginAPI/Core/Factories/PlayerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace PluginAPI.Core.Factories
/// <summary>
/// A factory to create <see cref="IPlayer"/>'s.
/// </summary>
public class PlayerFactory : Factory<IPlayer>
public class PlayerFactory : Factory<Player>
{
public virtual Type BaseType { get; } = typeof(Player);

Expand All @@ -15,6 +15,12 @@ public class PlayerFactory : Factory<IPlayer>
/// </summary>
/// <param name="component">The <see cref="IGameComponent"/>.</param>
/// <returns>The created <see cref="IPlayer"/>.</returns>
public override IPlayer Create(IGameComponent component) => new Player(component);
public override Player Create(IGameComponent component)
{
if (component is ReferenceHub hub && hub.isLocalPlayer)
return new Server(hub);

return new Player(component);
}
}
}
8 changes: 4 additions & 4 deletions NwPluginAPI/Core/FactoryManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace PluginAPI.Core
namespace PluginAPI.Core
{
using System;
using System.Collections.Generic;
using Factories;
using Interfaces;
using Events;

/// <summary>
Expand Down Expand Up @@ -111,8 +110,9 @@ static void RemovePlayer(ReferenceHub obj)
{
foreach (var factory in PlayerFactories.Values)
{
if (!factory.Entities.TryGetValue(obj, out IPlayer plr))
continue;
var plr = factory.Get(obj);

if (plr == null) continue;

try
{
Expand Down
60 changes: 11 additions & 49 deletions NwPluginAPI/Core/Interfaces/IPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,28 @@
namespace PluginAPI.Core.Interfaces
{
using UnityEngine;

/// <summary>
/// Defines a player.
/// </summary>
public interface IPlayer : IEntity
{
/// <summary>
/// Gets if player is dedicated server.
/// Gets if the player is in the server.
/// </summary>
bool IsServer { get; }

bool IsOffline { get; }
/// <summary>
/// Gets the player's <see cref="global::ReferenceHub"/>.
/// Gets the player's user id.
/// </summary>
ReferenceHub ReferenceHub { get; }

string UserId { get; }
/// <summary>
/// Gets the player's <see cref="UnityEngine.GameObject"/>.
/// Gets the player's name.
/// </summary>
GameObject GameObject { get; }

string Nickname { get; }
/// <summary>
/// Gets player temporary data storage.
/// Gets the player's ip address.
/// </summary>
DataStorage TemporaryData { get; }

/// <summary>
/// Executed when player object is created.
/// </summary>
void OnStart();

/// <summary>
/// Executed when player object is destroyed.
/// </summary>
void OnDestroy();

/// <summary>
/// Executed every frame.
/// </summary>
void OnUpdate();

/// <summary>
/// Executed after all OnUpdate functions have been called.
/// </summary>
void OnLateUpdate();

/// <summary>
/// Executed with the frequency of the physics system.
/// <remarks>Unity's physics engine runs at 50hz by default.</remarks>
/// </summary>
void OnFixedUpdate();

/// <summary>
/// Gets the <see cref="UnityEngine.MonoBehaviour"/> and caches it.
/// </summary>
T GetComponent<T>(bool globalSearch = false) where T : MonoBehaviour;

/// <summary>
/// Gets the <see cref="UnityEngine.MonoBehaviour"/> and caches it.
/// </summary>
bool TryGetComponent<T>(out T component, bool globalSearch = false) where T : MonoBehaviour;
string IpAddress { get; }
}
}
Loading

0 comments on commit 2749a86

Please sign in to comment.