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); }
public override string Part1(List <string> input, bool isTestRun) { XMapCount = input[0].Length; YMapCount = input.Count; TotalFlashcount = 0; Map = GetIntMap(input); //STEPS for (int i = 1; i <= 100; i++) { Flashed = new();//reset flashdictionary //First, the energy level of each octopus increases by 1. for (int y = 0; y < YMapCount; y++) { for (int x = 0; x < XMapCount; x++) { Map[x, y]++; } } //Then, any octopus with an energy level greater than 9 flashes. //This increases the energy level of all adjacent octopuses by 1, including octopuses that are diagonally adjacent. //If this causes an octopus to have an energy level greater than 9, //it also flashes.This process continues as long as new octopuses keep having their energy level increased beyond 9. //(An octopus can only flash at most once per step.) for (int y = 0; y < YMapCount; y++) { for (int x = 0; x < XMapCount; x++) { if (Map[x, y] > 9) { //Flash Flash(x, y); } } } //Finally, any octopus that flashed during this step has its energy level set to 0, as it used all of its energy to flash. for (int y = 0; y < YMapCount; y++) { for (int x = 0; x < XMapCount; x++) { if (Flashed.ContainsKey($"{x},{y}") && Flashed[$"{x},{y}"]) { Map[x, y] = 0; } } } //PrintToConsole(); TotalFlashcount = TotalFlashcount + (ulong)Flashed.Count(); } return($"{TotalFlashcount}"); }
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); }
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); } }
void OnFlashEnd() { // Call event. Flashed?.Invoke(); if (!gameObject.activeInHierarchy) { return; } // Restart. if (delay <= 0) { Flash(); } else { this.Timer(delay, Flash); } }
private void Flash(int x, int y) { if (!Flashed.ContainsKey($"{x},{y}") || !Flashed[$"{x},{y}"]) { Flashed[$"{x},{y}"] = true; //if up exists increase if (y > 0) { Map[x, y - 1]++; if (Map[x, y - 1] > 9) { Flash(x, y - 1); } } //if right-up exists check if (x < XMapCount - 1 && y > 0) { Map[x + 1, y - 1]++; if (Map[x + 1, y - 1] > 9) { Flash(x + 1, y - 1); } } //if right exists check if (x < XMapCount - 1) { Map[x + 1, y]++; if (Map[x + 1, y] > 9) { Flash(x + 1, y); } } //if right-down exists check if (x < XMapCount - 1 && y < YMapCount - 1) { Map[x + 1, y + 1]++; if (Map[x + 1, y + 1] > 9) { Flash(x + 1, y + 1); } } //if down exists check if (y < YMapCount - 1) { Map[x, y + 1]++; if (Map[x, y + 1] > 9) { Flash(x, y + 1); } } //if down-left exists check if (y < YMapCount - 1 && x > 0) { Map[x - 1, y + 1]++; if (Map[x - 1, y + 1] > 9) { Flash(x - 1, y + 1); } } //if left exists check if (x > 0) { Map[x - 1, y]++; if (Map[x - 1, y] > 9) { Flash(x - 1, y); } } //if left-up exists check if (x > 0 && y > 0) { Map[x - 1, y - 1]++; if (Map[x - 1, y - 1] > 9) { Flash(x - 1, y - 1); } } } }