コード例 #1
0
ファイル: SessionRun.cs プロジェクト: Coreman230/WeaponCore
        public override void Simulate()
        {
            try
            {
                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 && !WheelUi.WheelActive && !InMenu)
                {
                    UpdateLocalAiAndCockpit();
                    if (UiInput.PlayerCamera && ActiveCockPit != null)
                    {
                        TargetSelection();
                    }
                }

                if (FragmentsNeedingEntities.Count > 0)
                {
                    Projectiles.PrepFragmentEntities();
                }

                DsUtil.Start("projectiles");
                Projectiles.Update();
                DsUtil.Complete("projectiles", true);

                DsUtil.Start("network1");
                if (WeaponsToSync.Count > 0)
                {
                    Proccessor.Proccess();
                }
                DsUtil.Complete("network1", true);

                /*
                 * if (!DedicatedServer)
                 * {
                 *  //PTask = MyAPIGateway.Parallel.StartBackground(Projectiles.Update);
                 *  if (WeaponsToSync.Count > 0) NTask = MyAPIGateway.Parallel.StartBackground(Proccessor.Proccess);
                 * }
                 */
            }
            catch (Exception ex) { Log.Line($"Exception in SessionSim: {ex}"); }
        }