Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
BetterDrops 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus-QC committed Oct 19, 2022
1 parent 2aef9fb commit f6ac290
Show file tree
Hide file tree
Showing 17 changed files with 389 additions and 397 deletions.
39 changes: 18 additions & 21 deletions BetterDrops/BetterDrops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,36 @@ public class BetterDrops : Plugin<PluginConfig>
public override string Author { get; } = "Jesus-QC";
public override string Name { get; } = "BetterDrops";
public override string Prefix { get; } = "better_drops";
public override Version Version { get; } = new Version(1, 0, 3);
public override Version RequiredExiledVersion { get; } = new Version(4, 1, 7);

public static PluginConfig Cfg;
public static EventManager EventManager;
public override Version Version { get; } = new Version(2, 0, 0);
public override Version RequiredExiledVersion { get; } = new Version(5, 0, 0);

private EventManager _eventManager;

public override void OnEnabled()
{
Cfg = Config;

EventManager = new EventManager();

Server.RestartingRound += EventManager.OnRestartingRound;
Server.RespawningTeam += EventManager.OnRespawningTeam;
Server.RoundStarted += EventManager.OnStartingRound;
Exiled.API.Features.Server.IsHeavilyModded = true;

_eventManager = new EventManager(this);

Physics.IgnoreLayerCollision(Config.DropLayer, 16); // Invisible barriers
Server.RestartingRound += _eventManager.OnRestartingRound;
Server.RespawningTeam += _eventManager.OnRespawningTeam;
Server.RoundStarted += _eventManager.OnStartingRound;

Physics.IgnoreLayerCollision(16, 6, true);

base.OnEnabled();
}

public override void OnDisabled()
{
Physics.IgnoreLayerCollision(Config.DropLayer, 16, false);
Physics.IgnoreLayerCollision(16, 6, false);

Server.RestartingRound -= EventManager.OnRestartingRound;
Server.RespawningTeam -= EventManager.OnRespawningTeam;
Server.RoundStarted -= EventManager.OnStartingRound;

EventManager = null;

Cfg = null;
Server.RestartingRound -= _eventManager.OnRestartingRound;
Server.RespawningTeam -= _eventManager.OnRespawningTeam;
Server.RoundStarted -= _eventManager.OnStartingRound;

_eventManager = null;

base.OnDisabled();
}
}
Expand Down
77 changes: 36 additions & 41 deletions BetterDrops/BetterDrops.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,81 +33,76 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Assembly-CSharp-Publicized.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>$(EXILED_REFERENCES)\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\CommandSystem.Core.dll</HintPath>
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\CommandSystem.Core.dll</HintPath>
</Reference>
<Reference Include="Exiled.API, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.API.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.API, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.API.dll</HintPath>
</Reference>
<Reference Include="Exiled.Bootstrap, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.Bootstrap.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.Bootstrap, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.Bootstrap.dll</HintPath>
</Reference>
<Reference Include="Exiled.CreditTags, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.CreditTags.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.CreditTags, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.CreditTags.dll</HintPath>
</Reference>
<Reference Include="Exiled.CustomItems, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.CustomItems.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.CustomItems, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.CustomItems.dll</HintPath>
</Reference>
<Reference Include="Exiled.CustomRoles, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.CustomRoles.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.CustomRoles, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.CustomRoles.dll</HintPath>
</Reference>
<Reference Include="Exiled.Events, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.Events.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.Events, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.Events.dll</HintPath>
</Reference>
<Reference Include="Exiled.Loader, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.Loader.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.Loader, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.Loader.dll</HintPath>
</Reference>
<Reference Include="Exiled.Permissions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.Permissions.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.Permissions, Version=5.3.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.Permissions.dll</HintPath>
</Reference>
<Reference Include="Exiled.Updater, Version=3.1.1.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EXILED.5.0.0-alpha.4\lib\net472\Exiled.Updater.dll</HintPath>
<Private>True</Private>
<Reference Include="Exiled.Updater, Version=3.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\Exiled.Updater.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Steamworks.Win64, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Facepunch.Steamworks.Win64.dll</HintPath>
<HintPath>$(EXILED_REFERENCES)\Facepunch.Steamworks.Win64.dll</HintPath>
</Reference>
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
<HintPath>$(EXILED_REFERENCES)\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EXILED.5.3.1\lib\net472\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>$(EXILED_REFERENCES)\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>$(EXILED_REFERENCES)\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>$(EXILED_REFERENCES)\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BetterDrops.cs" />
<Compile Include="Commands\BetterDropsCommand.cs" />
<Compile Include="Commands\SpawnCommand.cs" />
<Compile Include="Configs\DropConfig.cs" />
<Compile Include="Configs\RandomDropConfigs.cs" />
<Compile Include="Features\Components\BalloonController.cs" />
<Compile Include="Features\Components\DisappearController.cs" />
<Compile Include="Features\Components\DropController.cs" />
<Compile Include="Features\Data\Drop.cs" />
<Compile Include="Features\Data\SimplifiedLight.cs" />
<Compile Include="Features\Data\SimplifiedToy.cs" />
<Compile Include="Features\EventManager.cs" />
<Compile Include="Features\DropExtensions.cs" />
<Compile Include="Features\Extensions\DropExtensions.cs" />
<Compile Include="PluginConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
26 changes: 26 additions & 0 deletions BetterDrops/Commands/BetterDropsCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using CommandSystem;

