コード例 #1
0
        public override void BeforeStart()
        {
            base.BeforeStart();

            if (!Sync.IsServer)
            {
                return;
            }

            var meteorEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "MeteorWave"));

            if (meteorEvent == null)
            {
                meteorEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "MeteorWaveCataclysm"));
            }
            if (meteorEvent == null)
            {
                meteorEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "MeteorWaveCataclysmUnreal"));
            }

            if (meteorEvent == null && MySession.Static.EnvironmentHostility != MyEnvironmentHostilityEnum.SAFE && MyFakes.ENABLE_METEOR_SHOWERS)
            {
                var globalEvent = MyGlobalEventFactory.CreateEvent(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "MeteorWave"));
                globalEvent.SetActivationTime(MyMeteorShower.CalculateShowerTime(MySession.Static.EnvironmentHostility));
                MyGlobalEvents.AddGlobalEvent(globalEvent);
            }
            else if (meteorEvent != null)
            {
                if (MySession.Static.EnvironmentHostility == MyEnvironmentHostilityEnum.SAFE || !MyFakes.ENABLE_METEOR_SHOWERS)
                {
                    meteorEvent.Enabled = false;
                }
                else
                {
                    meteorEvent.Enabled = true;
                    if (MySession.Static.PreviousEnvironmentHostility.HasValue)
                    {
                        if (MySession.Static.EnvironmentHostility != MySession.Static.PreviousEnvironmentHostility.Value)
                        {
                            meteorEvent.SetActivationTime(
                                MyMeteorShower.CalculateShowerTime(
                                    MySession.Static.EnvironmentHostility,
                                    MySession.Static.PreviousEnvironmentHostility.Value,
                                    meteorEvent.ActivationTime));
                            MySession.Static.PreviousEnvironmentHostility = null;
                        }
                    }
                }
            }
        }
コード例 #2
0
        public override void BeforeStart()
        {
            base.BeforeStart();

            if (!Sync.IsServer)
            {
                return;
            }

            var  april2014Event = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventDefinition), "April2014"));
            bool eventEnabled   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) == new DateTime(2014, 4, 1) || MyFakes.APRIL2014_ENABLED;

            if (april2014Event == null && eventEnabled)
            {
                var globalEvent = MyGlobalEventFactory.CreateEvent <MyGlobalEventBase>(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventDefinition), "April2014"));
                MyGlobalEvents.AddGlobalEvent(globalEvent);
            }
            else if (april2014Event != null)
            {
                april2014Event.Enabled &= eventEnabled;
            }
        }