コード例 #1
0
        public override void Draw()
        {
            try
            {
                if (DedicatedServer || _lastDrawTick == Tick || _paused)
                {
                    return;
                }
                _lastDrawTick = Tick;
                DsUtil.Start("draw");

                CameraMatrix          = Session.Camera.WorldMatrix;
                CameraPos             = CameraMatrix.Translation;
                CameraFrustrum.Matrix = (Camera.ViewMatrix * Camera.ProjectionMatrix);

                if (HudUi.TexturesToAdd > 0)
                {
                    HudUi.DrawTextures();
                }

                if ((UiInput.PlayerCamera || UiInput.FirstPersonView || InGridAiBlock) && !InMenu && !Session.Config.MinimalHud && !MyAPIGateway.Gui.IsCursorVisible)
                {
                    if (WheelUi.WheelActive)
                    {
                        WheelUi.DrawWheel();
                    }
                    TargetUi.DrawTargetUi();
                }

                Av.Run();
                DsUtil.Complete("draw", true);
            }
            catch (Exception ex) { Log.Line($"Exception in SessionDraw: {ex}"); }
        }
コード例 #2
0
        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}"); }
        }
コード例 #3
0
        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();
                    }
                }

                DsUtil.Start("projectiles1");
                Projectiles.Stage1();
                DsUtil.Complete("projectiles1", true);
            }
            catch (Exception ex) { Log.Line($"Exception in SessionSim: {ex}"); }
        }
コード例 #4
0
ファイル: SessionRun.cs プロジェクト: keleios/WeaponCore
        public override void Draw()
        {
            try
            {
                if (SupressLoad || DedicatedServer || _lastDrawTick == Tick || _paused)
                {
                    return;
                }
                _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;
                ScaleFov           = Math.Tan(CurrentFovWithZoom * 0.5);

                if (HudUi.TexturesToAdd > 0)
                {
                    HudUi.DrawTextures();
                }

                if ((UiInput.PlayerCamera || UiInput.FirstPersonView || InGridAiBlock) && !InMenu && !Session.Config.MinimalHud && !MyAPIGateway.Gui.IsCursorVisible)
                {
                    TargetUi.DrawTargetUi();
                }
                Av.Run();
                DsUtil.Complete("draw", true);
            }
            catch (Exception ex) { Log.Line($"Exception in SessionDraw: {ex}"); }
        }
