Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.

Commit

Permalink
fixed GeneratorEvent for Synapse version 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
GrafDimenzio committed Aug 4, 2020
1 parent 1645a24 commit 184f178
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 66 deletions.
135 changes: 71 additions & 64 deletions Synapse/Events/Patches/EventPatches/MapPatches/GeneratorPatches.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,75 @@
using Harmony;
using System;
using Harmony;
using Mirror;
using Synapse.Api;
using UnityEngine;

namespace Synapse.Events.Patches
{
/*
[HarmonyPatch(typeof(Generator079), nameof(Generator079.Interact))]
public static class GeneratorTabletPatches
{
public static bool Prefix(Generator079 __instance, GameObject person, string command)
{
try
{
var player = person.GetPlayer();
if (player == null)
{
Log.Error("GeneratorEventError: a GameObject which is not a Player used a Generator?");
return false;
}
if (command.StartsWith("EPS_DOOR")) return true;
if (command.StartsWith("EPS_TABLET"))
{
if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance._localTime <= 0f || Generator079.mainGenerator.forcedOvercharge) return false;
var component = person.GetComponent<Inventory>();
var enumerator = component.items.GetEnumerator();
while (enumerator.MoveNext())
{
var syncItemInfo = enumerator.Current;
if (syncItemInfo.id != ItemType.WeaponManagerTablet) continue;
var allow = player.Team != Team.SCP;
Events.InvokeGeneratorInserted(player, __instance, ref allow);
if (!allow) return false;
component.items.Remove(syncItemInfo);
__instance.NetworkisTabletConnected = true;
return false;
}
}
if (!command.StartsWith("EPS_CANCEL")) return true;
[HarmonyPatch(typeof(Generator079), nameof(Generator079.Interact))]
public static class GeneratorTabletPatches
{
public static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
{
try
{
switch (command)
{
if (!__instance.isTabletConnected) return false;
var allow = true;
Events.InvokeGeneratorEjected(player, __instance, ref allow);
return allow;
case PlayerInteract.Generator079Operations.Door:



break;

case PlayerInteract.Generator079Operations.Tablet:

if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance._localTime <= 0f || Generator079.mainGenerator.forcedOvercharge)
{
return false;
}
Inventory component = person.GetComponent<Inventory>();
using (SyncList<Inventory.SyncItemInfo>.SyncListEnumerator enumerator = component.items.GetEnumerator())
{
while (enumerator.MoveNext())
{
Inventory.SyncItemInfo syncItemInfo = enumerator.Current;
if (syncItemInfo.id == ItemType.WeaponManagerTablet)
{
var allow2 = true;
Events.InvokeGeneratorInserted(person.GetPlayer(), __instance, ref allow2);
if (!allow2) break;

component.items.Remove(syncItemInfo);
__instance.NetworkisTabletConnected = true;
break;
}
}
}
break;

case PlayerInteract.Generator079Operations.Cancel:
if (!__instance.isTabletConnected) break;

var allow = true;
Events.InvokeGeneratorEjected(person.GetPlayer(), __instance, ref allow);
if (!allow) break;
return true;
}
}
return false;
}
catch (Exception e)
{
{
Log.Error($"GeneratorTablet Event Error: {e}");
return true;
}
}
}*/

[HarmonyPatch(typeof(Generator079), nameof(Generator079.OpenClose))]
public static class GeneratorDoorPatches
{
public static bool Prefix(Generator079 __instance, GameObject person)
{
}
}
}

[HarmonyPatch(typeof(Generator079), nameof(Generator079.OpenClose))]
public static class GeneratorDoorPatches
{
public static bool Prefix(Generator079 __instance, GameObject person)
{
var player = person.GetPlayer();

var component = person.GetComponent<Inventory>();
Expand All @@ -73,19 +80,19 @@ public static bool Prefix(Generator079 __instance, GameObject person)
{
var allow = true;
if (!__instance.NetworkisDoorOpen)
{
{
Events.InvokeGeneratorOpen(player, __instance, ref allow);
}
else
{
}
else
{
Events.InvokeGeneratorClose(player, __instance, ref allow);
}
}

if (!allow)
{
{
__instance.RpcDenied();
return false;
}
}

__instance._doorAnimationCooldown = 1.5f;
__instance.NetworkisDoorOpen = !__instance.isDoorOpen;
Expand All @@ -96,7 +103,7 @@ public static bool Prefix(Generator079 __instance, GameObject person)
//Unlock The Generator
var flag = player.Bypass;
var flag2 = player.Team != Team.SCP;

if (flag2 && component.curItem > ItemType.KeycardJanitor)
{
var permissions = component.GetItemByID(component.curItem).permissions;
Expand All @@ -118,5 +125,5 @@ public static bool Prefix(Generator079 __instance, GameObject person)

return false;
}
}
}
}
4 changes: 2 additions & 2 deletions Synapse/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyVersion("1.1.2")]
[assembly: AssemblyFileVersion("1.1.2")]

0 comments on commit 184f178

Please sign in to comment.