Ejemplo n.º 1
0
 private void Entities_OnEntityAdd(IMyEntity entity)
 {
     if (entity.Save || entity is IMyCharacter)
     {
         AddRemoveActions.AddTail(() => AddEntity(entity));
     }
 }
Ejemplo n.º 2
0
        /// <param name="unregisterOnClosing">Leave as null if you plan on manually unregistering</param>
        public static void RegisterUpdateHandler(uint frequency, Action toInvoke, IMyEntity unregisterOnClosing = null)
        {
            var assembly = Assembly.GetCallingAssembly();

            ExternalRegistrations?.AddTail(() => {
                ComponentStore.AddUpdateHandler(frequency, toInvoke, assembly);
                if (unregisterOnClosing != null)
                {
                    unregisterOnClosing.OnClosing += (entity) => ComponentStore.RemoveUpdateHandler(frequency, toInvoke);
                }
            });
        }
Ejemplo n.º 3
0
        public void EnqueueAction(Action toQueue)
        {
            if (Globals.WorldClosed)
            {
                Log.DebugLog("Cannot enqueue, world is closed");
                return;
            }

            ActionQueue.AddTail(toQueue);
            VRage.Exceptions.ThrowIf <Exception>(ActionQueue.Count > QueueOverflow, "queue is too long");

            if (ParallelTasks >= AllowedParallel || StaticParallel >= StaticMaxParallel)
            {
                return;
            }

            MyAPIGateway.Utilities.InvokeOnGameThread(() => {
                if (MyAPIGateway.Parallel == null)
                {
                    Log.DebugLog("Parallel == null", Logger.severity.WARNING);
                    return;
                }

                if (Background)
                {
                    MyAPIGateway.Parallel.StartBackground(Run);
                }
                else
                {
                    MyAPIGateway.Parallel.Start(Run);
                }
            });
        }
Ejemplo n.º 4
0
        private static void Log(LogItem item)
        {
            if (item.Level <= Severity.Level.WARNING && item.Assembly.IsDebugDefined())
            {
                Notification.Notify(item.Assembly.GetName().Name + " " + item.Level, 2000, item.Level);
            }

            LogItems.AddTail(item);

            MyAPIGateway.Parallel?.StartBackground(Loop);
        }