コード例 #5
0
ファイル: SessionJobs.cs プロジェクト: Coreman230/WeaponCore
        private void ProcessDbsCallBack()
        {
            try
            {
                DsUtil.Start("db");
                for (int d = 0; d < DbsToUpdate.Count; d++)
                {
                    var db = DbsToUpdate[d];

                    db.TargetingInfo.Clean();

                    if (db.MyPlanetTmp != null)
                    {
                        db.MyPlanetInfo();
                    }

                    foreach (var sub in db.PrevSubGrids)
                    {
                        db.SubGrids.Add(sub);
                    }
                    if (db.SubGridsChanged)
                    {
                        db.SubGridChanges();
                    }

                    for (int i = 0; i < db.SortedTargets.Count; i++)
                    {
                        var tInfo = db.SortedTargets[i];
                        tInfo.Target   = null;
                        tInfo.MyAi     = null;
                        tInfo.MyGrid   = null;
                        tInfo.TargetAi = null;
                        TargetInfoPool.Return(db.SortedTargets[i]);
                    }
                    db.SortedTargets.Clear();
                    db.Targets.Clear();

                    var newEntCnt = db.NewEntities.Count;
                    db.SortedTargets.Capacity = newEntCnt;
                    for (int i = 0; i < newEntCnt; i++)
                    {
                        var detectInfo = db.NewEntities[i];
                        var ent        = detectInfo.Parent;
                        if (ent.Physics == null)
                        {
                            continue;
                        }

                        var    grid     = ent as MyCubeGrid;
                        GridAi targetAi = null;

                        if (grid != null)
                        {
                            GridTargetingAIs.TryGetValue(grid, out targetAi);
                        }

                        var targetInfo = TargetInfoPool.Get();
                        targetInfo.Init(ref detectInfo, db.MyGrid, db, targetAi);

                        db.SortedTargets.Add(targetInfo);
                        db.Targets[ent] = targetInfo;

                        if (targetInfo.Target == db.Focus.Target[0] || targetInfo.Target == db.Focus.Target[1] || targetInfo.DistSqr < db.MaxTargetingRangeSqr && targetInfo.DistSqr < db.TargetingInfo.ThreatRangeSqr && targetInfo.OffenseRating > 0 && (targetInfo.EntInfo.Relationship != MyRelationsBetweenPlayerAndBlock.Friends || targetInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.FactionShare))
                        {
                            db.TargetingInfo.TargetInRange  = true;
                            db.TargetingInfo.ThreatRangeSqr = targetInfo.DistSqr;
                        }
                    }
                    db.NewEntities.Clear();
                    db.SortedTargets.Sort(TargetCompare);
                    db.TargetAis.Clear();
                    db.TargetAis.AddRange(db.TargetAisTmp);
                    db.TargetAisTmp.Clear();

                    db.Obstructions.Clear();
                    db.Obstructions.AddRange(db.ObstructionsTmp);
                    db.ObstructionsTmp.Clear();

                    if (db.PlanetSurfaceInRange)
                    {
                        db.StaticsInRangeTmp.Add(db.MyPlanet);
                    }
                    db.StaticsInRange.Clear();
                    db.StaticsInRange.AddRange(db.StaticsInRangeTmp);
                    db.StaticsInRangeTmp.Clear();
                    db.StaticEntitiesInRange = db.StaticsInRange.Count > 0;
                    db.MyStaticInfo();

                    db.DbReady        = db.SortedTargets.Count > 0 || db.TargetAis.Count > 0 || Tick - db.LiveProjectileTick < 3600 || db.LiveProjectile.Count > 0 || db.ControllingPlayers.Keys.Count > 0 || db.FirstRun;
                    db.MyShield       = db.MyShieldTmp;
                    db.NaturalGravity = db.FakeShipController.GetNaturalGravity();
                    db.ShieldNear     = db.ShieldNearTmp;
                    db.BlockCount     = db.MyGrid.BlocksCount;
                    db.Concealed      = ((uint)db.MyGrid.Flags & 4) > 0;

                    if (db.ScanBlockGroups || db.WeaponTerminalReleased())
                    {
                        db.ReScanBlockGroups();
                    }

                    db.FirstRun = false;
                }
                DbsToUpdate.Clear();
                DsUtil.Complete("db", true);
                DbCallBackComplete = true;
            }
            catch (Exception ex) { Log.Line($"Exception in ProcessDbsCallBack: {ex}"); }
        }
