Exemplo n.º 1
0
        private void BeforeInit()
        {
            if (Modulator.CubeGrid.Physics == null)
            {
                return;
            }

            _isServer    = Session.Instance.IsServer;
            _isDedicated = Session.Instance.DedicatedServer;

            ResetComp();

            Session.Instance.Modulators.Add(this);

            CreateUi();
            ModUi.ComputeDamage(this, ModUi.GetDamage(Modulator));

            Entity.TryGetSubpart("Rotor", out _subpartRotor);
            PowerInit();
            Modulator.RefreshCustomInfo();
            StateChange(true);
            if (!Session.Instance.ModAction)
            {
                Session.Instance.ModAction = true;
                Session.AppendConditionToAction <IMyUpgradeModule>((a) => Session.Instance.ModActions.Contains(a.Id), (a, b) => b.GameLogic.GetAs <Modulators>() != null && Session.Instance.ModActions.Contains(a.Id));
            }
            MainInit     = true;
            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
            _bTime       = _isDedicated ? 10 : 1;
            _bInit       = true;
        }
Exemplo n.º 2
0
        public override void UpdateOnceBeforeFrame()
        {
            base.UpdateOnceBeforeFrame();
            try
            {
                if (Modulator.CubeGrid.Physics == null)
                {
                    return;
                }

                _isServer    = Session.Instance.IsServer;
                _isDedicated = Session.Instance.DedicatedServer;

                ResetComp();

                Session.Instance.Modulators.Add(this);

                CreateUi();
                ModUi.ComputeDamage(this, ModUi.GetDamage(Modulator));

                Entity.TryGetSubpart("Rotor", out _subpartRotor);
                PowerInit();
                Modulator.RefreshCustomInfo();
                StateChange(true);
                if (!Session.Instance.ModAction)
                {
                    Session.Instance.ModAction = true;
                    Session.AppendConditionToAction <IMyUpgradeModule>((a) => Session.Instance.ModActions.Contains(a.Id), (a, b) => b.GameLogic.GetAs <Modulators>() != null && Session.Instance.ModActions.Contains(a.Id));
                }
                MainInit = true;
            }
            catch (Exception ex) { Log.Line($"Exception in UpdateOnceBeforeFrame: {ex}"); }
        }