private static IEnumerator <float> Postfix(IEnumerator <float> values, RandomItemSpawner.SpawnerItemToSpawn __instance) { SpawningItemEventArgs ev = new SpawningItemEventArgs(__instance._id, __instance._pos, __instance._rot, __instance._locked, true); Handlers.Map.OnSpawningItem(ev); if (ev.IsAllowed) { Pickup pickup = ReferenceHub.GetHub(PlayerManager.localPlayer).inventory.SetPickup(ev.Id, 0.0f, Vector3.zero, Quaternion.identity, 0, 0, 0); yield return(float.NegativeInfinity); HostItemSpawner.SetPos(pickup, ev.Position, ev.Id, ev.Rotation.eulerAngles); pickup.RefreshDurability(true, true); if (ev.Locked) { pickup.Locked = true; } SpawnedItemEventArgs spawned_ev = new SpawnedItemEventArgs(pickup); Handlers.Map.OnSpawnedItem(spawned_ev); } }
#pragma warning disable IDE0051 // Remove unused private members private void Awake() { hub = ReferenceHub.GetHub(gameObject); AllEffects.Add(typeof(Scp207), new Scp207(hub)); AllEffects.Add(typeof(Scp268), new Scp268(hub)); AllEffects.Add(typeof(Corroding), new Corroding(hub)); AllEffects.Add(typeof(Visuals939), new Visuals939(hub)); AllEffects.Add(typeof(Decontaminating), new Decontaminating(hub)); AllEffects.Add(typeof(SinkHole), new SinkHole(hub)); AllEffects.Add(typeof(Flashed), new Flashed(hub)); AllEffects.Add(typeof(Amnesia), new Amnesia(hub)); AllEffects.Add(typeof(Blinded), new Blinded(hub)); AllEffects.Add(typeof(Hemorrhage), new Hemorrhage(hub)); AllEffects.Add(typeof(Poisoned), new Poisoned(hub)); AllEffects.Add(typeof(Bleeding), new Bleeding(hub)); AllEffects.Add(typeof(Disabled), new Disabled(hub)); AllEffects.Add(typeof(Ensnared), new Ensnared(hub)); AllEffects.Add(typeof(Concussed), new Concussed(hub)); AllEffects.Add(typeof(Burned), new Burned(hub)); AllEffects.Add(typeof(Deafened), new Deafened(hub)); AllEffects.Add(typeof(Asphyxiated), new Asphyxiated(hub)); AllEffects.Add(typeof(Exhausted), new Exhausted(hub)); AllEffects.Add(typeof(Panic), new Panic(hub)); AllEffects.Add(typeof(Invigorated), new Invigorated(hub)); AllEffects.Add(typeof(SCP008), new SCP008(hub)); if (NetworkServer.active) { Resync(); } }
public static void OldRefreshPlyModel(this CharacterClassManager ccm, GameObject player, RoleType classId = RoleType.None) { ReferenceHub hub = ReferenceHub.GetHub(player); hub.GetComponent <AnimationController>().OnChangeClass(); if (ccm.MyModel != null) { UnityEngine.Object.Destroy(ccm.MyModel); } Role role = ccm.Classes.SafeGet((classId < RoleType.Scp173) ? ccm.CurClass : classId); if (role.team != Team.RIP) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(role.model_player, ccm.gameObject.transform, true); gameObject.transform.localPosition = role.model_offset.position; gameObject.transform.localRotation = Quaternion.Euler(role.model_offset.rotation); gameObject.transform.localScale = role.model_offset.scale; ccm.MyModel = gameObject; AnimationController component = hub.GetComponent <AnimationController>(); if (ccm.MyModel.GetComponent <Animator>() != null) { component.animator = ccm.MyModel.GetComponent <Animator>(); } FootstepSync component2 = ccm.GetComponent <FootstepSync>(); FootstepHandler component3 = ccm.MyModel.GetComponent <FootstepHandler>(); if (component2 != null) { component2.FootstepHandler = component3; } if (component3 != null) { component3.FootstepSync = component2; component3.AnimationController = component; } if (ccm.isLocalPlayer) { if (ccm.MyModel.GetComponent <Renderer>() != null) { ccm.MyModel.GetComponent <Renderer>().enabled = false; } Renderer[] componentsInChildren = ccm.MyModel.GetComponentsInChildren <Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } foreach (Collider collider in ccm.MyModel.GetComponentsInChildren <Collider>()) { if (collider.name != "LookingTarget") { collider.enabled = false; } } } } ccm.GetComponent <CapsuleCollider>().enabled = (role.team != Team.RIP); if (ccm.MyModel != null) { ccm.GetComponent <WeaponManager>().hitboxes = ccm.MyModel.GetComponentsInChildren <HitboxIdentity>(true); } }
public static bool Prefix(Handcuffs __instance, GameObject target) { if (EventPlugin.HandcuffEventPatchDisable) { return(true); } try { if (!__instance._interactRateLimit.CanExecute(true) || target == null || (Vector3.Distance(target.transform.position, __instance.transform.position) > __instance.raycastDistance * 1.10000002384186 || __instance.MyReferenceHub.characterClassManager .Classes.SafeGet(__instance.MyReferenceHub.characterClassManager.CurClass).team == Team.SCP)) { return(false); } bool allow = true; Events.InvokePlayerHandcuffFree(__instance.gameObject, target, ref allow); if (!allow) { return(false); } ReferenceHub.GetHub(target).handcuffs.NetworkCufferId = -1; return(false); } catch (Exception e) { Log.Error($"HandcuffFreeTeammate Error: {e}"); return(true); } }
private static void Postfix(GameObject player) { try { if (!API.Features.Player.Dictionary.TryGetValue(player, out API.Features.Player newPlayer)) { newPlayer = new API.Features.Player(ReferenceHub.GetHub(player)); API.Features.Player.Dictionary.Add(player, newPlayer); } API.Features.Log.Debug($"Player {newPlayer?.Nickname} ({newPlayer?.UserId}) connected with the IP: {newPlayer?.IPAddress}"); if (PlayerManager.players.Count >= CustomNetworkManager.slots) { API.Features.Log.Debug($"Server is full!"); } Timing.CallDelayed(0.25f, () => { if (newPlayer != null && newPlayer.IsMuted) { newPlayer.ReferenceHub.characterClassManager.SetDirtyBit(1UL); } }); var ev = new JoinedEventArgs(API.Features.Player.Get(player)); Player.OnJoined(ev); } catch (Exception exception) { API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.Joined: {exception}\n{exception.StackTrace}"); } }
private static void Postfix(NicknameSync __instance) { if (__instance.hub.characterClassManager.IsHost || string.IsNullOrEmpty(__instance.hub.characterClassManager.UserId)) { return; } if (!API.Features.Player.Dictionary.TryGetValue(__instance.gameObject, out API.Features.Player player)) { player = new API.Features.Player(ReferenceHub.GetHub(__instance.gameObject)); API.Features.Player.Dictionary.Add(__instance.gameObject, player); } API.Features.Log.Debug($"Player {player?.Nickname} ({player?.UserId}) connected with the IP: {player?.IPAddress}"); if (PlayerManager.players.Count >= CustomNetworkManager.slots) { API.Features.Log.Debug($"Server is full!"); } Timing.CallDelayed(0.25f, () => { if (player != null && player.IsMuted) { player.ReferenceHub.characterClassManager.SetDirtyBit(1UL); } }); var ev = new JoinedEventArgs(API.Features.Player.Get(__instance.gameObject)); Player.OnJoined(ev); }
public static bool Prefix(Handcuffs __instance) { if (EventPlugin.HandcuffEventPatchDisable) { return(true); } try { foreach (GameObject player in PlayerManager.players) { Handcuffs handcuffs = ReferenceHub.GetHub(player).handcuffs; if (handcuffs.CufferId == __instance.MyReferenceHub.queryProcessor.PlayerId) { bool allow = true; Events.InvokePlayerHandcuffFree(__instance.gameObject, player, ref allow); if (allow) { handcuffs.NetworkCufferId = -1; } break; } } return(false); } catch (Exception e) { Log.Error($"HandcuffFree Error: {e}"); return(true); } }
public void OnDestroy() { orig_OnDestroy(); ReferenceHub refHub = ReferenceHub.GetHub(gameObject); if (string.IsNullOrEmpty(refHub.characterClassManager.UserId) || !refHub.characterClassManager.UserId.Contains('@')) { return; } else { try { Base.Debug("Triggering PlayerLeaveEvent"); PluginManager.TriggerEvent <IEventHandlerPlayerLeave>(new PlayerLeaveEvent(new PheggPlayer(this.gameObject))); } catch (Exception e) { Base.Error($"Error triggering PlayerLeaveEvent: {e.InnerException}"); } } //if (refHub.characterClassManager.IsAnyScp() && refHub.characterClassManager.CurClass != RoleType.Scp0492) //{ // bool HasBeenReplaced = false; // foreach(var p in ReferenceHub.GetAllHubs()) // { // if(p.Value.characterClassManager.CurClass == RoleType.Spectator && p.Value.serverRoles.over) // } // if (!HasBeenReplaced && SCP.ContainsKey(refHub.characterClassManager.CurClass)) // { // SCPData data = new SCPData // { // roleType = refHub.characterClassManager.CurClass, // health = refHub.playerStats.Health, // artHealth = refHub.playerStats.syncArtificialHealth, // position = refHub.playerMovementSync.RealModelPosition, // }; // if(data.roleType == RoleType.Scp079) // { // data.exp = refHub.scp079PlayerScript.Exp; // data.mana = refHub.scp079PlayerScript.Mana; // } // SCP.Add(data.roleType, data); // } //} if (PlayerManager.players.Count - 1 < 1 && RoundSummary.RoundInProgress()) { PMRoundSummary.RoundFix(); } }
public static bool Prefix(PlayerInteract __instance) { if (!PluginConfig.Cfg.Enabled) { return(true); } if (!__instance._playerInteractRateLimit.CanExecute(true) || (__instance._hc.CufferId > 0 && !(PluginConfig.Cfg.OverrideHandcuffConfig ? PluginConfig.Cfg.CanDisarmedInteract : __instance.CanDisarmedInteract)) ) { return(false); } if (!PluginConfig.Cfg.CanChangeKnobWhileWorking && Scp914Machine.singleton.working || !__instance.ChckDis(Scp914Machine.singleton.knob.position)) { return(false); } //if (Plugin.KnobBlockade) return false; Scp914Machine.singleton.ChangeKnobStatus(); Plugin.LastPlayerHub = ReferenceHub.GetHub(__instance.gameObject); __instance.OnInteract(); return(false); }
private static bool Prefix(FlashGrenade __instance) { List <Exiled.API.Features.Player> players = new List <Exiled.API.Features.Player>(); foreach (GameObject gameObject in PlayerManager.players) { Vector3 position = __instance.transform.position; ReferenceHub hub = ReferenceHub.GetHub(gameObject); Flashed effect = hub.playerEffectsController.GetEffect <Flashed>(); Deafened effect2 = hub.playerEffectsController.GetEffect <Deafened>(); if (effect == null || __instance.thrower == null || (!__instance.Network_friendlyFlash && !effect.Flashable(ReferenceHub.GetHub(__instance.thrower.gameObject), position, __instance.viewLayerMask))) { continue; } float num = __instance.powerOverDistance.Evaluate(Vector3.Distance(gameObject.transform.position, position) / ((position.y > 900f) ? __instance.distanceMultiplierSurface : __instance.distanceMultiplierFacility)) * __instance.powerOverDot.Evaluate(Vector3.Dot(hub.PlayerCameraReference.forward, (hub.PlayerCameraReference.position - position).normalized)); byte b = (byte)Mathf.Clamp(Mathf.RoundToInt(num * 10f * __instance.maximumDuration), 1, 255); if (b >= effect.Intensity && num > 0f) { players.Add(API.Features.Player.Get(gameObject)); } } ExplodingGrenadeEventArgs ev = new ExplodingGrenadeEventArgs(players, false, __instance.gameObject); Handlers.Map.OnExplodingGrenade(ev); return(ev.IsAllowed); }
private static Player GetPlayerOrServer(GameObject gameObject) { ReferenceHub refHub = ReferenceHub.GetHub(gameObject); // The only reason is that the server is also a player, // and we've seen a lot of NullRef exceptions at the place // where we call this method return(refHub.isLocalPlayer ? Server.Host : Player.Get(gameObject)); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { var ownerRaw = arguments.ElementAtOrDefault(0); if (ownerRaw == null) { response = "Missing owner"; return(false); } var owner = CommandExtensions.MatchPlayers(ownerRaw, sender)[0]; var pet = UnityEngine.Object.Instantiate(LiteNetLib4MirrorNetworkManager.singleton.playerPrefab, owner.playerMovementSync.RealModelPosition, Quaternion.identity); var hub = ReferenceHub.GetHub(pet); foreach (var component in pet.GetComponents <Behaviour>()) { if (component is ReferenceHub || component is CharacterClassManager || component is PlayerMovementSync || component is PlayerPositionManager) { continue; } component.enabled = false; } var roleRaw = arguments.ElementAtOrDefault(1); if (roleRaw == null || !Enum.TryParse <RoleType>(roleRaw, true, out var role)) { response = $"Missing role ({Enum.GetNames(typeof(RoleType)).Join()})"; return(false); } hub.characterClassManager.NetworkCurClass = role; pet.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); Timing.CallDelayed(1f, () => { hub.nicknameSync.MyNick = $"{owner.nicknameSync.MyNick}'s pet"; NetworkServer.Spawn(pet); }); var pets = Pets[owner] = Pets.GetValueSafe(owner) ?? new List <ReferenceHub>(); pets.Add(hub); hub.characterClassManager.netIdentity.isLocalPlayer = true; hub.characterClassManager.netIdentity.connectionToClient = hub.characterClassManager.netIdentity.connectionToServer = NetworkServer.localConnection; hub.queryProcessor.PlayerId = -1 - Pets.Values.Sum(x => x.Count); hub.playerMovementSync._realModelPosition = owner.playerMovementSync.RealModelPosition; response = "Created pet"; return(false); }
public static bool Prefix(FlashGrenade __instance, ref bool __result) { Exiled.API.Features.Log.Debug($"Flash grenade explosion", Subclass.Instance.Config.Debug); foreach (GameObject obj2 in PlayerManager.players) { Player target = Player.Get(obj2); Vector3 position = ((EffectGrenade)__instance).transform.position; ReferenceHub hub = ReferenceHub.GetHub(obj2); Flashed effect = hub.playerEffectsController.GetEffect <Flashed>(); Deafened deafened = hub.playerEffectsController.GetEffect <Deafened>(); Exiled.API.Features.Log.Debug($"Flash target is: {target?.Nickname}", Subclass.Instance.Config.Debug); if ((effect != null) && ((((EffectGrenade)__instance).thrower != null) && (__instance._friendlyFlash || effect.Flashable(ReferenceHub.GetHub(((EffectGrenade)__instance).thrower.gameObject), position, __instance._ignoredLayers)))) { if (!Tracking.PlayersWithSubclasses.ContainsKey(target) || !Tracking.PlayersWithSubclasses[target].Abilities.Contains(AbilityType.FlashImmune)) { float num = __instance.powerOverDistance.Evaluate((float)(Vector3.Distance(obj2.transform.position, position) / ((position.y > 900f) ? __instance.distanceMultiplierSurface : __instance.distanceMultiplierFacility))) * __instance.powerOverDot.Evaluate(Vector3.Dot(hub.PlayerCameraReference.forward, (hub.PlayerCameraReference.position - position).normalized)); byte intensity = (byte)Mathf.Clamp(Mathf.RoundToInt((float)((num * 10f) * __instance.maximumDuration)), 1, 0xff); if ((intensity >= effect.Intensity) && (num > 0f)) { hub.playerEffectsController.ChangeEffectIntensity <Flashed>(intensity); if (deafened != null) { hub.playerEffectsController.EnableEffect(deafened, num * __instance.maximumDuration, true); } } } else { Concussed concussedEffect = hub.playerEffectsController.GetEffect <Concussed>(); concussedEffect.Intensity = 3; hub.playerEffectsController.EnableEffect(concussedEffect, 5); Disabled disabledEffect = hub.playerEffectsController.GetEffect <Disabled>(); disabledEffect.Intensity = 2; hub.playerEffectsController.EnableEffect(disabledEffect, 5); } } } if (((EffectGrenade)__instance).serverGrenadeEffect != null) { Transform transform = ((Grenade)__instance).transform; Object.Instantiate <GameObject>(((EffectGrenade)__instance).serverGrenadeEffect, transform.position, transform.rotation); } string str = (((Grenade)__instance).thrower != null) ? ((Grenade)__instance).thrower.hub.LoggedNameFromRefHub() : ((string)"(UNKNOWN)"); string[] textArray1 = new string[] { "Player ", (string)str, "'s ", (string)((Grenade)__instance).logName, " grenade exploded." }; ServerLogs.AddLog(ServerLogs.Modules.Logger, string.Concat((string[])textArray1), ServerLogs.ServerLogType.GameEvent, false); __result = true; return(false); }
/// <summary> /// Get a list of messages for a given player. /// </summary> /// <param name="player">Player object </param> /// <returns></returns> public IEnumerable <Message> GetMessagesForPlayer(GameObject player) { var refHub = ReferenceHub.GetHub(player); var role = refHub.serverRoles.NetworkMyText.ToLower(); var defaultMessages = GetGlobalMessages(); return(GetMessagesForRole(role).Concat(defaultMessages)); }
public bool Is343(Player Ply) { /// Here we get the Smod2 player object and then we use the <see cref="Player.GetGameObject()"/> which returns a default C# Object and then we cast into a UnityEngine GameObject so SCP:SL's ReferenceHub can find the player. GameObject PlayerGameObject = (GameObject)Ply.GetGameObject(); ReferenceHub hub = ReferenceHub.GetHub(PlayerGameObject); return(Is343(hub)); ///Could also be done like return Is343(ReferenceHub.GetHub((GameObject)Ply.GetGameObject())); }
private void Start() { WelcomesMod.Instance.Info($"InitWC"); _nextCycle = Time.time; _messageStack = new Stack <Message>(Messages.Reverse()); WelcomesMod.Instance.Info($"{_messageStack.Count}"); _broadcast = GetComponent <Broadcast>(); _connection = ReferenceHub.GetHub(gameObject).playerStats.connectionToClient; }
public static bool Prefix(PlayerStats __instance, PlayerStats.HitInfo info, GameObject go) { var referenceHub = ReferenceHub.GetHub(go); if (referenceHub.playerStats.Health - info.Amount <= 0 && ReferenceHub.HostHub != null && !ReferenceHub.HostHub.characterClassManager.RoundStarted) { Spawn(referenceHub); return(false); } return(true); }
private static bool Prefix(Scp096 __instance, GameObject target) { ReferenceHub hub = ReferenceHub.GetHub(target); if (!__instance.CanReceiveTargets || hub == null || __instance._targets.Contains(hub)) { return(false); } API.Features.Player scp096 = API.Features.Player.Get(__instance.Hub.gameObject); API.Features.Player targetPlayer = API.Features.Player.Get(target); if (scp096 == null) { Log.Error("SCP-096.AddTarget: Could not get SCP-096 player object."); return(true); } if (targetPlayer == null) { Log.Error("SCP-096.AddTarget: Could not get Target player object."); return(true); } AddingTargetEventArgs ev = new AddingTargetEventArgs(scp096, targetPlayer, 70, __instance.EnrageTimePerReset); Exiled.Events.Handlers.Scp096.OnAddingTarget(ev); if (ev.IsAllowed) { if (!__instance._targets.IsEmpty() || __instance.Enraged) { if (__instance.AddedTimeThisRage + ev.EnrageTimeToAdd >= __instance.MaximumAddedEnrageTime) { ev.EnrageTimeToAdd = 0f; } else if (__instance.AddedTimeThisRage + ev.EnrageTimeToAdd > __instance.MaximumAddedEnrageTime) { ev.EnrageTimeToAdd = __instance.AddedTimeThisRage + ev.EnrageTimeToAdd - __instance.MaximumAddedEnrageTime; } __instance.EnrageTimeLeft += ev.EnrageTimeToAdd; __instance.AddedTimeThisRage += ev.EnrageTimeToAdd; } __instance._targets.Add(hub); __instance.AdjustShield(ev.AhpToAdd); NetworkServer.SendToClientOfPlayer <Scp096ToTargetMessage>(hub.characterClassManager.netIdentity, new Scp096ToTargetMessage(hub)); } return(false); }
public static void SpawnGrenade(Vector3 position, bool isFlash = false, float fusedur = -1, ReferenceHub player = null) { if (player == null) { player = ReferenceHub.GetHub(PlayerManager.localPlayer); } var gm = player.GetComponent <Grenades.GrenadeManager>(); Grenades.Grenade component = UnityEngine.Object.Instantiate(gm.availableGrenades[isFlash ? (int)GRENADE_ID.FLASH_NADE : (int)GRENADE_ID.FRAG_NADE].grenadeInstance).GetComponent <Grenades.Grenade>(); if (fusedur != -1) { component.fuseDuration = fusedur; } component.FullInitData(gm, position, Quaternion.Euler(component.throwStartAngle), Vector3.zero, component.throwAngularVelocity); NetworkServer.Spawn(component.gameObject); }
public void Postfix(PlayableScps.Scp096 __instance, VisionInformation __result, GameObject source) { VisionInformation visionInformation = new VisionInformation { Source = source, Target = __instance.Hub.gameObject, RaycastHit = false, Looking = false }; if (source == __instance.Hub.gameObject) { __result = visionInformation; return; } Transform playerCameraReference = ReferenceHub.GetHub(source).PlayerCameraReference; Vector3 position = __instance.Hub.PlayerCameraReference.position; Vector3 position2 = playerCameraReference.position; visionInformation.Distance = Vector3.Distance(position2, position); float num = -Vector3.Dot((position2 - position).normalized, playerCameraReference.forward); float num2 = -Vector3.Dot((position - position2).normalized, __instance.Hub.PlayerCameraReference.forward); visionInformation.DotProduct = num; visionInformation.Looking = true; if (num < MoreConfig.singleton.Config.Scp096Config.triggerBounds1 || num2 < MoreConfig.singleton.Config.Scp096Config.triggerBounds2) { visionInformation.Looking = false; __result = visionInformation; return; } if (visionInformation.Distance > ((__instance.Hub.transform.position.y > 980f) ? MoreConfig.singleton.Config.Scp096Config.surfaceTriggerDistance : MoreConfig.singleton.Config.Scp096Config.triggerDistance)) { __result = visionInformation; return; } RaycastHit raycastResult; if (!Physics.Raycast(visionInformation.Source.transform.position, (visionInformation.Target.transform.position - visionInformation.Source.transform.position).normalized, out raycastResult, MoreConfig.singleton.Config.Scp096Config.surfaceTriggerDistance, PlayableScps.Scp096.VisionLayerMask)) { __result = visionInformation; return; } visionInformation.RaycastHit = true; visionInformation.RaycastResult = raycastResult; __result = visionInformation; }
public static void Postfix(ConsumableAndWearableItems __instance, int mid) { ReferenceHub player = ReferenceHub.GetHub(__instance.gameObject); ItemType itemtype = __instance.usableItems[mid].inventoryID; Log.Debug($"[MedicalUsedPatch] {player?.GetNickname()} mid:{mid}/{itemtype}"); if (itemtype == ItemType.Medkit || itemtype == ItemType.SCP500) { if (Coroutines.DOTDamages.TryGetValue(player, out CoroutineHandle handle)) { Log.Debug($"[939DOT] Removed {player.GetNickname()}"); Timing.KillCoroutines(handle); Coroutines.DOTDamages.Remove(player); } } }
private static bool ServerCreatePickupPatch(ref ItemPickupBase __result, Inventory inv, ItemBase item, PickupSyncInfo psi, bool spawn = true) { try { __result = null; if (item == null) { return(false); } var pickup = UnityEngine.Object.Instantiate(item.PickupDropModel, inv.transform.position, ReferenceHub.GetHub(inv.gameObject).PlayerCameraReference.rotation * item.PickupDropModel.transform.rotation); //The Value to the Serial can also be null but every Serial should be as key inside AllItems if (!SynapseItem.AllItems.TryGetValue(psi.Serial, out var sitem)) { Logger.Get.Warn($"Found unregistered ItemSerial in PickupSyncInfo (CreatePickupPatch): {psi.Serial}"); psi.Serial = ItemSerialGenerator.GenerateNext(); } pickup.NetworkInfo = psi; pickup.Info = psi; if (sitem == null) { sitem = new SynapseItem(pickup); } else { sitem.PickupBase = pickup; } pickup.transform.localScale = sitem.Scale; if (spawn) { NetworkServer.Spawn(pickup.gameObject); } sitem.CheckForSchematic(); pickup.InfoReceived(default, psi);
private static bool Prefix(FlashGrenade __instance) { try { Dictionary <Player, float> players = new Dictionary <Player, float>(); foreach (GameObject gameObject in PlayerManager.players) { Vector3 position = __instance.transform.position; ReferenceHub hub = ReferenceHub.GetHub(gameObject); Flashed effect = hub.playerEffectsController.GetEffect <Flashed>(); Deafened effect2 = hub.playerEffectsController.GetEffect <Deafened>(); if (effect == null || __instance.thrower == null || (!__instance.Network_friendlyFlash && !effect.Flashable( ReferenceHub.GetHub(__instance.thrower.gameObject), position, __instance._ignoredLayers))) { continue; } float num = __instance.powerOverDistance.Evaluate( Vector3.Distance(gameObject.transform.position, position) / ((position.y > 900f) ? __instance.distanceMultiplierSurface : __instance.distanceMultiplierFacility)) * __instance.powerOverDot.Evaluate(Vector3.Dot(hub.PlayerCameraReference.forward, (hub.PlayerCameraReference.position - position).normalized)); byte b = (byte)Mathf.Clamp(Mathf.RoundToInt(num * 10f * __instance.maximumDuration), 1, 255); if (b >= effect.Intensity && num > 0f) { players.Add(Player.Get(gameObject), num); } } ExplodingGrenadeEventArgs ev = new ExplodingGrenadeEventArgs(Player.Get(__instance.throwerGameObject), players, false, __instance.gameObject); Handlers.Map.OnExplodingGrenade(ev); return(ev.IsAllowed); } catch (Exception exception) { Log.Error($"{typeof(ExplodingFlashGrenade).FullName}:\n{exception}"); return(true); } }
public static bool Prefix(Scp096PlayerScript __instance) { if (!Configs.scp096_high_sensitive) { return(true); } foreach (var player in PlayerManager.players) { ReferenceHub hubs = ReferenceHub.GetHub(player); if (!hubs.characterClassManager.Scp173.SameClass && hubs.characterClassManager.Scp173.LookFor173(__instance.gameObject, true) && __instance._ccm.Scp173.LookFor173(player, false)) { __instance.IncreaseRage(Time.fixedDeltaTime); } } return(false); }
private static bool Prefix(Scp096 __instance, GameObject target) { ReferenceHub hub = ReferenceHub.GetHub(target); if (!__instance.CanReceiveTargets || hub == null || __instance._targets.Contains(hub)) { return(false); } API.Features.Player scp096 = API.Features.Player.Get(__instance.Hub.gameObject); API.Features.Player targetPlayer = API.Features.Player.Get(target); if (scp096 == null) { Log.Error("SCP-096.AddTarget: Could not get SCP-096 player object."); return(true); } if (targetPlayer == null) { Log.Error("SCP-096.AddTarget: Could not get Target player object."); return(true); } AddingTargetEventArgs ev = new AddingTargetEventArgs(scp096, targetPlayer, 200, __instance.EnrageTimePerReset); if (targetPlayer.Role == RoleType.Tutorial && !Exiled.Events.Events.Instance.Config.CanTutorialTriggerScp096) { ev.IsAllowed = false; } Exiled.Events.Handlers.Scp096.OnAddingTarget(ev); if (ev.IsAllowed) { if (!__instance._targets.IsEmpty()) { __instance.EnrageTimeLeft += ev.EnrageTimeToAdd; } __instance._targets.Add(hub); __instance.AdjustShield(ev.AhpToAdd); } return(false); }
public static bool Prefix(Scp096PlayerScript __instance) { if (__instance._processLookingQueue.IsEmpty()) { foreach (GameObject player in PlayerManager.players) { __instance._processLookingQueue.Enqueue(player); } } else { GameObject player = __instance._processLookingQueue.Dequeue(); if (player == null || !ReferenceHub.GetHub(player).characterClassManager.IsHuman() || player.GetComponent <FlashEffect>().blinded) { return(false); } Transform transform = player.GetComponent <Scp096PlayerScript>().camera.transform; float num = __instance.lookingTolerance.Evaluate(Vector3.Distance(transform.position, __instance.camera.transform.position)); Vector3 vector3; if (num >= 0.75) { Vector3 forward = transform.forward; vector3 = transform.position - __instance.camera.transform.position; Vector3 normalized = vector3.normalized; if (Vector3.Dot(forward, normalized) >= -(double)num) { return(false); } } Vector3 position = transform.transform.position; vector3 = __instance.camera.transform.position - transform.position; Vector3 normalized1 = vector3.normalized; int layerMask = __instance.layerMask; if (!Physics.Raycast(position, normalized1, out RaycastHit raycastHit, (__instance.gameObject.transform.position.y > 500f ? Plugin.MaxTriggerRangeSurface : Plugin.MaxTriggerRange), layerMask) || (raycastHit.collider.gameObject.layer != 24 || !raycastHit.collider.GetComponentInParent <Scp096PlayerScript>() == __instance)) { return(false); } __instance.IncreaseRage(Time.fixedDeltaTime); } return(false); }
private static bool Prefix(Scp096 __instance, GameObject target) { ReferenceHub hub = ReferenceHub.GetHub(target); if (!__instance.CanReceiveTargets || hub == null || __instance._targets.Contains(hub)) { return(false); } if (!__instance._targets.IsEmpty()) { __instance.AddReset(); } __instance._targets.Add(hub); __instance.AdjustShield(Instance.Config.EnableCustomScp096Shield ? Instance.Config.Scp096Ahp : 200); return(false); }
public static bool Prefix(Scp096 __instance, GameObject target) { ReferenceHub hub = ReferenceHub.GetHub(target); if (!__instance.CanReceiveTargets || hub == null || __instance._targets.Contains(hub)) { return(false); } if (!__instance._targets.IsEmpty <ReferenceHub>()) { __instance.EnrageTimeLeft += SCP096Re.instance.Config.re096_target_enrage_add; } hub.hints.Show(new TextHint(SCP096Re.instance.Config.re096_target_hint, new HintParameter[] { new StringHintParameter("") }, HintEffectPresets.FadeInAndOut(0.25f, 1f, 0f), 5f)); __instance._targets.Add(hub); __instance.AdjustShield(SCP096Re.instance.Config.re096_shield_per_target); return(false); }
public static List <ReferenceHub> GetHubs() { List <ReferenceHub> hubs = new List <ReferenceHub>(); foreach (GameObject obj in PlayerManager.players) { if (_hubs.ContainsKey(obj)) { hubs.Add(_hubs[obj]); } else { ReferenceHub rh = ReferenceHub.GetHub(obj); _hubs.Add(obj, rh); hubs.Add(rh); } } return(hubs); }
public static void Postfix(Scp049PlayerScript __instance, ref GameObject target) { Log.Debug($"[Recall049Patch] SCP049:{Player.GetPlayer(__instance.gameObject).GetNickname()} Target:{Player.GetPlayer(target).GetNickname()} TargetRole:{Player.GetPlayer(target).GetRole()}"); if (Player.GetPlayer(target)?.GetRole() != RoleType.Scp0492) { return; } if (Configs.recovery_amount_scp049 > 0) { ReferenceHub.GetHub(__instance.gameObject).playerStats.HealHPAmount(Configs.recovery_amount_scp049); } if (Configs.scp049_reset_ragdoll_after_recall) { foreach (var player in Player.GetHubs()) { __instance.RpcSetDeathTime(player.gameObject); } } }