コード例 #6
0
        private void ProcessDbsCallBack()
        {
            try
            {
                DsUtil.Start("db");
                for (int d = 0; d < DbsToUpdate.Count; d++)
                {
                    var db = DbsToUpdate[d];
                    using (db.Ai.DbLock.AcquireExclusiveUsing())
                    {
                        var ai = db.Ai;
                        if (ai.MyGrid.MarkedForClose || ai.MarkedForClose || db.Version != ai.Version)
                        {
                            ai.ScanInProgress = false;
                            continue;
                        }

                        if (ai.MyPlanetTmp != null)
                        {
                            ai.MyPlanetInfo();
                        }

                        foreach (var sub in ai.PrevSubGrids)
                        {
                            ai.SubGrids.Add((MyCubeGrid)sub);
                        }
                        if (ai.SubGridsChanged)
                        {
                            ai.SubGridChanges(false, true);
                        }

                        ai.TargetingInfo.Clean(ai);
                        ai.CleanSortedTargets();
                        ai.Targets.Clear();

                        var newEntCnt = ai.NewEntities.Count;
                        ai.SortedTargets.Capacity = newEntCnt;
                        for (int i = 0; i < newEntCnt; i++)
                        {
                            var detectInfo = ai.NewEntities[i];
                            var ent        = detectInfo.Parent;
                            if (ent.Physics == null)
                            {
                                continue;
                            }

                            var    grid     = ent as MyCubeGrid;
                            GridAi targetAi = null;

                            if (grid != null)
                            {
                                GridTargetingAIs.TryGetValue(grid, out targetAi);
                            }

                            var targetInfo = TargetInfoPool.Get();
                            targetInfo.Init(ref detectInfo, ai.MyGrid, ai, targetAi);

                            ai.SortedTargets.Add(targetInfo);
                            ai.Targets[ent] = targetInfo;

                            var checkFocus = ai.Construct.Data.Repo.FocusData.HasFocus && targetInfo.Target?.EntityId == ai.Construct.Data.Repo.FocusData.Target[0] || targetInfo.Target?.EntityId == ai.Construct.Data.Repo.FocusData.Target[1];

                            if (targetInfo.Drone)
                            {
                                ai.TargetingInfo.DroneAdd(ai, targetInfo);
                            }

                            if (ai.RamProtection && targetInfo.DistSqr < 136900 && targetInfo.IsGrid)
                            {
                                ai.TargetingInfo.RamProximity = true;
                            }

                            if (targetInfo.DistSqr < ai.MaxTargetingRangeSqr && (checkFocus || targetInfo.OffenseRating > 0))
                            {
                                if (checkFocus || targetInfo.DistSqr < ai.TargetingInfo.ThreatRangeSqr && targetInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.Enemies)
                                {
                                    ai.TargetingInfo.ThreatInRange  = true;
                                    ai.TargetingInfo.ThreatRangeSqr = targetInfo.DistSqr;
                                }

                                if (checkFocus || targetInfo.DistSqr < ai.TargetingInfo.OtherRangeSqr && targetInfo.EntInfo.Relationship != MyRelationsBetweenPlayerAndBlock.Enemies)
                                {
                                    ai.TargetingInfo.OtherInRange  = true;
                                    ai.TargetingInfo.OtherRangeSqr = targetInfo.DistSqr;
                                }

                                if (targetInfo.Drone && targetInfo.DistSqr < ai.TargetingInfo.DroneRangeSqr)
                                {
                                    ai.TargetingInfo.DroneInRange  = true;
                                    ai.TargetingInfo.DroneRangeSqr = targetInfo.DistSqr;
                                }
                            }
                        }

                        ai.NewEntities.Clear();
                        ai.SortedTargets.Sort(TargetCompare);
                        ai.TargetAis.Clear();
                        ai.TargetAis.AddRange(ai.TargetAisTmp);
                        ai.TargetAisTmp.Clear();

                        ai.Obstructions.Clear();
                        ai.Obstructions.AddRange(ai.ObstructionsTmp);
                        ai.ObstructionsTmp.Clear();

                        ai.MyShield           = null;
                        ai.ShieldNear         = false;
                        ai.FriendlyShieldNear = false;
                        if (ai.NearByShieldsTmp.Count > 0)
                        {
                            ai.NearByShield();
                        }

                        ai.StaticsInRange.Clear();
                        ai.StaticsInRange.AddRange(ai.StaticsInRangeTmp);
                        ai.StaticsInRangeTmp.Clear();
                        ai.StaticEntitiesInRange = ai.StaticsInRange.Count > 0;
                        ai.MyStaticInfo();

                        ai.NaturalGravity = ai.FakeShipController.GetNaturalGravity();
                        ai.BlockCount     = ai.MyGrid.BlocksCount;
                        ai.NearByEntities = ai.NearByEntitiesTmp;

                        if (!ai.TargetingInfo.ThreatInRange && ai.LiveProjectile.Count > 0)
                        {
                            ai.TargetingInfo.ThreatInRange  = true;
                            ai.TargetingInfo.ThreatRangeSqr = 0;
                        }

                        ai.TargetingInfo.SomethingInRange = ai.TargetingInfo.ThreatInRange || ai.TargetingInfo.OtherInRange;

                        ai.DbReady = ai.SortedTargets.Count > 0 || ai.TargetAis.Count > 0 || Tick - ai.LiveProjectileTick < 3600 || ai.LiveProjectile.Count > 0 || ai.Construct.RootAi.Data.Repo.ControllingPlayers.Count > 0 || ai.FirstRun;

                        MyCubeBlock activeCube;
                        ai.AiSleep = ai.Construct.RootAi.Data.Repo.ControllingPlayers.Count <= 0 && (!ai.TargetingInfo.ThreatInRange && !ai.TargetingInfo.OtherInRange || !ai.TargetNonThreats && ai.TargetingInfo.OtherInRange) && (ai.Data.Repo.ActiveTerminal <= 0 || MyEntities.TryGetEntityById(ai.Data.Repo.ActiveTerminal, out activeCube) && activeCube != null && !ai.SubGrids.Contains(activeCube.CubeGrid));

                        ai.DbUpdated      = true;
                        ai.FirstRun       = false;
                        ai.ScanInProgress = false;
                    }
                }
                DbsToUpdate.Clear();
                DsUtil.Complete("db", true);
                DbUpdating = false;
            }
            catch (Exception ex) { Log.Line($"Exception in ProcessDbsCallBack: {ex}"); }
        }
