Пример #1
0
        internal void BeforeDamageHandler(object o, ref MyDamageInformation info)
        {
            var slim = o as IMySlimBlock;

            if (slim != null)
            {
                var cube = slim.FatBlock as MyCubeBlock;
                var grid = (MyCubeGrid)slim.CubeGrid;

                if (info.IsDeformation && info.AttackerId > 0 && DeformProtection.Contains(grid))
                {
                    Log.Line($"BeforeDamageHandler1");
                    info.Amount = 0f;
                    return;
                }

                CoreComponent comp;
                if (cube != null && ArmorCubes.TryGetValue(cube, out comp))
                {
                    Log.Line($"BeforeDamageHandler2");
                    info.Amount = 0f;
                    if (info.IsDeformation && info.AttackerId > 0)
                    {
                        DeformProtection.Add(cube.CubeGrid);
                        LastDeform = Tick;
                    }
                }
            }
        }
Пример #2
0
        public override void UpdateBeforeSimulation()
        {
            try
            {
                if (SuppressWc)
                {
                    return;
                }

                if (DeformProtection.Count > 0 && Tick - LastDeform > 0)
                {
                    DeformProtection.Clear();
                }

                Timings();

                if (IsClient)
                {
                    if (ClientSideErrorPkt.Count > 0)
                    {
                        ReproccessClientErrorPackets();
                    }

                    if (ClientPacketsToClean.Count > 0)
                    {
                        CleanClientPackets();
                    }
                }

                if (IsServer)
                {
                    if (Tick60)
                    {
                        AcqManager.Observer();
                    }
                    if (Tick600)
                    {
                        AcqManager.ReorderSleep();
                    }
                }

                if (!DedicatedServer && TerminalMon.Active)
                {
                    TerminalMon.Monitor();
                }

                MyCubeBlock cube;
                if (Tick60 && UiInput.ControlKeyPressed && UiInput.CtrlPressed && GetAimedAtBlock(out cube) && cube.BlockDefinition != null && WeaponCoreBlockDefs.ContainsKey(cube.BlockDefinition.Id.SubtypeName))
                {
                    ProblemRep.GenerateReport(cube);
                }

                if (!IsClient && !InventoryUpdate && WeaponToPullAmmo.Count > 0 && ITask.IsComplete)
                {
                    StartAmmoTask();
                }

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

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

                if (Tick20 && !DelayedAiClean.IsEmpty)
                {
                    DelayedAiCleanup();
                }

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

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

                if (Tick180)
                {
                    ProfilePerformance();
                }

                FutureEvents.Tick(Tick);

                if (HomingWeapons.Count > 0)
                {
                    UpdateHomingWeapons();
                }


                if (MpActive)
                {
                    if (PacketsToClient.Count > 0 || PrunedPacketsToClient.Count > 0)
                    {
                        ProccessServerPacketsForClients();
                    }
                    if (PacketsToServer.Count > 0)
                    {
                        ProccessClientPacketsForServer();
                    }
                }
            }
            catch (Exception ex) { Log.Line($"Exception in SessionBeforeSim: {ex}"); }
        }