public void HandleReaction() { if (_playing) { if (_interruptable) { Timing.KillCoroutines(_animationCoroutine); _currentIndex = 0; } else { return; } } _playing = true; _animationCoroutine = Timing.RunCoroutine(PlayAnimation().CancelWith(_root)); }
private void TimedOnScenarioLoaded() { _scenarioState = ScenarioState.ShootToStart; session.SetScoreSystem(NagaUtils.FindObjectOfType <IScoreSystem>()); SetupCountdownLogic(); statUI.SetTimeDP(0); statUI.SetTimerMode(); statUI.UpdateTime(session.timeAllowed * 1000); SetupCountdownUI(); scenarioTimer.onEndTimer.AddListener(OnTimedScenarioEnded); shootToStartCoroutine = Timing.RunCoroutine(_WaitToStart(() => { scenarioTimer.StartTimer(session.timeAllowed, countdownTime); _scenarioState = ScenarioState.Countdown; })); }
// Start is called before the first frame update void Start() { animator = GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); rb = GetComponent <Rigidbody>(); if (rb != null) { //Set restraints on startup if using Rigidbody. rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; } _moveMonitor = Timing.RunCoroutine(MonitorMovement().CancelWith(gameObject)); soundMaker = soundMakers[UnityEngine.Random.Range(0, soundMakers.Count)]; nextSoundMaker = soundMakers[UnityEngine.Random.Range(0, soundMakers.Count)]; SoundsListener.OnSoundEvent += OnSoundEventHandler; }
protected override void Repeat() { if (_isRunning) { if (_interruptable) { Timing.KillCoroutines(_repeatCoroutine); _currentCount = 0; _isRunning = false; } else { return; } } _isRunning = true; _repeatCoroutine = Timing.RunCoroutine(ProcessRepeater().CancelWith(_root)); }
public Dash(BaseEvent ef, Character caster, bool ignoreMinSpeedOnAir, Skill skill, Environment environment) { this.ef = ef; this.caster = caster; this.ignoreMinSpeedOnAir = ignoreMinSpeedOnAir; this.skill = skill; mapGround = environment.MapColliders().bottom; mapCeil = environment.MapColliders().top; GameObject gameObject = caster.GameObject(); casterTransform = gameObject.transform; casterBoxCollider = gameObject.GetComponent <BoxCollider>(); casterEntity = gameObject.GetComponent <EntityReference>().Entity; movementComponent = casterEntity.GetComponent <MovementComponent>(); da = (DashAction)ef.ShowAction(); if (ef.ShowTrigger().ShowTriggerType() == TriggerType.Frame) { TimelineTrigger tt = (TimelineTrigger)ef.ShowTrigger(); duration = da.ShowEndFrameInSeconds(tt.ShowScaleTime()); } else { duration = da.ShowEndFrameInSeconds(1); } PerformDash(da, caster); isDashPerformed = true; CacheOriginalColliderData(ef, caster); ResizeCollider(ef); if (da.collision) { cubeShape = new CubeShape(GetCenterOfHitbox(), casterBoxCollider.size, new List <SsarTuple <Color, float> >(new [] { new SsarTuple <Color, float>(Color.cyan, duration), })); GizmosDrawer.Instance.AddRequest(new DrawRequest(cubeShape, duration)); } if (da.collision) { collisionDetectionCoroutineHandle = Timing.RunCoroutine(DetectCollision(), Segment.FixedUpdate); centerOfHitBoxAtPreviousFrame = GetCenterOfHitbox(); } positionAtPreviousFrame = movementComponent.Position; }
private CoroutineHandle Start(uint inIndex, MonoBehaviour inHost, IEnumerator inStartingPoint) { m_Handle = new CoroutineHandle(inIndex); m_Host = inHost; if (m_Host == null) { m_Host = s_RoutineHost; Assert.True(m_Host != null, "Host has been specified."); } ClearStack(); m_Stack.Push(inStartingPoint); m_Paused = false; m_Disposing = false; m_UnityWait = null; m_WaitTime = 0.0f; s_CurrentlyRunning.Add(this); return(m_Handle); }
private void OnConfigReloaded() { if (Config.EnablePrecache) { CacheReady = false; } Timing.KillCoroutines(IntercomHandle); IntercomHandle = new CoroutineHandle(); Timing.KillCoroutines(Coroutines); Coroutines.Clear(); ImageCache.Clear(); preCache = Timing.RunCoroutine(RunPreCache()); OnRoundStart(); ReferenceHub.HostHub.GetComponent <Intercom>().CustomContent = ""; IntercomText = null; }
public void OnEggTap() { if (!AllowTap) { return; } Genie.I.LogEvent(OE_INTERACT.Create(OE_INTERACT.Type.TOUCH, "hud.tapEggs")); if (transform.parent.FindChild("egg1").GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Base Layer.eggsIdle")) { SoundManager.instance.PlayRandomOneShot(SoundManager.instance.hudTapEgg, .5f); transform.parent.FindChild("egg1").GetComponent <Animator>().SetTrigger("tapped"); secondTap.Clear(); if (Session.instance.eggsEarned != 1) { secondTap = this.WaitSecondsThen(.25f, TapSecondEgg); } } }
private IEnumerable <object> SendStateAfterDelay() { while (sendStateTimer > 0.0f) { sendStateTimer -= CoroutineManager.DeltaTime; yield return(CoroutineStatus.Running); } if (item.Removed || GameMain.NetworkMember == null) { yield return(CoroutineStatus.Success); } sendStateCoroutine = null; if (lastSentText != Text) { item.CreateServerEvent(this); } yield return(CoroutineStatus.Success); }
private IEnumerator <float> ShowIntercom(Dictionary <string, string> image, int scale, float fps) { yield return(Timing.WaitUntilDone(preCache)); List <string> frames = new List <string>(); CoroutineHandle handle = new CoroutineHandle(); try { handle = Util.LocationToText(image["location"], text => { IntercomText = text.Replace("\\n", "\n"); ReferenceHub.HostHub.GetComponent <Intercom>().CustomContent = IntercomText; frames.Add(IntercomText); }, image["name"].Trim().ToLower(), image["isURL"] == "true", scale, true, 1 / fps); Coroutines.Add(handle); } catch (Exception e) { Log.Error(e); } yield return(Timing.WaitUntilDone(handle)); var cur = 0; if (frames.Count > 1) { while (true) { IntercomText = frames[cur % frames.Count]; ReferenceHub.HostHub.GetComponent <Intercom>().CustomContent = IntercomText; yield return(Timing.WaitForSeconds(1 / fps)); cur++; } } }
internal void RunIntercomImage(string imageName) { if (imageName == "none" || Config.Images.Count(img => img["name"].Trim().ToLower().Replace(" ", "") == imageName) <= 0) { return; } var image = Config.Images.First(img => img["name"].Trim().ToLower().Replace(" ", "") == imageName); var scale = 0; if (image.ContainsKey("scale") && image["scale"].Trim().ToLower() != "auto" && !int.TryParse(image["scale"].Trim().ToLower(), out scale)) { Log.Error("The scale value for the custom intercom image is incorrect. Use an integer or \"auto\"."); return; } var fps = 10; if (image.ContainsKey("fps") && image["fps"].Trim().ToLower() != "auto" && !int.TryParse(image["fps"].Trim().ToLower(), out fps)) { Log.Error("The fps value for the custom intercom image is incorrect. Use an integer."); return; } var compress = true; if (image.ContainsKey("compress") && !bool.TryParse(image["compress"].Trim().ToLower(), out compress)) { Log.Info("The compress parameter for this image is invalid. Only use booleans"); return; } Timing.KillCoroutines(IntercomHandle); IntercomText = null; ReferenceHub.HostHub.GetComponent <Intercom>().CustomContent = ""; IntercomHandle = Timing.RunCoroutine(ShowIntercom(image, scale, fps, compress)); Coroutines.Add(IntercomHandle); }
/// <inheritdoc cref="Exiled.Events.Handlers.Server.OnRoundStarted"/> public void OnRoundStarted() { teslasDisabled = false; if (plugin.Config.Blackouts.ModifyDoors) { doorsToChange = Map.Doors.Where(d => config.Blackouts.BlacklistedDoors.All(s => d != Map.GetDoorByName(s))); } if (config.AutomaticBlackouts.DoAutomaticBlackouts) { if (config.AutomaticBlackouts.DoMultipleBlackouts) { automaticHandler = Timing.RunCoroutine(MultipleBlackouts()); } else { automaticHandler = Timing.RunCoroutine(SingleBlackout()); } } }
/// <summary> /// Starts running the timer. /// </summary> public void Start() { if (IsRunning) { return; } _startTime = Time.time; IsRunning = true; float remaining = Duration - _elapsedTime; if (remaining > 0) { _timerHandle = Timing.CallDelayed(remaining, Finish); } else { Finish(); } }
private void OnPathProcessed(Guid requestID, Vector3[] WayPoints, bool bPathFound) { if (bPathFound && currentRequestID == requestID) { if (SmoothPath) { mPath = new Path(WayPoints, mUnitTransform.position, fTurnDistance); Timing.KillCoroutines("WalkTheSmoothPath"); Timing.RunCoroutine(WalkTheSmoothPath()); } else { vec3_WayPoints = WayPoints; nTargetIndex = 0; Timing.KillCoroutines(handle); handle = Timing.RunCoroutine(WalkThePath()); } } }
private void Dispose() { if (m_Handle) { m_Host = null; m_Paused = false; ClearStack(); if (m_UnityWait != null) { s_RoutineHost.StopCoroutine(m_UnityWait); m_UnityWait = null; } s_Pool.Push(this); s_CurrentlyRunning.Remove(this); m_Handle = CoroutineHandle.Null; } }
internal void StartNetworkClient() { PacketProcessor.RegisterNestedType <CommandInfo>(); PacketProcessor.RegisterNestedType <PlayerInfo>(); PacketProcessor.RegisterNestedType <Position>(); PacketProcessor.RegisterNestedType <Rotation>(); PacketProcessor.RegisterNestedType <AddonInfo>(); PacketProcessor.SubscribeReusable <PlayerInteractPacket, NetPeer>(OnPlayerInteract); PacketProcessor.SubscribeReusable <ServerInteractPacket, NetPeer>(OnServerInteract); PacketProcessor.SubscribeReusable <ReceiveCommandsPacket, NetPeer>(OnReceiveCommandsData); PacketProcessor.SubscribeReusable <SendTokenPacket, NetPeer>(OnReceiveNewToken); PacketProcessor.SubscribeReusable <SendAddonsInfoPacket, NetPeer>(OnReceiveAddons); PacketProcessor.SubscribeReusable <EventPacket, NetPeer>(OnReceiveEvent); PacketProcessor.SubscribeReusable <AddonDataPacket, NetPeer>(OnReceiveAddonData); PacketProcessor.SubscribeReusable <UnloadAddonPacket, NetPeer>(OnUnloadAddons); NetworkListener = new NetManager(this); NetworkListener.Start(); CreateDefaultConnectionData(); NetworkListener.Connect(plugin.Config.HostAddress, plugin.Config.HostPort, defaultdata); refreshPolls = Timing.RunCoroutine(RefreshPolls()); }
public void OnPlayerHurt(HurtingEventArgs ev) { if (ev.Target == player) { if (ev.DamageType != DamageTypes.Scp207) { player.Health += ev.Amount < 0 ? -9999999f : -ev.Amount; } if (!excludedDamages.Contains(ev.DamageType)) { AngerMeter += ev.Amount; } else { ev.Amount = 0; return; } ev.Amount = 0; if (AngerMeter > BetterScp939.Instance.Config.AngerMeterMaximum) { AngerMeter = BetterScp939.Instance.Config.AngerMeterMaximum; } player.AdrenalineHealth = (byte)(AngerMeter / BetterScp939.Instance.Config.AngerMeterMaximum * player.MaxAdrenalineHealth); if (!angerMeterDecayCoroutine.IsRunning) { angerMeterDecayCoroutine = Timing.RunCoroutine(AngerMeterDecay(BetterScp939.Instance.Config.AngerMeterDecayTime), Segment.FixedUpdate); } } else if (ev.Attacker == player && ev.Amount > 0) { ev.Amount = BetterScp939.Instance.Config.BaseDamage + (AngerMeter / BetterScp939.Instance.Config.AngerMeterMaximum) * BetterScp939.Instance.Config.BonusAttackMaximum; forceSlowDownCoroutine = Timing.RunCoroutine(ForceSlowDown(BetterScp939.Instance.Config.ForceSlowDownTime, forceSlowDownInterval), Segment.FixedUpdate); } }
public override void OnDisabled() { base.OnDisabled(); if (Config.EnablePrecache) { CacheReady = false; } Timing.KillCoroutines(IntercomHandle); IntercomHandle = new CoroutineHandle(); foreach (var coroutineHandle in Coroutines) { Timing.KillCoroutines(coroutineHandle); } Coroutines.Clear(); Singleton = null; harmony.UnpatchAll(); Exiled.Events.Handlers.Server.RoundStarted -= OnRoundStart; Exiled.Events.Handlers.Server.RestartingRound -= OnRoundRestart; Exiled.Events.Handlers.Player.Joined -= OnPlayerJoin; Exiled.Events.Handlers.Server.ReloadedConfigs -= OnConfigReloaded; foreach (var command in commands) { CommandProcessor.RemoteAdminCommandHandler.UnregisterCommand(command); GameCore.Console.singleton.ConsoleCommandHandler.UnregisterCommand(command); } commands.Clear(); ImageCache.Clear(); ReferenceHub.HostHub.GetComponent <Intercom>().CustomContent = ""; IntercomText = null; }
public void On106CreatePortal(Player106CreatePortalEvent ev) { if (!singleCreate) { singleCreate = true; return; } else { PocketTrap.instance.Debug($"[On106CreatePortal] {ev.Player.Name}<{ev.Player.TeamRole.Role}> / {ev.Position}"); if (waitcoroutine == null) { waitcoroutine = Timing.RunCoroutine(_WaitForPortalActivated(), Segment.FixedUpdate); } else { Timing.KillCoroutines(waitcoroutine); waitcoroutine = Timing.RunCoroutine(_WaitForPortalActivated(), Segment.FixedUpdate); } singleCreate = false; } }
public void Remove() { #if CLIENT if (loopingSoundChannel != null) { loopingSoundChannel.Dispose(); loopingSoundChannel = null; } if (GuiFrame != null) { GUI.RemoveFromUpdateList(GuiFrame, true); } #endif if (delayedCorrectionCoroutine != null) { CoroutineManager.StopCoroutines(delayedCorrectionCoroutine); delayedCorrectionCoroutine = null; } RemoveComponentSpecific(); }
private IEnumerator <float> ShowIntercom(HandleCommandObject obj) { var frames = new List <string>(); var handle = new CoroutineHandle(); try { handle = Util.LocationToText(obj.image["location"], text => { Images.Singleton.IntercomText = text.Replace("\\n", "\n"); ReferenceHub.HostHub.GetComponent <Intercom>().CustomContent = Images.Singleton.IntercomText; frames.Add(Images.Singleton.IntercomText); }, obj.image["name"].Trim().ToLower(), obj.image["isURL"] == "true", obj.scale, true, 1 / obj.fps); Images.Singleton.Coroutines.Add(handle); } catch (Exception e) { Log.Error(e); } yield return(Timing.WaitUntilDone(handle)); var cur = 0; if (frames.Count <= 1) { yield break; } while (true) { Images.Singleton.IntercomText = frames[cur % frames.Count]; ReferenceHub.HostHub.GetComponent <Intercom>().CustomContent = Images.Singleton.IntercomText; yield return(Timing.WaitForSeconds(1 / obj.fps)); cur++; } }
private void DebugBlocked(StepTaskEntityBase stepTaskEntity) { _hitBreakPointsLock.EnterWriteLock(); // 暂停的场景 CoroutineHandle coroutineHandle = stepTaskEntity.Coroutine; if (_hitBreakPoints.ContainsKey(coroutineHandle.Id)) { _hitBreakPoints[coroutineHandle.Id] = stepTaskEntity; } // 断点命中的场景 else { _hitBreakPoints.Add(coroutineHandle.Id, stepTaskEntity); } _hitBreakPointsLock.ExitWriteLock(); CallStack breakPoint = stepTaskEntity.GetStack(); _watchDatas.Values.Clear(); foreach (string watchData in _watchDatas.Names) { string variableName = ModuleUtils.GetVariableNameFromParamValue(watchData); _watchDatas.Values.Add(_context.VariableMapper.GetWatchDataValue(variableName, watchData)); } DebugMessage debugMessage = new DebugMessage(MessageNames.BreakPointHitName, _context.SessionId, breakPoint, false) { WatchData = _watchDatas }; // 发送断点命中消息 _context.MessageTransceiver.SendMessage(debugMessage); _context.LogSession.Print(LogLevel.Debug, _context.SessionId, $"Breakpoint hitted:{breakPoint}"); coroutineHandle.WaitSignal(); }
public static void MakePlayer035(Player player) { Scp035Player = player; Scp035Player.AddItem(ItemType.KeycardZoneManager); Scp035Player.ShowHint("You are now SCP-035", 5); Scp035Player.SetInfo(PlayerInfoArea.Role, "SCP-035"); Scp035Player.DisplayNick = "[SCP-035] " + Scp035Player.Nick; foreach (NetworkBehaviour behaviour in Scp035Player.Hub.networkIdentity.NetworkBehaviours) { if (behaviour.GetType() == typeof(DissonanceUserSetup)) { DUS = (DissonanceUserSetup)behaviour; // Scp035.Singleton.AddLog("Found DissonanceUserSetup of player"); } } DissonanceUserSetup dus = DUS; dus.SCPChat = true; dus.MimicAs939 = true; dus.SpeakerAs079 = true; Hurt035Coroutine = Timing.RunCoroutine(Damage035()); Scp035.Singleton.AddLog("Player " + Scp035Player.Nick + " is now Scp035"); }
public void ShowRewardVideo() { #if UNITY_EDITOR || UNITY_STANDALONE DoCompletedRewardVideo(); return; #endif if (reward.IsLoaded()) { Timing.KillCoroutines(handleLoadAds); handleLoadAds = Timing.RunCoroutine(_LoadAds()); reward.Show(); } else { RefreshRewardVideo(); DoFailedRewardVideo(); } }
private IEnumerator <float> _StartTimer(int timeInSeconds, int countdownTimeInSeconds) { Debug.Log("STARTING TIMER"); isAlreadyRunning = true; yield return(Timing.WaitUntilDone(countdownCoroutine = Timing.RunCoroutine(_PlayCountdown(countdownTimeInSeconds)))); onStartTimer.Invoke(); time = timeInSeconds; do { yield return(Timing.WaitForOneFrame); time -= Time.deltaTime; onTimerTicked.Invoke((long)(time * 1000)); } while (time > 0); onTimerTicked.Invoke((long)(time * 1000)); onEndTimer.Invoke(); isAlreadyRunning = false; }
private IEnumerator <float> DiffuseBomb(Player player) { //if (player.Inventory.items.FindIndex(p => p.id == ItemType.Disarmer) != -1) if (player.Role == plugin.Config.NTFRole) { player.ReferenceHub.playerEffectsController.ChangeEffectIntensity <Ensnared>(1); diffusing = true; diffuser = player; yield return(Timing.WaitForSeconds(plugin.Config.DiffuseTime)); if (player.Role == plugin.Config.NTFRole) { player.ReferenceHub.playerEffectsController.ChangeEffectIntensity <Ensnared>(0); bombDiffused = true; bombPlanted = false; diffusing = false; diffuser = null; AddMoney(plugin.Config.BombInteractMoney, player); } } Timing.KillCoroutines(plantHandle); plantHandle = new CoroutineHandle(); }
IEnumerator <float> AbilityRoutine(Entity target, object payload) { List <Collider> hitColliders = new List <Collider>(); Vector3 position = transform.position; foreach (Hitbox hitbox in hitboxes) { //hitbox.HitboxObject.transform.position = position; //hitbox.hitboxObject.SetActive(true); yield return(Timing.WaitForSeconds(hitbox.Delay)); CoroutineHandle hitboxHandle = Timing.RunCoroutine(HitboxRoutine(hitbox, hitColliders, position)); yield return(Timing.WaitForSeconds(hitbox.Duration)); Timing.KillCoroutines(hitboxHandle); //hitbox.hitboxObject.SetActive(false); } if (!isToggle) { EndAbility(target, payload); } }
private void FadeOperatorsTo(float inValue) { m_OperatorFadeRoutine.Clear(); m_OperatorFadeRoutine = this.SmartCoroutine(Tween.ValueTo(m_OperatorNestFade, inValue, this.InvalidDragTargetFadeTime, SetOperatorNestFade)); }
public int KillCoroutines(CoroutineHandle handle) { return(Timing.KillCoroutines(handle)); }
private void FadeChickensTo(float inValue) { m_ChickenFadeRoutine.Clear(); m_ChickenFadeRoutine = this.SmartCoroutine(Tween.ValueTo(m_ChickenNestFade, inValue, this.InvalidDragTargetFadeTime, SetChickenNestFade)); }