コード例 #7
0
        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}"); }
        }
コード例 #8
0
        public override void UpdateBeforeSimulation()
        {
            try
            {
                //
                // Finish work from last frame
                //
                DsUtil.Start("projectiles2");
                Projectiles.Stage2();
                DsUtil.Complete("projectiles2", true);

                DsUtil.Start("damage");
                if (_effectedCubes.Count > 0)
                {
                    ApplyGridEffect();
                }

                if (Tick60)
                {
                    GridEffects();
                }

                if (Hits.Count > 0)
                {
                    ProcessHits();
                }
                DsUtil.Complete("damage", true);

                if (MpActive)
                {
                    DsUtil.Start("network1");
                    if (WeaponsToSync.Count > 0)
                    {
                        Proccessor.Proccess();
                    }
                    if (UiInput.InputChanged && ActiveControlBlock != null)
                    {
                        SendMouseUpdate(ActiveControlBlock);
                    }
                    if (ClientGridResyncRequests.Count > 0)
                    {
                        ProccessGridResyncRequests();
                    }

                    Proccessor.AddPackets();

                    if (PacketsToClient.Count > 0)
                    {
                        ProccessServerPacketsForClients();
                    }
                    if (PacketsToServer.Count > 0)
                    {
                        ProccessClientPacketsForServer();
                    }
                    if (ClientSideErrorPktList.Count > 0)
                    {
                        ReproccessClientErrorPackets();
                    }
                    DsUtil.Complete("network1", true);
                }

                DsUtil.Start("av");
                if (!DedicatedServer)
                {
                    Av.End();
                }
                DsUtil.Complete("av", true);
                //
                // Finished last frame
                //
                Timings();

                if (!WeaponAmmoRemoveQueue.IsEmpty && CTask.IsComplete)
                {
                    if (CTask.valid && CTask.Exceptions != null)
                    {
                        TaskHasErrors(ref CTask, "CTask");
                    }

                    CTask = MyAPIGateway.Parallel.StartBackground(AmmoToRemove, RemoveAmmo);
                }

                if (!WeaponAmmoPullQueue.IsEmpty && ITask.IsComplete)
                {
                    if (ITask.valid && ITask.Exceptions != null)
                    {
                        TaskHasErrors(ref ITask, "ITask");
                    }

                    ITask = MyAPIGateway.Parallel.StartBackground(AmmoPull, MoveAmmo);
                }

                if (!CompsToStart.IsEmpty)
                {
                    StartComps();
                }

                if (Tick120 && CompsDelayed.Count > 0)
                {
                    DelayedComps();
                }

                if (CompReAdds.Count > 0)
                {
                    ChangeReAdds();
                }

                if (Tick3600 && MpActive)
                {
                    NetReport();
                }

                if (Tick180)
                {
                    ProfilePerformance();
                }

                FutureEvents.Tick(Tick);

                if (!DedicatedServer && ActiveControlBlock != null && !InMenu)
                {
                    WheelUi.UpdatePosition();
                }
            }
            catch (Exception ex) { Log.Line($"Exception in SessionBeforeSim: {ex}"); }
        }
