void DrawCounters() { var counters = m_NetworkClient.counters; if (counters == null) { return; } int y = 2; DebugOverlay.Write(2, y++, " Bytes in : {0}", counters.bytesIn); DebugOverlay.Write(2, y++, " Bytes out : {0}", counters.bytesOut); DebugOverlay.Write(2, y++, " Packages in : {0}", counters.packagesIn); DebugOverlay.Write(2, y++, " Packages out : {0}", counters.packagesOut); y++; DebugOverlay.Write(2, y++, " Stale packages : {0}", counters.packagesStaleIn); DebugOverlay.Write(2, y++, " Duplicate packages : {0}", counters.packagesDuplicateIn); DebugOverlay.Write(2, y++, " Out of order packages : {0}", counters.packagesOutOfOrderIn); y++; DebugOverlay.Write(2, y++, " Lost packages in : {0}", counters.packagesLostIn); DebugOverlay.Write(2, y++, " Lost packages out : {0}", counters.packagesLostOut); y++; DebugOverlay.Write(2, y++, " Fragmented packages in : {0}", counters.fragmentedPackagesIn); DebugOverlay.Write(2, y++, " Fragmented packages out : {0}", counters.fragmentedPackagesOut); DebugOverlay.Write(2, y++, " Fragmented packages lost in : {0}", counters.fragmentedPackagesLostIn); DebugOverlay.Write(2, y++, " Fragmented packages lost out : {0}", counters.fragmentedPackagesLostOut); y++; DebugOverlay.Write(2, y++, " Choked packages lost : {0}", counters.chokedPackagesOut); }
public static void ConsoleUpdate() { var lastMsgTime = Time.realtimeSinceStartup - timeLastMsg; if (lastMsgTime < 1.0) { DebugOverlay.Write(0, 0, lastMsg); } s_ConsoleUI.ConsoleUpdate(); while (s_PendingCommands.Count > 0) { if (s_PendingCommandsWaitForFrames > 0) { s_PendingCommandsWaitForFrames--; break; } if (s_PendingCommandsWaitForLoad) { s_PendingCommandsWaitForLoad = false; } // Remove before executing as we may hit an 'exec' command that wants to insert commands var cmd = s_PendingCommands[0]; s_PendingCommands.RemoveAt(0); ExecuteCommand(cmd); } }
public static void ConsoleUpdate() { var lastMsgTime = Game.frameTime - timeLastMsg; if (lastMsgTime < 1.0) { DebugOverlay.Write(0, 0, lastMsg); } s_ConsoleUI.ConsoleUpdate(); while (s_PendingCommands.Count > 0) { if (s_PendingCommandsWaitForFrames > 0) { s_PendingCommandsWaitForFrames--; break; } if (s_PendingCommandsWaitForLoad) { if (!Game.game.levelManager.IsCurrentLevelLoaded()) { break; } s_PendingCommandsWaitForLoad = false; } // Remove before executing as we may hit an 'exec' command that wants to insert commands var cmd = s_PendingCommands[0]; s_PendingCommands.RemoveAt(0); ExecuteCommand(cmd); } }
public void ShowHistory(GameWorld world) { StateHistory.Enabled = true; var state = new CharacterPredictedState.StateData(); var count = DebugOverlay.Height - 4; for (var iEntry = 0; iEntry < count; iEntry++) { var tick = world.worldTime.tick - count + 1 + iEntry; StateHistory.GetPredictedState(this, tick, ref state); var y = 2 + iEntry; { var color = (Color32)Color.HSVToRGB(0.21f * (int)state.locoState, 1, 1); var colorRGB = ((color.r >> 4) << 8) | ((color.g >> 4) << 4) | (color.b >> 4); DebugOverlay.Write(2, y, "^{0}{1}", colorRGB.ToString("X3"), state.locoState.ToString()); } DebugOverlay.Write(14, y, state.sprinting ? "Sprint" : "no-sprint"); { var color = (Color32)Color.HSVToRGB(0.21f * (int)state.action, 1, 1); var colorRGB = ((color.r >> 4) << 8) | ((color.g >> 4) << 4) | (color.b >> 4); DebugOverlay.Write(26, y, "^{0}{1}", colorRGB.ToString("X3"), state.action.ToString()); } } }
void DebugApplyPresentation() { if (debugStandIk.IntValue > 0) { var charIndex = s_Instances.IndexOf(this); var lineIndex = charIndex * 3 + 1; var color = s_DebugColors[charIndex % s_DebugColors.Length]; var leftHitString = "Char " + charIndex + " - Left XForm hit: Nothing"; if (m_LeftHitSuccess) { leftHitString = "Char " + charIndex + " - Left XForm hit: " + m_LeftHit.transform.name; } DebugOverlay.Write(color, 2, lineIndex, leftHitString); GameDebug.Log(leftHitString); var rightHitString = "Char " + charIndex + " - Right XForm hit: Nothing"; if (m_RightHitSuccess) { rightHitString = "Char " + charIndex + " - Right XForm hit: " + m_RightHit.transform.name; } DebugOverlay.Write(color, 2, lineIndex + 1, rightHitString); GameDebug.Log(rightHitString); } }
void DrawStats() { var samplesPerSecond = 1.0f / m_StatsDeltaTime.average; int y = 2; DebugOverlay.Write(2, y++, " tick rate: {0}", m_NetworkClient.serverTickRate); DebugOverlay.Write(2, y++, " frame timescale: {0}", m_FrameTimeScale); DebugOverlay.Write(2, y++, " sim : {0:0.0} / {1:0.0} / {2:0.0} ({3:0.0})", m_ServerSimTime.min, m_ServerSimTime.min, m_ServerSimTime.max, m_ServerSimTime.stdDeviation); DebugOverlay.Write(2, y++, "^FF0 lat : {0:0.0} / {1:0.0} / {2:0.0}", m_Latency.min, m_Latency.average, m_Latency.max); DebugOverlay.Write(2, y++, "^0FF rtt : {0:0.0} / {1:0.0} / {2:0.0}", m_RTT.min, m_RTT.average, m_RTT.max); DebugOverlay.Write(2, y++, "^0F0 cmdq : {0:0.0} / {1:0.0} / {2:0.0}", m_CMDQ.min, m_CMDQ.average, m_CMDQ.max); DebugOverlay.Write(2, y++, "^F0F intp : {0:0.0} / {1:0.0} / {2:0.0}", m_Interp.min, m_Interp.average, m_Interp.max); y++; DebugOverlay.Write(2, y++, "^22F header/payload/total bps (in):"); DebugOverlay.Write(2, y++, "^22F {0:00.0} / {1:00.0} / {2:00.0} ({3})", m_HeaderBitsIn.graph.average / 8.0f * samplesPerSecond, (m_BytesIn.graph.average - m_HeaderBitsIn.graph.average / 8.0f) * samplesPerSecond, m_BytesIn.graph.average * samplesPerSecond, m_NetworkClient.clientConfig.serverUpdateRate); DebugOverlay.Write(2, y++, "^F00 bps (out): {0:00.0}", m_BytesOut.graph.average * samplesPerSecond); DebugOverlay.Write(2, y++, " pps (in): {0:00.0}", m_PackagesIn.graph.average * samplesPerSecond); DebugOverlay.Write(2, y++, " pps (out): {0:00.0}", m_PackagesOut.graph.average * samplesPerSecond); DebugOverlay.Write(2, y++, " pl% (in): {0:00.0}", m_PackageLossPctIn.average); DebugOverlay.Write(2, y++, " pl% (out): {0:00.0}", m_PackageLossPctOut.average); y++; DebugOverlay.Write(2, y++, " upd_srate: {0:00.0} ({1})", m_SnapshotsIn.graph.average * samplesPerSecond, m_NetworkClient.clientConfig.serverUpdateInterval); DebugOverlay.Write(2, y++, " cmd_srate: {0:00.0} ({1})", m_CommandsOut.graph.average * samplesPerSecond, m_NetworkClient.serverTickRate); DebugOverlay.Write(2, y++, " ev (in): {0:00.0}", m_EventsIn.graph.average * samplesPerSecond); DebugOverlay.Write(2, y++, " ev (out): {0:00.0}", m_EventsOut.graph.average * samplesPerSecond); var startIndex = m_BytesIn.graph.GetData().HeadIndex; var graphY = 5; DebugOverlay.DrawGraph(38, graphY, 60, 5, m_Latency.GetData().GetArray(), startIndex, Color.yellow, 100); DebugOverlay.DrawGraph(38, graphY, 60, 5, m_RTT.GetData().GetArray(), startIndex, Color.cyan, 100); DebugOverlay.DrawGraph(38, graphY, 60, 5, m_CMDQ.GetData().GetArray(), startIndex, Color.green, 10); DebugOverlay.DrawGraph(38, graphY, 60, 5, m_Interp.GetData().GetArray(), startIndex, Color.magenta, 100); DebugOverlay.DrawHist(38, graphY, 60, 5, m_HardCatchup.GetArray(), startIndex, Color.red, 100); m_2GraphData[0] = m_BytesIn.graph.GetData().GetArray(); m_2GraphData[1] = m_BytesOut.graph.GetData().GetArray(); graphY += 7; DebugOverlay.DrawGraph(38, graphY, 60, 5, m_2GraphData, startIndex, m_BytesGraphColors); graphY += 6; DebugOverlay.DrawHist(38, graphY++, 60, 1, m_SnapshotsIn.graph.GetData().GetArray(), startIndex, Color.blue, 5.0f); DebugOverlay.DrawHist(38, graphY++, 60, 1, m_CommandsOut.graph.GetData().GetArray(), startIndex, Color.red, 5.0f); DebugOverlay.DrawHist(38, graphY++, 60, 1, m_EventsIn.graph.GetData().GetArray(), startIndex, Color.yellow, 5.0f); DebugOverlay.DrawHist(38, graphY++, 60, 1, m_EventsOut.graph.GetData().GetArray(), startIndex, Color.green, 5.0f); }
void DrawCompactStats() { var samplesPerSecond = 1.0f / m_StatsDeltaTime.average; DebugOverlay.Write(-50, -4, "pps (in/out): {0} / {1}", m_PackagesIn.graph.average * samplesPerSecond, m_PackagesOut.graph.average * samplesPerSecond); DebugOverlay.Write(-50, -3, "bps (in/out): {0:00.0} / {1:00.0}", m_BytesIn.graph.average * samplesPerSecond, m_BytesOut.graph.average * samplesPerSecond); var startIndex = m_BytesIn.graph.GetData().HeadIndex; DebugOverlay.DrawHist(-50, -2, 20, 2, m_BytesIn.graph.GetData().GetArray(), startIndex, Color.blue, 5.0f); }
void DrawFPS() { DebugOverlay.Write(0, 1, "{0} FPS ({1:##.##} ms)", Mathf.RoundToInt(1000.0f / m_FrameDurationMS), m_FrameDurationMS); float minDuration = float.MaxValue; float maxDuration = float.MinValue; float sum = 0; for (var i = 0; i < _no_frames; i++) { var frametime = m_FrameTimes[i]; sum += frametime; if (frametime < minDuration) { minDuration = frametime; } if (frametime > maxDuration) { maxDuration = frametime; } } DebugOverlay.Write(Color.green, 0, 2, "{0:##.##}", minDuration); DebugOverlay.Write(Color.grey, 6, 2, "{0:##.##}", sum / _no_frames); DebugOverlay.Write(Color.red, 12, 2, "{0:##.##}", maxDuration); DebugOverlay.Write(0, 3, "Frame #: {0}", Time.frameCount); DebugOverlay.Write(0, 4, m_GraphicsDeviceName); int y = 6; for (int i = 0; i < recordersList.Length; i++) { DebugOverlay.Write(0, y++, "{0:##.##}ms (*{1:##}) ({2:##.##}ms *{3:##}) {4}", recordersList[i].avgTime, recordersList[i].avgCount, recordersList[i].time, recordersList[i].count, recordersList[i].name); } if (showFPS.IntValue < 3) { return; } y++; // Start at framecount+1 so the one we have just recorded will be the last DebugOverlay.DrawHist(0, y, 20, 2, m_FrameTimes, Time.frameCount + 1, fpsColor, 20.0f); DebugOverlay.DrawHist(0, y + 2, 20, 2, m_TicksPerFrame, Time.frameCount + 1, histColor, 3.0f * 16.0f); DebugOverlay.DrawGraph(0, y + 6, 40, 2, m_FrameTimes, Time.frameCount + 1, fpsColor, 20.0f); if (GameWorld.s_Worlds.Count > 0) { var world = GameWorld.s_Worlds[0]; DebugOverlay.Write(0, y + 8, "Tick: {0:##.#}", 1000.0f * world.worldTime.tickInterval); } }
void DebugUpdatePresentation(PresentationState animState) { if (debugStandIk.IntValue > 0) { var charIndex = s_Instances.IndexOf(this); var lineIndex = charIndex * 3 + 3; var debugString = "Char " + charIndex + " - IK Offset: " + animState.footIkOffset.x.ToString("0.000") + ", " + animState.footIkOffset.y.ToString("0.000"); DebugOverlay.Write(s_DebugColors[charIndex % s_DebugColors.Length], 2, lineIndex, debugString); GameDebug.Log(debugString); } }
public void ShowHistory(int tick) { if (historyBuffer == null) { historyBuffer = new CharPredictedStateData[30]; } var goe = GetComponent <GameObjectEntity>(); var nextIndex = (historyFirstIndex + historyCount) % historyBuffer.Length; historyBuffer[nextIndex] = goe.EntityManager.GetComponentData <CharPredictedStateData>(goe.Entity);; // GameDebug.Log(state.locoState + " sprint:" + state.sprinting + " action:" + state.action); if (historyCount < historyBuffer.Length) { historyCount++; } else { historyFirstIndex = (historyFirstIndex + 1) % historyBuffer.Length; } for (int i = 0; i < historyCount; i++) { var index = (historyFirstIndex + i) % historyBuffer.Length; var state = historyBuffer[index]; var y = 2 + i; { var color = (Color32)Color.HSVToRGB(0.21f * (int)state.locoState, 1, 1); var colorRGB = ((color.r >> 4) << 8) | ((color.g >> 4) << 4) | (color.b >> 4); DebugOverlay.Write(2, y, "^{0}{1}", colorRGB.ToString("X3"), state.locoState.ToString()); } DebugOverlay.Write(14, y, state.sprinting == 1 ? "Sprint" : "no-sprint"); { var color = (Color32)Color.HSVToRGB(0.21f * (int)state.action, 1, 1); var colorRGB = ((color.r >> 4) << 8) | ((color.g >> 4) << 4) | (color.b >> 4); DebugOverlay.Write(26, y, "^{0}{1}:{2}", colorRGB.ToString("X3"), state.action.ToString(), state.actionStartTick); } } }
void DrawPackageStatistics() { float x = DebugOverlay.Width - 20; float y = DebugOverlay.Height - 8; float dx = 1.0f; // bar spacing float w = 1.0f; // width of bars int maxbits = 0; var stats = m_NetworkClient.counters.packageContentStats; var last = m_NetworkClient.counters.packagesIn; for (var i = last; i > 0 && i > last - stats.Length; --i) { var s = stats[i % stats.Length]; if (s == null) { continue; } var barx = x + (i - last) * dx; for (int j = 0, c = s.Count; j < c; ++j) { var stat = s[j]; DebugOverlay.DrawRect(barx, y - (stat.sectionStart + stat.sectionLength) * bitheight, w, stat.sectionLength * bitheight, stat.color); } var lastStat = s[s.Count - 1]; if (lastStat.sectionStart + lastStat.sectionLength > maxbits) { maxbits = lastStat.sectionStart + lastStat.sectionLength; } } int maxbytes = (maxbits + 7) / 8; int step = Mathf.Max(1, maxbytes >> 4) * 16; for (var i = 0; i <= maxbytes; i += step) { DebugOverlay.Write(x - 4, y - i * 8 * bitheight - 0.5f, "{0:###}b", i); } bitheight = Mathf.Min(0.01f, 10.0f / maxbits); }
static void DrawQualityOverlay() { DebugOverlay.Write(2, 2, "Quality Settings"); DebugOverlay.Write(2, 4, "Current camera: {0}", Game.game.TopCamera() != null ? Game.game.TopCamera().name : "(null)"); //DebugOverlay.Write(2, 5, "Post volume: {0}", "");// Game.game.TopCamera() != null ? Game.game.TopCamera().name : "(null)"); DebugOverlay.Write(2, 7, "r.aamode: {0}", rAAMode.Value); DebugOverlay.Write(2, 8, "r.aaquality: {0}", rAAQuality.Value); DebugOverlay.Write(2, 9, "r.bloom: {0}", rBloom.IntValue); DebugOverlay.Write(2, 10, "r.motionblur: {0}", rMotionBlur.IntValue); DebugOverlay.Write(2, 11, "r.ssao: {0}", rSSAO.IntValue); DebugOverlay.Write(2, 12, "r.grain: {0}", rGrain.IntValue); DebugOverlay.Write(2, 13, "r.ssr: {0}", rSSR.IntValue); DebugOverlay.Write(2, 15, "r.sss: {0}", rSSS.IntValue); DebugOverlay.Write(2, 16, "r.roughrefraction: {0}", rRoughRefraction.IntValue); DebugOverlay.Write(2, 17, "r.distortion: {0}", rDistortion.IntValue); DebugOverlay.Write(2, 19, "r.decaldist: {0}", rDecalDist.IntValue); DebugOverlay.Write(2, 20, "r.shadowdistmult: {0}", rShadowDistMult.FloatValue); }
void ShowInfoOverlay(float x, float y) { if (m_showTickInfo.IntValue == 1) { DebugOverlay.Write(x, y++, "Tick:{0} Last server:{1} Predicted:{2}", m_clientWorld.PredictedTime.tick, m_NetworkClient.serverTime, m_clientWorld.PredictedTime.tick - m_NetworkClient.serverTime - 1); } if (m_showCommandInfo.IntValue == 1) { UserCommand command = UserCommand.defaultCommand; bool valid = m_LocalPlayer.commandBuffer.TryGetValue(m_clientWorld.PredictedTime.tick + 1, ref command); if (valid) { DebugOverlay.Write(x, y++, "Next cmd: PrimaryFire:{0}", command.primaryFire ? 1:0); } valid = m_LocalPlayer.commandBuffer.TryGetValue(m_clientWorld.PredictedTime.tick, ref command); if (valid) { DebugOverlay.Write(x, y++, "Tick cmd: PrimaryFire:{0}", command.primaryFire ? 1:0); } } }
public void TickUpdate() { if (m_ShowStats < 1) { return; } long ticks = m_StopWatch.ElapsedTicks; float frameDurationMs = (ticks - m_LastFrameTicks) * 1000 / (float)m_StopWatchFreq; m_LastFrameTicks = ticks; DebugOverlay.SetColor(Color.yellow); DebugOverlay.SetOrigin(0, 0); DebugOverlay.Write(1, 0, "FPS:{0,6:###.##}", 1.0f / Time.deltaTime); fpsHistory[Time.frameCount % fpsHistory.Length] = 1.0f / Time.deltaTime; DebugOverlay.DrawGraph(1, 1, 9, 1.5f, fpsHistory, Time.frameCount % fpsHistory.Length, Color.green); DebugOverlay.Write(30, 0, "Open console (F12) and type: \"showstats\" to toggle graphs"); if (m_ShowStats < 2) { return; } DebugOverlay.Write(0, 4, "Hello, {0,-5} world!", Time.frameCount % 100 < 50 ? "Happy" : "Evil"); DebugOverlay.Write(0, 5, "FrameNo: {0,7}", Time.frameCount); DebugOverlay.Write(0, 6, "MonoHeap:{0,7} kb", (int)(UnityEngine.Profiling.Profiler.GetMonoUsedSizeLong() / 1024)); /// Graphing difference between deltaTime and actual passed time float fps = Time.deltaTime * 1000.0f; var idx = Time.frameCount % fpsArray[0].Length;; fpsArray[0][idx] = -Mathf.Min(0, frameDurationMs - fps); fpsArray[1][idx] = Mathf.Max(0, frameDurationMs - fps); float variance, mean, min, max; CalcStatistics(fpsArray[0], out mean, out variance, out min, out max); // Draw histogram over time differences DebugOverlay.DrawHist(20, 10, 20, 3, fpsArray, Time.frameCount, colors, max); DebugOverlay.SetColor(new Color(1.0f, 0.3f, 0.0f)); DebugOverlay.Write(20, 14, "{0,4:#.###} ({1,4:##.#} +/- {2,4:#.##})", frameDurationMs - fps, mean, Mathf.Sqrt(variance)); DebugOverlay.DrawGraph(45, 10, 40, 3, fpsArray, Time.frameCount, colors, max); /// Graphing frametime var idx2 = Time.frameCount % frameTimeArray.Length; frameTimeArray[idx2] = frameDurationMs; CalcStatistics(frameTimeArray, out mean, out variance, out min, out max); DebugOverlay.DrawHist(20, 15, 20, 3, frameTimeArray, Time.frameCount, Color.red, max); // Draw legend float scale = 18.0f - 3.0f / max * 16.6667f; DebugOverlay.DrawLine(20, scale, 40, scale, Color.black); DebugOverlay.Write(20, 18, "{0,5} ({1} +/- {2})", frameDurationMs, mean, Mathf.Sqrt(variance)); DebugOverlay.DrawGraph(45, 15, 40, 3, frameTimeArray, Time.frameCount, Color.red, max); // Draw some lines to help visualize framerate fluctuations float ratio = (float)DebugOverlay.Height / DebugOverlay.Width * Screen.width / Screen.height; float time = (float)Time.frameCount / 60.0f; for (var i = 0; i < 10; i++) { DebugOverlay.DrawLine(60, 20, 60 + Mathf.Sin(Mathf.PI * 0.2f * i + time) * 8.0f, 20 + Mathf.Cos(Mathf.PI * 0.2f * i + time) * 8.0f * ratio, Color.black); } }
protected override void Update(Entity entity, CharBehaviour charBehavior, DefaultCharBehaviourController.InternalState internalState, DefaultCharBehaviourController.PredictedState predictedState) { if (internalState.initialized == 0) { Activate(internalState.abilityMovement); internalState.initialized = 1; EntityManager.SetComponentData(entity, internalState); } var command = EntityManager.GetComponentObject <UserCommandComponent>(charBehavior.character).command; var healthState = EntityManager.GetComponentObject <HealthState>(charBehavior.character); if (healthState.health <= 0 && predictedState.dead == 0) { if (predictedState.activeAbility != DefaultCharBehaviourController.Ability.None) { var behavior = internalState.GetAbilityBehavior(predictedState.activeAbility); Deactivate(behavior); } Deactivate(internalState.abilityMovement); Activate(internalState.abilityDead); predictedState.dead = 1; EntityManager.SetComponentData(entity, predictedState); } if (predictedState.dead == 1) { return; } // Check for abilities done if (predictedState.activeAbility != DefaultCharBehaviourController.Ability.None) { var activeBehavior = internalState.GetAbilityBehavior(predictedState.activeAbility); var abilityCtrl = EntityManager.GetComponentData <AbilityControl>(activeBehavior); if (abilityCtrl.behaviorState != AbilityControl.State.Active) { // GameDebug.Log("Behavior done:" + activeBehavior); Deactivate(activeBehavior); predictedState.activeAbility = DefaultCharBehaviourController.Ability.None; } } if (IsRequestingActive(ref internalState, DefaultCharBehaviourController.Ability.PrimFire)) { AttempActivate(ref internalState, ref predictedState, DefaultCharBehaviourController.Ability.PrimFire, false); } else if (command.secondaryFire) { AttempActivate(ref internalState, ref predictedState, DefaultCharBehaviourController.Ability.SecFire, false); } else if (command.melee) { var force = predictedState.activeAbility == DefaultCharBehaviourController.Ability.Sprint; AttempActivate(ref internalState, ref predictedState, DefaultCharBehaviourController.Ability.Melee, force); } else if (command.sprint) { AttempActivate(ref internalState, ref predictedState, DefaultCharBehaviourController.Ability.Sprint, false); } else if (command.emote != CharacterEmote.None) { if (command.moveMagnitude == 0) { AttempActivate(ref internalState, ref predictedState, DefaultCharBehaviourController.Ability.Emote, false); } } EntityManager.SetComponentData(entity, predictedState); if (DefaultCharBehaviourController.ShowInfo.IntValue > 0) { int x = 1; int y = 2; DebugOverlay.Write(x, y++, "Ability controller"); DebugOverlay.Write(x, y++, " Active ability:" + predictedState.activeAbility); DebugOverlay.Write(x, y++, " dead:" + predictedState.dead); } }
void DrawStats() { int y = 2; DebugOverlay.Write(2, y++, " tick rate: {0}", Game.serverTickRate.IntValue); DebugOverlay.Write(2, y++, " entities: {0}", m_NetworkServer.NumEntities); DebugOverlay.Write(2, y++, " sim : {0:0.0} / {1:0.0} / {2:0.0} ({3:0.0})", m_ServerSimTime.min, m_ServerSimTime.min, m_ServerSimTime.max, m_ServerSimTime.stdDeviation); int totalSnapshots = 0; foreach (var c in m_NetworkServer.GetConnections()) { totalSnapshots += c.Value.counters.snapshotsOut; } snapsPerFrame[Time.frameCount % snapsPerFrame.Length] = (totalSnapshots - totalSnapshotsLastFrame); totalSnapshotsLastFrame = totalSnapshots; DebugOverlay.DrawHist(2, 10, 60, 5, snapsPerFrame, Time.frameCount % snapsPerFrame.Length, new Color(0.5f, 0.5f, 1.0f)); //for(var i = 0; i < counters.) //DebugOverlay.Write(2, y++, " entities: {0}", counters.numEntities); return; /* * * DebugOverlay.Write(2, y++, "^FF0 lat : {0:0.0} / {1:0.0} / {2:0.0}", m_Latency.min, m_Latency.average, m_Latency.max); * DebugOverlay.Write(2, y++, "^0FF rtt : {0:0.0} / {1:0.0} / {2:0.0}", m_RTT.min, m_RTT.average, m_RTT.max); * DebugOverlay.Write(2, y++, "^0F0 cmdq : {0:0.0} / {1:0.0} / {2:0.0}", m_CMDQ.min, m_CMDQ.average, m_CMDQ.max); * DebugOverlay.Write(2, y++, "^F0F intp : {0:0.0} / {1:0.0} / {2:0.0}", m_Interp.min, m_Interp.average, m_Interp.max); * * var samplesPerSecond = 1.0f / m_StatsDeltaTime.average; * * y++; * DebugOverlay.Write(2, y++, "^00F bps (in): {0:00.0} ({1})", m_BytesIn.graph.average * samplesPerSecond, m_NetworkClient.updateRate); * DebugOverlay.Write(2, y++, "^F00 bps (out): {0:00.0}", m_BytesOut.graph.average * samplesPerSecond); * DebugOverlay.Write(2, y++, " pps (in): {0:00.0}", m_PackagesIn.graph.average * samplesPerSecond); * DebugOverlay.Write(2, y++, " pps (out): {0:00.0}", m_PackagesOut.graph.average * samplesPerSecond); * DebugOverlay.Write(2, y++, " pl% (in): {0:00.0}", m_PackageLossPctIn.average); * DebugOverlay.Write(2, y++, " pl% (out): {0:00.0}", m_PackageLossPctOut.average); * * y++; * DebugOverlay.Write(2, y++, " upd_srate: {0:00.0} ({1})", m_SnapshotsIn.graph.average * samplesPerSecond, m_NetworkClient.updateSendRate); * DebugOverlay.Write(2, y++, " cmd_srate: {0:00.0} ({1})", m_CommandsOut.graph.average * samplesPerSecond, m_NetworkClient.commandSendRate); * DebugOverlay.Write(2, y++, " ev (in): {0:00.0}", m_EventsIn.graph.average * samplesPerSecond); * DebugOverlay.Write(2, y++, " ev (out): {0:00.0}", m_EventsOut.graph.average * samplesPerSecond); * * var startIndex = m_BytesIn.graph.GetData().HeadIndex; * var graphY = 5; * * DebugOverlay.DrawGraph(38, graphY, 60, 5, m_Latency.GetData().GetArray(), startIndex, Color.yellow, 100); * DebugOverlay.DrawGraph(38, graphY, 60, 5, m_RTT.GetData().GetArray(), startIndex, Color.cyan, 100); * DebugOverlay.DrawGraph(38, graphY, 60, 5, m_CMDQ.GetData().GetArray(), startIndex, Color.green, 10); * DebugOverlay.DrawGraph(38, graphY, 60, 5, m_Interp.GetData().GetArray(), startIndex, Color.magenta, 100); * DebugOverlay.DrawHist(38, graphY, 60, 5, m_HardCatchup.GetArray(), startIndex, Color.red, 100); * * m_2GraphData[0] = m_BytesIn.graph.GetData().GetArray(); * m_2GraphData[1] = m_BytesOut.graph.GetData().GetArray(); * * graphY += 7; * DebugOverlay.DrawGraph(38, graphY, 60, 5, m_2GraphData, startIndex, m_BytesGraphColors); * * graphY += 6; * DebugOverlay.DrawHist(38, graphY++, 60, 1, m_SnapshotsIn.graph.GetData().GetArray(), startIndex, Color.blue, 5.0f); * DebugOverlay.DrawHist(38, graphY++, 60, 1, m_CommandsOut.graph.GetData().GetArray(), startIndex, Color.red, 5.0f); * DebugOverlay.DrawHist(38, graphY++, 60, 1, m_EventsIn.graph.GetData().GetArray(), startIndex, Color.yellow, 5.0f); * DebugOverlay.DrawHist(38, graphY++, 60, 1, m_EventsOut.graph.GetData().GetArray(), startIndex, Color.green, 5.0f); */ }
public void Update() { if (focus != Application.isFocused) { focus = Application.isFocused; if (soundMute.IntValue == -1) { m_MasterVolume.MoveTo(focus ? 1.0f : 0.0f, 0.5f); } } var masterVolume = m_MasterVolume.GetValue(); if (soundMute.IntValue == 0) { masterVolume = 0.0f; DebugOverlay.Write(Color.red, DebugOverlay.Width - 10, 2, "{0}", "AUDIO MUTED"); } else if (soundMute.IntValue == 1) { masterVolume = 1.0f; DebugOverlay.Write(Color.green, DebugOverlay.Width - 10, 2, "{0}", "AUDIO PLAYING"); } m_AudioMixer.SetFloat("MasterVolume", DecibelFromAmplitude(Mathf.Clamp(soundMasterVol.FloatValue, 0.0f, 1.0f) * masterVolume)); m_AudioMixer.SetFloat("MusicVolume", DecibelFromAmplitude(Mathf.Clamp(soundMusicVol.FloatValue, 0.0f, 1.0f))); m_AudioMixer.SetFloat("SFXVolume", DecibelFromAmplitude(Mathf.Clamp(soundSFXVol.FloatValue, 0.0f, 1.0f))); m_AudioMixer.SetFloat("MenuVolume", DecibelFromAmplitude(Mathf.Clamp(soundMenuVol.FloatValue, 0.0f, 1.0f))); // Update running sounds int count = 0; foreach (var e in m_Emitters) { if (!e.playing) { continue; } if (e.source == null) { // Could happen if parent was killed. Not good, but fixable: GameDebug.LogWarning("Soundemitter had its audiosource destroyed. Making a new."); e.source = MakeAudioSource(); e.repeatCount = 0; } if (e.fadeToKill.IsMoving()) { e.source.volume = AmplitudeFromDecibel(e.soundDef.volume) * e.fadeToKill.GetValue(); } else if (e.fadeToKill.GetValue() == 0.0f) { // kill no matter what e.Kill(); } if (e.source.isPlaying) { count++; continue; } if (e.repeatCount > 1) { e.repeatCount--; StartEmitter(e); continue; } // Reset for reuse e.playing = false; e.source.transform.parent = m_SourceHolder.transform; e.source.enabled = true; e.source.gameObject.SetActive(true); e.source.transform.position = Vector3.zero; e.fadeToKill.SetValue(1.0f); } if (soundDebug.IntValue > 0) { DebugOverlay.Write(30, 1, "Mixer: {0} {1}", m_AudioMixer.GetInstanceID(), Game.game.audioMixer.GetInstanceID()); int ii = 4; foreach (var o in GameObject.FindObjectsOfType <AudioMixerGroup>()) { DebugOverlay.Write(30, ii++, "group: {0} {1}", o.name, o.GetInstanceID()); } DebugOverlay.Write(1, 1, "Num audios {0}", count); for (int i = 0, c = m_Emitters.Length; i < c; ++i) { var e = m_Emitters[i]; DebugOverlay.Write(1, 3 + i, "Emitter {0:##} {1} {2} {3}", i, e.playing ? e.soundDef.name : "<n/a>", e.source.gameObject.activeInHierarchy ? "act":"nact", e.playing ? "Mixer: " + e.source.outputAudioMixerGroup.audioMixer.GetInstanceID() : ""); } if (m_CurrentListener == null) { DebugOverlay.Write(DebugOverlay.Width / 2 - 5, DebugOverlay.Height, "No AudioListener?"); return; } for (int i = 0, c = m_Emitters.Length; i < c; ++i) { var e = m_Emitters[i]; if (!e.playing) { continue; } var s = e.source.spatialBlend; Vector3 locpos = m_CurrentListener.transform.InverseTransformPoint(e.source.transform.position); float x = Mathf.Lerp(e.source.panStereo * 10.0f, Mathf.Clamp(locpos.x, -10, 10), s);; float z = Mathf.Lerp(-10.0f, Mathf.Clamp(locpos.z, -10, 10), s); DebugOverlay.Write(Color.Lerp(Color.green, Color.blue, s), DebugOverlay.Width / 2 + x, DebugOverlay.Height / 2 - z, "{0} ({1:##.#})", e.soundDef.name, locpos.magnitude); } } }
public void Update() { if (focus != Application.isFocused) { focus = Application.isFocused; if (soundMute.IntValue == -1) { m_MasterVolume.MoveTo(focus ? 1.0f : 0.0f, 0.5f); } } var masterVolume = m_MasterVolume.GetValue(); if (soundMute.IntValue == 0) { masterVolume = 0.0f; DebugOverlay.Write(Color.red, DebugOverlay.Width - 10, 2, "{0}", "AUDIO MUTED"); } else if (soundMute.IntValue == 1) { masterVolume = 1.0f; DebugOverlay.Write(Color.green, DebugOverlay.Width - 10, 2, "{0}", "AUDIO PLAYING"); } //UnityEngine.Debug.Log("Master Bus currently set to " + MasterBus.ToString()); //Time to apply all the FMOD stuff here MasterBus.setVolume(Mathf.Clamp(soundMasterVol.FloatValue, 0.0f, 1.0f) * masterVolume); MusicBus.setVolume(Mathf.Clamp(soundMusicVol.FloatValue, 0.0f, 1.0f)); SFXBus.setVolume(Mathf.Clamp(soundSFXVol.FloatValue, 0.0f, 1.0f)); //MasterBus.getVolume(out float masterBusPrintVolume); UnityEngine.Debug.Log("Master Bus Volume is: " + masterBusPrintVolume); //UnityEngine.Debug.Log("soundMasterVol variable is: " + soundMasterVol.FloatValue); //UnityEngine.Debug.Log("Interpolator value is: " + m_MasterVolume.GetValue()); //UnityEngine.Debug.Log("FMOD bus volumes applied"); //m_AudioMixer.SetFloat("MasterVolume", DecibelFromAmplitude(Mathf.Clamp(soundMasterVol.FloatValue, 0.0f, 1.0f) * masterVolume)); //m_AudioMixer.SetFloat("MusicVolume", DecibelFromAmplitude(Mathf.Clamp(soundMusicVol.FloatValue, 0.0f, 1.0f))); //m_AudioMixer.SetFloat("SFXVolume", DecibelFromAmplitude(Mathf.Clamp(soundSFXVol.FloatValue, 0.0f, 1.0f))); //m_AudioMixer.SetFloat("MenuVolume", DecibelFromAmplitude(Mathf.Clamp(soundMenuVol.FloatValue, 0.0f, 1.0f))); // Update running sounds //Logan: Collapsed into that little box, because I couldn't get VS to do it for me //int count = 0; //foreach (var e in m_Emitters) //{ // if (!e.playing) // continue; // if (e.source == null) // { // // Could happen if parent was killed. Not good, but fixable: // GameDebug.LogWarning("Soundemitter had its audiosource destroyed. Making a new."); // e.source = MakeAudioSource(); // e.repeatCount = 0; // } // if (e.fadeToKill.IsMoving()) // { // e.source.volume = AmplitudeFromDecibel(e.soundDef.volume) * e.fadeToKill.GetValue(); // } // else if (e.fadeToKill.GetValue() == 0.0f) // { // // kill no matter what // e.Kill(); // } // if (e.source.isPlaying) // { // count++; // continue; // } // if (e.repeatCount > 1) // { // e.repeatCount--; // StartEmitter(e); // continue; // } // // Reset for reuse // e.playing = false; // e.source.transform.parent = m_SourceHolder.transform; // e.source.enabled = true; // e.source.gameObject.SetActive(true); // e.source.transform.position = Vector3.zero; // e.fadeToKill.SetValue(1.0f); //} //if (soundDebug.IntValue > 0) //{ // DebugOverlay.Write(30, 1, "Mixer: {0} {1}", m_AudioMixer.GetInstanceID(), Game.game.audioMixer.GetInstanceID()); // int ii = 4; // foreach (var o in GameObject.FindObjectsOfType<AudioMixerGroup>()) // { // DebugOverlay.Write(30, ii++, "group: {0} {1}", o.name, o.GetInstanceID()); // } // DebugOverlay.Write(1, 1, "Num audios {0}", count); // for (int i = 0, c = m_Emitters.Length; i < c; ++i) // { // var e = m_Emitters[i]; // DebugOverlay.Write(1, 3 + i, "Emitter {0:##} {1} {2} {3}", i, e.playing ? e.soundDef.name : "<n/a>", e.source.gameObject.activeInHierarchy ? "act" : "nact", e.playing ? "Mixer: " + e.source.outputAudioMixerGroup.audioMixer.GetInstanceID() : ""); // } // if (m_CurrentListener == null) // { // DebugOverlay.Write(DebugOverlay.Width / 2 - 5, DebugOverlay.Height, "No AudioListener?"); // return; // } // for (int i = 0, c = m_Emitters.Length; i < c; ++i) // { // var e = m_Emitters[i]; // if (!e.playing) // continue; // var s = e.source.spatialBlend; // Vector3 locpos = m_CurrentListener.transform.InverseTransformPoint(e.source.transform.position); // float x = Mathf.Lerp(e.source.panStereo * 10.0f, Mathf.Clamp(locpos.x, -10, 10), s); ; // float z = Mathf.Lerp(-10.0f, Mathf.Clamp(locpos.z, -10, 10), s); // DebugOverlay.Write(Color.Lerp(Color.green, Color.blue, s), DebugOverlay.Width / 2 + x, DebugOverlay.Height / 2 - z, "{0} ({1:##.#})", e.soundDef.name, locpos.magnitude); // } //} }
protected override void Update(Entity entity, AbilityCollection.InternalState internalState) { var abilityEntries = EntityManager.GetBuffer <AbilityCollection.AbilityEntry>(entity); // Check for abilities done for (int i = 0; i < abilityEntries.Length; i++) { var ability = abilityEntries[i].ability; var abilityCtrl = EntityManager.GetComponentData <AbilityControl>(ability); if (abilityCtrl.active == 1 && abilityCtrl.behaviorState != AbilityControl.State.Active) { // GameDebug.Log("Behavior done:" + ability); Deactivate(ability); } } // Get active abilties uint activeAbilityFlags = 0; for (int i = 0; i < abilityEntries.Length; i++) { var ability = abilityEntries[i].ability; var abilityCtrl = EntityManager.GetComponentData <AbilityControl>(ability); if (abilityCtrl.active == 1) { activeAbilityFlags |= 1U << i; } } // Check for ability activate for (int i = 0; i < abilityEntries.Length; i++) { var abilityEntry = abilityEntries[i]; var abilityCtrl = EntityManager.GetComponentData <AbilityControl>(abilityEntry.ability); if (abilityCtrl.active == 1) { continue; } if (abilityCtrl.behaviorState != AbilityControl.State.RequestActive) { continue; } // if(DefaultCharBehaviourController.ShowInfo.IntValue > 0) // GameDebug.Log("AttempActivate:" + ability); var canNotRunWith = activeAbilityFlags & ~abilityEntries[i].canRunWith; if (activeAbilityFlags == 0 || canNotRunWith == 0) { Activate(abilityEntry.ability); continue; } var canActivate = true; for (int j = 0; j < abilityEntries.Length; j++) { var flag = 1U << j; var blocking = (canNotRunWith & flag) > 0; if (blocking) { var canInterrupt = (abilityEntry.canInterrupt & flag) > 0; if (canInterrupt) { Deactivate(abilityEntries[j].ability); } else { RequestDeactivate(abilityEntries[j].ability); canActivate = false; } } } if (canActivate) { Activate(abilityEntry.ability); } } if (AbilityCollection.ShowInfo.IntValue > 0) { int x = 1; int y = 2; DebugOverlay.Write(x, y++, "Ability controller"); for (int i = 0; i < abilityEntries.Length; i++) { var ability = abilityEntries[i].ability; var abilityCtrl = EntityManager.GetComponentData <AbilityControl>(ability); DebugOverlay.Write(x, y++, " " + ability); DebugOverlay.Write(x, y++, " active:" + abilityCtrl.active); DebugOverlay.Write(x, y++, " request deactivate:" + abilityCtrl.requestDeactivate); DebugOverlay.Write(x, y++, " state:" + abilityCtrl.behaviorState); } // DebugOverlay.Write(x, y++, " Active ability:" + predictedState.activeAbility); // DebugOverlay.Write(x, y++, " dead:" + predictedState.dead); } }