public override void Draw() { try { if (SuppressWc || DedicatedServer || _lastDrawTick == Tick || _paused) { return; } if (DebugLos) { LosDebuging(); } _lastDrawTick = Tick; DsUtil.Start("draw"); CameraMatrix = Session.Camera.WorldMatrix; CameraPos = CameraMatrix.Translation; CameraFrustrum.Matrix = (Camera.ViewMatrix * Camera.ProjectionMatrix); var newFov = Camera.FovWithZoom; if (!MyUtils.IsEqual(newFov, CurrentFovWithZoom)) { FovChanged(); } CurrentFovWithZoom = newFov; AspectRatio = Camera.ViewportSize.X / Camera.ViewportSize.Y; AspectRatioInv = Camera.ViewportSize.Y / Camera.ViewportSize.X; ScaleFov = Math.Tan(CurrentFovWithZoom * 0.5); if (!Session.Config.MinimalHud && InGridAiBlock) { if (HudUi.TexturesToAdd > 0 || HudUi.KeepBackground) { HudUi.DrawTextures(); } if ((UiInput.PlayerCamera || UiInput.FirstPersonView || UiInput.CameraBlockView) && !InMenu && !MyAPIGateway.Gui.IsCursorVisible && PlayerDummyTargets.ContainsKey(PlayerId)) { TargetUi.DrawTargetUi(); } if (HudUi.AgingTextures) { HudUi.DrawText(); } } Av.Run(); DrawDisabledGuns(); DsUtil.Complete("draw", true); } catch (Exception ex) { Log.Line($"Exception in SessionDraw: {ex}"); } }
public override void Simulate() { try { if (SuppressWc) { return; } if (!DedicatedServer) { EntityControlUpdate(); CameraMatrix = Session.Camera.WorldMatrix; CameraPos = CameraMatrix.Translation; PlayerPos = Session.Player?.Character?.WorldAABB.Center ?? Vector3D.Zero; } if (GameLoaded) { DsUtil.Start("ai"); AiLoop(); DsUtil.Complete("ai", true); DsUtil.Start("charge"); if (ChargingWeapons.Count > 0) { UpdateChargeWeapons(); } DsUtil.Complete("charge", true); DsUtil.Start("acquire"); if (AcquireTargets.Count > 0) { CheckAcquire(); } DsUtil.Complete("acquire", true); DsUtil.Start("shoot"); if (ShootingWeapons.Count > 0) { ShootWeapons(); } DsUtil.Complete("shoot", true); } if (!DedicatedServer && !InMenu) { UpdateLocalAiAndCockpit(); if ((UiInput.PlayerCamera && ActiveCockPit != null || ActiveControlBlock is MyRemoteControl && !UiInput.PlayerCamera || UiInput.CameraBlockView) && PlayerDummyTargets.ContainsKey(PlayerId)) { TargetSelection(); } } DsUtil.Start("ps"); Projectiles.SpawnAndMove(); DsUtil.Complete("ps", true); DsUtil.Start("pi"); Projectiles.Intersect(); DsUtil.Complete("pi", true); DsUtil.Start("pd"); Projectiles.Damage(); DsUtil.Complete("pd", true); DsUtil.Start("pa"); Projectiles.AvUpdate(); DsUtil.Complete("pa", true); DsUtil.Start("av"); if (!DedicatedServer) { Av.End(); } DsUtil.Complete("av", true); if (MpActive) { DsUtil.Start("network1"); if (PacketsToClient.Count > 0 || PrunedPacketsToClient.Count > 0) { ProccessServerPacketsForClients(); } if (PacketsToServer.Count > 0) { ProccessClientPacketsForServer(); } if (EwarNetDataDirty) { SendEwaredBlocks(); } DsUtil.Complete("network1", true); } } catch (Exception ex) { Log.Line($"Exception in SessionSim: {ex}"); } }