コード例 #9
0
ファイル: SessionRun.cs プロジェクト: Coreman230/WeaponCore
        public override void UpdateBeforeSimulation()
        {
            try
            {
                DsUtil.Start("av");
                if (!DedicatedServer)
                {
                    Av.End();
                }
                DsUtil.Complete("av", true);

                Timings();

                if (!WeaponAmmoRemoveQueue.IsEmpty && CTask.IsComplete)
                {
                    if (CTask.valid && CTask.Exceptions != null)
                    {
                        TaskHasErrors(ref CTask, "CTask");
                    }

                    CTask = MyAPIGateway.Parallel.StartBackground(AmmoToRemove, RemoveAmmo);
                }

                if (!WeaponAmmoPullQueue.IsEmpty && ITask.IsComplete)
                {
                    if (ITask.valid && ITask.Exceptions != null)
                    {
                        TaskHasErrors(ref ITask, "ITask");
                    }

                    ITask = MyAPIGateway.Parallel.StartBackground(AmmoPull, MoveAmmo);
                }

                if (!CompsToStart.IsEmpty)
                {
                    StartComps();
                }

                if (Tick120 && CompsDelayed.Count > 0)
                {
                    DelayedComps();
                }

                if (CompReAdds.Count > 0)
                {
                    ChangeReAdds();
                }

                if (Tick3600 && MpActive)
                {
                    NetReport();
                }

                if (Tick180)
                {
                    ProfilePerformance();
                }

                FutureEvents.Tick(Tick);

                if (!DedicatedServer && UiInput.PlayerCamera && !InMenu)
                {
                    WheelUi.UpdatePosition();
                }
            }
            catch (Exception ex) { Log.Line($"Exception in SessionBeforeSim: {ex}"); }
        }
コード例 #10
0
ファイル: SessionRun.cs プロジェクト: Coreman230/WeaponCore
        public override void UpdateAfterSimulation()
        {
            try
            {
                if (Placer != null)
                {
                    UpdatePlacer();
                }
                if (!DedicatedServer)
                {
                    ProcessAnimations();
                }

                /*
                 * DsUtil.Start("projectiles");
                 * if (!DedicatedServer && false)
                 * {
                 *  if (!PTask.IsComplete)
                 *      PTask.Wait();
                 *
                 *  if (PTask.IsComplete && PTask.valid && PTask.Exceptions != null)
                 *      TaskHasErrors(ref PTask, "PTask");
                 * }
                 * else Projectiles.Update();
                 *
                 * DsUtil.Complete("projectiles", true);
                 */
                if (_effectedCubes.Count > 0)
                {
                    ApplyGridEffect();
                }

                if (Tick60)
                {
                    GridEffects();
                }

                if (GridTask.IsComplete)
                {
                    CheckDirtyGrids();
                }

                DsUtil.Start("damage");
                if (Hits.Count > 0)
                {
                    ProcessHits();
                }
                DsUtil.Complete("damage", true);

                if (IsClient)
                {
                    if (!MTask.IsComplete)
                    {
                        MTask.Wait();
                    }

                    if (MTask.IsComplete && MTask.valid && MTask.Exceptions != null)
                    {
                        TaskHasErrors(ref MTask, "MTask");
                    }
                }

                /*
                 * DsUtil.Start("network");
                 * if (!DedicatedServer)
                 * {
                 *  if (!NTask.IsComplete)
                 *      NTask.Wait();
                 *
                 *  if (NTask.IsComplete && NTask.valid && NTask.Exceptions != null)
                 *      TaskHasErrors(ref NTask, "NTask");
                 * }
                 * else if (WeaponsToSync.Count > 0) Proccessor.Proccess();
                 */

                DsUtil.Start("network2");
                Proccessor.AddPackets();

                if (MpActive && !HandlesInput)
                {
                    if (PacketsToClient.Count > 0)
                    {
                        ProccessServerPacketsForClients();
                    }
                    if (PacketsToServer.Count > 0)
                    {
                        ProccessClientPacketsForServer();
                    }
                }
                DsUtil.Complete("network2", true);
            }
            catch (Exception ex) { Log.Line($"Exception in SessionAfterSim: {ex}"); }
        }
コード例 #11
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}"); }
        }