public async void OnEjectingGeneratorTablet(StoppingGeneratorEventArgs ev) { if (Instance.Config.EventsToLog.PlayerEjectingGeneratorTablet && (!ev.Player.DoNotTrack || !Instance.Config.ShouldRespectDoNotTrack)) { await Network.SendAsync(new RemoteCommand("log", "gameEvents", string.Format(Language.GeneratorEjected, ev.Player.Nickname, Instance.Config.ShouldLogUserIds ? ev.Player.UserId : Language.Redacted, ev.Player.Role))).ConfigureAwait(false); } if (Instance.Config.StaffOnlyEventsToLog.PlayerEjectingGeneratorTablet) { await Network.SendAsync(new RemoteCommand("log", "staffCopy", string.Format(Language.GeneratorEjected, ev.Player.Nickname, ev.Player.UserId, ev.Player.Role))).ConfigureAwait(false); } }
/// <summary> /// Called before a player ejects the workstation tablet out of a generator. /// </summary> /// <param name="ev">The <see cref="StoppingGeneratorEventArgs"/> instance.</param> public static void OnStoppingGenerator(StoppingGeneratorEventArgs ev) => StoppingGenerator.InvokeSafely(ev);
private static bool Prefix(Scp079Generator __instance, ReferenceHub ply, byte colliderId) { try { if ((__instance._cooldownStopwatch.IsRunning && __instance._cooldownStopwatch.Elapsed.TotalSeconds < __instance._targetCooldown) || (colliderId != 0 && !__instance.HasFlag(__instance._flags, Scp079Generator.GeneratorFlags.Open))) { return(false); } __instance._cooldownStopwatch.Stop(); switch (colliderId) { case 0: if (__instance.HasFlag(__instance._flags, Scp079Generator.GeneratorFlags.Unlocked)) { if (__instance.HasFlag(__instance._flags, Scp079Generator.GeneratorFlags.Open)) { ClosingGeneratorEventArgs closingGenEvent = new ClosingGeneratorEventArgs(API.Features.Player.Get(ply), __instance); Player.OnClosingGenerator(closingGenEvent); if (!closingGenEvent.IsAllowed) { __instance.RpcDenied(); break; } } else { OpeningGeneratorEventArgs openingGenEvent = new OpeningGeneratorEventArgs(API.Features.Player.Get(ply), __instance); Player.OnOpeningGenerator(openingGenEvent); if (!openingGenEvent.IsAllowed) { __instance.RpcDenied(); break; } } __instance.ServerSetFlag(Scp079Generator.GeneratorFlags.Open, !__instance.HasFlag(__instance._flags, Scp079Generator.GeneratorFlags.Open)); __instance._targetCooldown = __instance._doorToggleCooldownTime; break; } bool flag = (!(ply.inventory.CurInstance != null) || !(ply.inventory.CurInstance is KeycardItem curInstance2) ? 0 : (curInstance2.Permissions.HasFlagFast(__instance._requiredPermission) ? 1 : 0)) != 0; UnlockingGeneratorEventArgs unlockingEvent = new UnlockingGeneratorEventArgs(API.Features.Player.Get(ply), __instance, flag); Player.OnUnlockingGenerator(unlockingEvent); if (unlockingEvent.IsAllowed) { __instance.ServerSetFlag(Scp079Generator.GeneratorFlags.Unlocked, true); } else { __instance.RpcDenied(); } __instance._targetCooldown = __instance._unlockCooldownTime; break; case 1: if ((ply.characterClassManager.IsHuman() || __instance.Activating) && !__instance.Engaged) { if (__instance.Activating) { StoppingGeneratorEventArgs stoppingGen = new StoppingGeneratorEventArgs(API.Features.Player.Get(ply), __instance); Player.OnStoppingGenerator(stoppingGen); if (!stoppingGen.IsAllowed) { __instance.RpcDenied(); break; } } else { ActivatingGeneratorEventArgs activatingEvent = new ActivatingGeneratorEventArgs(API.Features.Player.Get(ply), __instance); Player.OnActivatingGenerator(activatingEvent); if (!activatingEvent.IsAllowed) { __instance.RpcDenied(); break; } } __instance.Activating = !__instance.Activating; if (__instance.Activating) { __instance._leverStopwatch.Restart(); } __instance._targetCooldown = __instance._doorToggleCooldownTime; break; } break; case 2: if (__instance.Activating && !__instance.Engaged) { StoppingGeneratorEventArgs stoppingGen = new StoppingGeneratorEventArgs(API.Features.Player.Get(ply), __instance); Player.OnStoppingGenerator(stoppingGen); if (!stoppingGen.IsAllowed) { __instance.RpcDenied(); break; } __instance.ServerSetFlag(Scp079Generator.GeneratorFlags.Activating, false); __instance._targetCooldown = __instance._unlockCooldownTime; break; } break; default: __instance._targetCooldown = 1f; break; } __instance._cooldownStopwatch.Restart(); } catch (Exception exception) { API.Features.Log.Error( $"Exiled.Events.Patches.Events.Player.InteractingGeneratorEvent: {exception}\n{exception.StackTrace}"); return(true); } return(false); }