Skip to content

Commit 2c56844

Browse files
committed
0Harmony library, clearance of the code
1 parent 359cdf6 commit 2c56844

File tree

5 files changed

+3118
-22
lines changed

5 files changed

+3118
-22
lines changed

AntiLock.csproj

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,49 @@
2626
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2727
<DebugType>pdbonly</DebugType>
2828
<Optimize>true</Optimize>
29-
<OutputPath>bin\Release\</OutputPath>
29+
<OutputPath>bin\Release\Plugins\</OutputPath>
3030
<DefineConstants>TRACE</DefineConstants>
3131
<ErrorReport>prompt</ErrorReport>
3232
<WarningLevel>4</WarningLevel>
3333
<Prefer32Bit>false</Prefer32Bit>
3434
</PropertyGroup>
3535
<ItemGroup>
36-
<Reference Include="0Harmony_new">
37-
<HintPath>..\0Harmony_new.dll</HintPath>
36+
<Reference Include="0Harmony">
37+
<HintPath>Libraries\0Harmony2.0.2.0.dll</HintPath>
38+
<Private>False</Private>
3839
</Reference>
40+
<!-- Make your paths here or in Visual Studio -->
3941
<Reference Include="Assembly-CSharp">
4042
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\Assembly-CSharp.dll</HintPath>
43+
<Private>False</Private>
4144
</Reference>
4245
<Reference Include="Rocket.API">
4346
<HintPath>..\Rocket.API.dll</HintPath>
47+
<Private>False</Private>
4448
</Reference>
4549
<Reference Include="Rocket.Core">
4650
<HintPath>..\Rocket.Core.dll</HintPath>
51+
<Private>False</Private>
4752
</Reference>
4853
<Reference Include="Rocket.Unturned">
4954
<HintPath>..\Rocket.Unturned.dll</HintPath>
55+
<Private>False</Private>
5056
</Reference>
5157
<Reference Include="SDG.Glazier.Runtime">
5258
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\SDG.Glazier.Runtime.dll</HintPath>
59+
<Private>False</Private>
5360
</Reference>
5461
<Reference Include="SDG.NetPak.Runtime">
5562
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\SDG.NetPak.Runtime.dll</HintPath>
63+
<Private>False</Private>
5664
</Reference>
5765
<Reference Include="SDG.NetTransport">
5866
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\SDG.NetTransport.dll</HintPath>
67+
<Private>False</Private>
5968
</Reference>
6069
<Reference Include="Steamworks.NET">
6170
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\Steamworks.NET.dll</HintPath>
71+
<Private>False</Private>
6272
</Reference>
6373
<Reference Include="System" />
6474
<Reference Include="System.Core" />
@@ -68,12 +78,15 @@
6878
<Reference Include="System.Xml" />
6979
<Reference Include="UnityEngine">
7080
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\UnityEngine.dll</HintPath>
81+
<Private>False</Private>
7182
</Reference>
7283
<Reference Include="UnityEngine.CoreModule">
7384
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
85+
<Private>False</Private>
7486
</Reference>
7587
<Reference Include="UnityEngine.PhysicsModule">
7688
<HintPath>..\..\..\Steam\steamapps\common\U3DS\Unturned_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
89+
<Private>False</Private>
7790
</Reference>
7891
</ItemGroup>
7992
<ItemGroup>
@@ -83,5 +96,10 @@
8396
<Compile Include="CommandClearLocks.cs" />
8497
<Compile Include="Properties\AssemblyInfo.cs" />
8598
</ItemGroup>
99+
<ItemGroup />
100+
<ItemGroup>
101+
<None Include="Libraries\0Harmony2.0.2.0.dll" />
102+
<None Include="Libraries\0Harmony2.0.2.0.xml" />
103+
</ItemGroup>
86104
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
87105
</Project>

AskVehicleLockOverride.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static bool Check(ServerInvocationContext context)
2525
if (!vehicle?.checkDriver(steamID) ?? true) // not in the vehicle or aren't a driver
2626
return false;
2727

28-
if (vehicle.isLocked)
28+
if (vehicle.isLocked) // locked
2929
return true;
3030

3131
var group = conf.LockGroups
@@ -34,11 +34,11 @@ static bool Check(ServerInvocationContext context)
3434
.LastOrDefault();
3535

3636
int max = group == null ? conf.DefaultMaxLocks : group.MaxLocks;
37-
int count = VehicleManager.vehicles.Count(x => x.lockedOwner == steamID && x.isLocked);
37+
int lockedVehiclesCount = VehicleManager.vehicles.Count(x => x.lockedOwner == steamID && x.isLocked);
3838

39-
var maxLocks = count >= max && conf.DisplayMaxlocksNotice;
39+
var maxLocks = lockedVehiclesCount >= max && conf.DisplayMaxlocksNotice; // is locked max value of vehicles
4040
var msg = maxLocks ? inst.Translate(MaxLockedNotice, max) :
41-
(conf.DisplayLockNotice ? inst.Translate(LockedNotice, max - count - 1, max) : null);
41+
(conf.DisplayLockNotice ? inst.Translate(LockedNotice, max - lockedVehiclesCount - 1, max) : null);
4242
var color = maxLocks ? Color.red : Color.green;
4343

4444
UnturnedChat.Say(up, msg, color);

CommandClearLocks.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using static AntiLock.Main;
99
using System;
1010
using Steamworks;
11+
using System.Linq;
1112

1213
namespace AntiLock
1314
{
@@ -55,21 +56,13 @@ public void Execute(IRocketPlayer caller, string[] args)
5556
}
5657

5758
/// <returns>Amount of cleared locks</returns>
58-
int ClearLocks(UnturnedPlayer up)
59-
{
60-
int count = 0;
61-
if (up != null)
59+
int ClearLocks(UnturnedPlayer up) => up != null ?
60+
VehicleManager.vehicles.Select(v =>
6261
{
63-
foreach (var v in VehicleManager.vehicles)
64-
{
65-
if (v.lockedOwner == up.CSteamID && v.isLocked)
66-
{
67-
VehicleManager.ServerSetVehicleLock(v, CSteamID.Nil, CSteamID.Nil, false);
68-
count++;
69-
}
70-
}
71-
}
72-
return count;
73-
}
62+
var unlock = v.lockedOwner == up.CSteamID && v.isLocked;
63+
if (unlock)
64+
VehicleManager.ServerSetVehicleLock(v, CSteamID.Nil, CSteamID.Nil, false);
65+
return unlock ? 1 : 0;
66+
}).Sum() : 0;
7467
}
7568
}

Libraries/0Harmony2.0.2.0.dll

730 KB
Binary file not shown.

0 commit comments

Comments
 (0)