namespace BetterDrops.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class BetterDropsCommand : ParentCommand
{
public BetterDropsCommand() => LoadGeneratedCommands();

public sealed override void LoadGeneratedCommands()
{
RegisterCommand(SpawnCommand.Instance);
}

protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
response = "Please, specify a valid subcommand! Available ones: spawn";
return false;
}

public override string Command { get; } = "BetterDrops";
public override string[] Aliases { get; } = Array.Empty<string>();
public override string Description { get; } = "BetterDrops parent command.";
}
}
52 changes: 10 additions & 42 deletions BetterDrops/Commands/SpawnCommand.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,26 @@
using System;
using BetterDrops.Features.Extensions;
using CommandSystem;
using BetterDrops.Features.Data;
using BetterDrops.Features;
using Exiled.Permissions.Extensions;
using Exiled.API.Features;
using UnityEngine;
using Random = UnityEngine.Random;

namespace BetterDrops.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(ClientCommandHandler))]
public class SpawnCommand : ICommand
{
public string Command { get; } = "SpawnDrop";
public static SpawnCommand Instance { get; } = new SpawnCommand();

public string Command { get; } = "spawn";
public string[] Aliases { get; } = Array.Empty<string>();
public string Description { get; } = "Spawns drops";
public string Description { get; } = "Spawn a drop";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
/*
* - spawndrop X Y Z
* - spawndrop mtf
* - spawndrop chaos
*/
DropExtensions.SpawnDrop(Player.Get(sender).Position + Vector3.up * 10f, Random.ColorHSV(), new [] { ItemType.Coin });

if (!sender.CheckPermission("bd.spawndrop"))
{
response = "You don't have permission to execute this command. Required permission: bd.spawndrop";
return false;
}

if (arguments.Count == 1)
{
if (arguments.At(0).ToLower() == "mtf")
new Drop(Team.MTF.GetRandomDropSpawnPoint()).Spawn();
else if (arguments.At(0).ToLower() == "chaos")
new Drop(Team.CHI.GetRandomDropSpawnPoint()).Spawn();

response = "Done!";
return true;
}

if(arguments.Count > 2)
{
if (!float.TryParse(arguments.At(0), out var x) || !float.TryParse(arguments.At(1), out var y) || !float.TryParse(arguments.At(2), out var z))
{
response = "<color=red>There was an issue parsing the spawn position.</color>";
return true;
}

new Drop(new Vector3(x, y, z)).Spawn();
response = $"Done! ({x} {y} {z})";
return true;
}

response = "Usage:\n- spawndrop X Y Z\n- spawndrop mtf/chaos";
response = "Spawned!";
return true;
}
}
Expand Down
23 changes: 23 additions & 0 deletions BetterDrops/Configs/DropConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.ComponentModel;

namespace BetterDrops.Configs
{
public class DropConfig
{
[Description("Is the drop wave enabled.")]
public bool IsEnabled { get; set; } = true;

[Description("Number of drops in the spawn wave.")]
public uint NumberOfDrops { get; set; } = 5;

[Description("Items per drop, I suggest low values, if you do stupid things with this config it is your fault.")]
public uint ItemsPerDrop { get; set; } = 1;

[Description("Drop color. (It accepts Random or hex values like '#ffffff')")]
public string Color { get; set; } = "Random";

[Description("The possible items inside the drop")]
public List<ItemType> PossibleItems { get; set; } = new List<ItemType> {ItemType.Adrenaline, ItemType.Coin, ItemType.Medkit, ItemType.GrenadeFlash, ItemType.GrenadeHE, ItemType.Radio, ItemType.Painkillers, ItemType.ArmorCombat, ItemType.ArmorHeavy, ItemType.ArmorLight, ItemType.GunRevolver, ItemType.GunShotgun, ItemType.GunAK, ItemType.GunCOM15, ItemType.GunFSP9, ItemType.GunE11SR};
}
}
20 changes: 20 additions & 0 deletions BetterDrops/Configs/RandomDropConfigs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.ComponentModel;

namespace BetterDrops.Configs
{
public class RandomDropConfigs
{
[Description("The minimum time that has to happen until the first random drop.")]
public ushort FirstRandomDropOffset { get; set; } = 120;

[Description("Minimum time between random drops.")]
public ushort MinRandomDropsInterval { get; set; } = 120;

[Description("Maximum time between random drops.")]
public ushort MaxRandomDropsInterval { get; set; } = 240;

[Description("Random drop wave settings. (Here you can disable them)")]
public DropConfig WaveSettings { get; set; } = new DropConfig();
}
}
15 changes: 6 additions & 9 deletions BetterDrops/Features/Components/BalloonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ namespace BetterDrops.Features.Components
{
public class BalloonController : MonoBehaviour
{
private float _startPos;

private void Start() => _startPos = transform.position.y;
private float _counter;

private void Update()
{
if (transform.position.y - _startPos < 15)
{
transform.position += Vector3.up * Time.deltaTime * 10;
transform.localScale += Vector3.one * Time.deltaTime * 1.25f;
}
else
transform.position += 5 * Time.deltaTime * Vector3.up;

_counter += Time.deltaTime;

if (_counter > 10)
Destroy(gameObject);
}
}
Expand Down
18 changes: 18 additions & 0 deletions BetterDrops/Features/Components/DisappearController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using UnityEngine;

namespace BetterDrops.Features.Components
{
public class DisappearController : MonoBehaviour
{
public Vector3 startPos;

private void Start()
{
Rigidbody r = gameObject.AddComponent<Rigidbody>();

Vector3 dir = transform.position - startPos;

r.AddForce(dir * 10, ForceMode.Impulse);
}
}
}
Loading

0 comments on commit f6ac290

Please sign in to comment.