Skip to content

Commit

Permalink
Update to 2.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
GrafDimenzio committed Feb 12, 2022
1 parent 99ec90d commit 835625a
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 113 deletions.
26 changes: 14 additions & 12 deletions Pets/EventHandlers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ev = Synapse.Api.Events.EventHandler;
using Synapse.Api;
using Synapse.Api;
using System.Linq;
using ev = Synapse.Api.Events.EventHandler;

namespace Pets
{
Expand All @@ -11,13 +11,6 @@ public EventHandlers()
ev.Get.Player.LoadComponentsEvent += LoadComponents;
ev.Get.Server.TransmitPlayerDataEvent += TransmitData;
ev.Get.Player.PlayerDamagePermissionEvent += DamagePermission;
ev.Get.Player.PlayerDeathEvent += DeathEvent;
}

private void DeathEvent(Synapse.Api.Events.SynapseEventArguments.PlayerDeathEventArgs ev)
{
if (ev.Victim.IsDummy && ev.Victim.Team == Team.SCP)
TerminationPatch.Killer.Add(ev.Killer);
}

private void DamagePermission(Synapse.Api.Events.SynapseEventArguments.PlayerDamagePermissionEventArgs ev)
Expand All @@ -39,16 +32,25 @@ private void TransmitData(Synapse.Api.Events.SynapseEventArguments.TransmitPlaye

if (dummy != null && dummy is Pet p && p.Owner != ev.Player)
{
if (PluginClass.PetPlugin.Config.InvisiblePet || (p.Owner.Invisible && !ev.Player.HasPermission("synapse.see.invisible")) || p.Owner.PlayerEffectsController.GetEffect<CustomPlayerEffects.Invisible>().IsEnabled)
if(p.Owner.RoleType == RoleType.Spectator)
{
ev.Invisible = true;
return;
}

if (ev.Player.RoleType == RoleType.Scp93953 || ev.Player.RoleType == RoleType.Scp93989)
if(p.Owner != ev.Player)
{
if (SynapseExtensions.CanHarmScp(p.Owner, false) && !p.Owner.GetComponent<Scp939_VisionController>().CanSee(ev.Player.PlayerEffectsController.GetEffect<CustomPlayerEffects.Visuals939>()))
if (PluginClass.PetPlugin.Config.InvisiblePet || (p.Owner.Invisible && !ev.Player.HasPermission("synapse.see.invisible")) || p.Owner.PlayerEffectsController.GetEffect<CustomPlayerEffects.Invisible>().IsEnabled)
{
ev.Invisible = true;
return;
}

if (ev.Player.RoleType == RoleType.Scp93953 || ev.Player.RoleType == RoleType.Scp93989)
{
if (SynapseExtensions.CanHarmScp(p.Owner, false) && !p.Owner.GetComponent<Scp939_VisionController>().CanSee(ev.Player.PlayerEffectsController.GetEffect<CustomPlayerEffects.Visuals939>()))
ev.Invisible = true;
}
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions Pets/Pet.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using MEC;
using MEC;
using Synapse.Api;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace Pets
Expand Down Expand Up @@ -94,7 +94,6 @@ private IEnumerator<float> Walk()

else if (distance <= 1.25f)
Direction = Synapse.Api.Enum.MovementDirection.Stop;

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Pets/PetConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Synapse.Config;
using Synapse.Config;
using System.Collections.Generic;

namespace Pets
{
Expand Down
8 changes: 4 additions & 4 deletions Pets/PetHandler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using Synapse;
using Synapse.Api;
using Synapse.Config;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Synapse;
using Synapse.Api;
using Synapse.Config;

namespace Pets
{
Expand Down
20 changes: 10 additions & 10 deletions Pets/Pets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.2.1.1\lib\net472\0Harmony.dll</HintPath>
<Reference Include="0Harmony, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.2.2.0\lib\net472\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.7.1\lib\net472\Assembly-CSharp.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.8.3-pre1\lib\net472\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.7.1\lib\net472\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.8.3-pre1\lib\net472\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=5.0.11.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.11\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.7.1\lib\net472\Mirror.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.8.3-pre1\lib\net472\Mirror.dll</HintPath>
</Reference>
<Reference Include="Synapse, Version=2.7.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.7.1\lib\net472\Synapse.dll</HintPath>
<Reference Include="Synapse, Version=2.8.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.8.3-pre1\lib\net472\Synapse.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -63,13 +63,13 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.7.1\lib\net472\UnityEngine.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.8.3-pre1\lib\net472\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.7.1\lib\net472\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.8.3-pre1\lib\net472\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.7.1\lib\net472\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.8.3-pre1\lib\net472\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.11.2.1\lib\net45\YamlDotNet.dll</HintPath>
Expand Down
10 changes: 5 additions & 5 deletions Pets/PluginClass.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using HarmonyLib;
using HarmonyLib;
using Synapse.Api;
using Synapse.Api.Plugin;
using Synapse.Translation;
using System;

namespace Pets
{
Expand All @@ -12,9 +12,9 @@ namespace Pets
Description = "A Plugin for Pets in SL",
LoadPriority = 0,
SynapseMajor = 2,
SynapseMinor = 7,
SynapsePatch = 2,
Version = "v.1.0.2"
SynapseMinor = 8,
SynapsePatch = 3,
Version = "v.1.0.3"
)]
public class PluginClass : AbstractPlugin
{
Expand Down
2 changes: 1 addition & 1 deletion Pets/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Pets
{
public class PluginConfig : AbstractConfigSection
{
[Description("The max Amount of Pets a Player can have at the same time")]
[Description("The max Amount of Pets a Player can spawn during one Round")]
public int MaxPets { get; set; } = 1;

[Description("If enabled only the Owner of the pet can see it")]
Expand Down
77 changes: 6 additions & 71 deletions Pets/PluginPatches.cs
Original file line number Diff line number Diff line change
@@ -1,80 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HarmonyLib;
using Respawning.NamingRules;
using Synapse;
using Synapse.Api;
using HarmonyLib;

namespace Pets
{
[HarmonyPatch(typeof(NineTailedFoxNamingRule), nameof(NineTailedFoxNamingRule.PlayEntranceAnnouncement))]
internal static class AnnouncePatch
{
private static bool Prefix(NineTailedFoxNamingRule __instance, string regular)
{
try
{
string cassieUnitName = __instance.GetCassieUnitName(regular);
int num = Server.Get.GetPlayers(x => x.RealTeam == Team.SCP && !x.IsDummy).Count;
StringBuilder stringBuilder = new StringBuilder();
if (ClutterSpawner.IsHolidayActive(Holidays.Christmas))
{
stringBuilder.Append("XMAS_EPSILON11 ");
stringBuilder.Append(cassieUnitName);
stringBuilder.Append("XMAS_HASENTERED ");
stringBuilder.Append(num);
stringBuilder.Append(" XMAS_SCPSUBJECTS");
}
else
{
stringBuilder.Append("MTFUNIT EPSILON 11 DESIGNATED ");
stringBuilder.Append(cassieUnitName);
stringBuilder.Append(" HASENTERED ALLREMAINING ");
if (num == 0)
{
stringBuilder.Append("NOSCPSLEFT");
}
else
{
stringBuilder.Append("AWAITINGRECONTAINMENT ");
stringBuilder.Append(num);
if (num == 1)
{
stringBuilder.Append(" SCPSUBJECT");
}
else
{
stringBuilder.Append(" SCPSUBJECTS");
}
}
}
__instance.ConfirmAnnouncement(ref stringBuilder);
return false;
}
catch (Exception e)
{
Logger.Get.Error($"Error while announcing mtf:\n{e}");
return true;
}
}
}

[HarmonyPatch(typeof(NineTailedFoxAnnouncer), nameof(NineTailedFoxAnnouncer.AnnounceScpTermination))]
[HarmonyPatch(typeof(NineTailedFoxAnnouncer), nameof(NineTailedFoxAnnouncer.AnnounceScpTermination))]
internal static class TerminationPatch
{
public static List<Player> Killer = new List<Player>();

private static bool Prefix(PlayerStats.HitInfo hit)
[HarmonyPrefix]
private static bool Prefix(ReferenceHub scp)
{
var ply = Killer.FirstOrDefault(x => x.PlayerId == hit.PlayerId);
if (ply != null)
{
Killer.Remove(ply);
return false;
}

var pet = scp.GetPlayer();
if (pet.IsDummy) return false;
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Pets/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
4 changes: 2 additions & 2 deletions Pets/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Lib.Harmony" version="2.1.1" targetFramework="net472" />
<package id="Lib.Harmony" version="2.2.0" targetFramework="net472" />
<package id="LiteDB" version="5.0.11" targetFramework="net472" />
<package id="SynapseSL" version="2.7.1" targetFramework="net472" />
<package id="SynapseSL" version="2.8.3-pre1" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0-preview.3.21201.4" targetFramework="net472" />
<package id="YamlDotNet" version="11.2.1" targetFramework="net472" />
</packages>

0 comments on commit 835625a

Please sign in to comment.