Example #1
0
        public static void Process <T>(OnProcess <T> process, Logger log)
            where T : GameObject
        {
            foreach (T obj in Sims3.Gameplay.Queries.GetGlobalObjects <T>())
            {
                if (process(obj))
                {
                    if (log != null)
                    {
                        log("  Global Altered");
                    }
                }
            }

            foreach (T obj in Sims3.Gameplay.Queries.GetObjects <T>())
            {
                if (process(obj))
                {
                    if (log != null)
                    {
                        log("  Local Altered");
                    }
                }
            }
        }
Example #2
0
        private void Dispatch(TcpClient client, CancellationToken token)
        {
            try
            {
                var bytes = new byte[65536];

                using (var stream = client.GetStream())
                    while (true)
                    {
                        token.ThrowIfCancellationRequested();

                        stream.Read(bytes, 0, bytes.Length);
                        _log.Debug("Message recieved");

                        var response = OnProcess?.Invoke(bytes);

                        if (response != null)
                        {
                            stream.Write(response, 0, response.Length);
                        }

                        _log.Debug("Message sent");
                    }
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
            finally
            {
                client.Close();
            }
        }
Example #3
0
        static Packet()
        {
            Fragment = Platform.CoreFragment?.GetPacketFragment() ?? throw Platform.FragmentException();

            Fragment.Process = args => OnProcess.SafeInvoke(args);
            Fragment.Send    = args => OnSend.SafeInvoke(args);
        }
Example #4
0
        /// <summary>
        /// Process an asset and register it for further reprocessing in the future.
        /// Apply any mod-related changes to the asset based on the existing mod asset meta map.
        /// </summary>
        /// <param name="asset">The asset to process.</param>
        /// <param name="assetNameFull">The "full name" of the asset, preferable the relative asset path.</param>
        /// <returns>The processed asset.</returns>
        public static object Process(object asset, string assetNameFull)
        {
            string assetName = assetNameFull;

            if (string.IsNullOrEmpty(PathContentOrig) && !string.IsNullOrEmpty(ModManager.PathGame))
            {
                PathContentOrig = Path.Combine(ModManager.PathGame, "Content");
            }
            if (!string.IsNullOrEmpty(PathContentOrig) && assetName.StartsWith(PathContentOrig))
            {
                assetName = assetName.Substring(PathContentOrig.Length + 1);
            }

            int loadedIndex = LoadedAssetPaths.IndexOf(assetName);

            if (loadedIndex == -1)
            {
                LoadedAssetPaths.Add(assetName);
                LoadedAssetFullPaths.Add(assetNameFull);
                LoadedAssets.Add(new WeakReference(asset));
            }
            else
            {
                LoadedAssets[loadedIndex] = new WeakReference(asset);
            }

            return(OnProcess?.InvokePassing(asset, assetNameFull) ?? asset);
        }
Example #5
0
        protected override void OnShown(EventArgs e)
        {
            Task.Run(
                () => OnProcess?.Invoke(this, new EventArgs()),
                cancellationTokenSource.Token)
            .ContinueWith((t) =>
            {
                if (t.Exception != null)
                {
                    foreach (var exception in t.Exception.Flatten().InnerExceptions)
                    {
                        Console.Error.WriteLine(exception);
                    }

                    Console.Error.WriteLine("Search existing issues or create a new one here: https://github.com/SteamDatabase/ValveResourceFormat/issues");

                    SetProgress($"An exception occured, view console tab for more information. ({t.Exception.InnerException.Message})");

                    // TODO: Throwing doesn't actually display the exception ui
                    throw t.Exception;
                }

                if (!t.IsCanceled)
                {
                    Invoke((Action)Close);
                }
            });
        }
Example #6
0
        private void Listen(CancellationToken token)
        {
            try
            {
                while (!token.IsCancellationRequested)
                {
                    IPEndPoint endPoint = null;
                    var        request  = _udp.Receive(ref endPoint);
                    _log.Debug("Message recieved");

                    var response = OnProcess?.Invoke(request);

                    if (response != null)
                    {
                        _udp.Send(response, response.Length, endPoint);
                    }

                    _log.Debug("Message sent");
                }
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
            finally
            {
                _udp.Close();
            }
        }
        public async Task ProcessMessage(TestDelayOutboxCommand message, CancellationToken cancellationToken)
        {
            Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}");

            await Task.Delay(message.DelayMsec, cancellationToken);

            OnProcess?.Invoke(this, message);
        }
        public void ProcessTurn()
        {
            OnProcess?.Invoke();
            if (actionAgentList.Count > 0)
            {
                if (actionAgentList[0] == Player)
                {
                    OnPlayerActionRequest?.Invoke();
                    actionAgentList.Remove(Player);
                }
                else
                {
                    int enemyIndex = (int)actionAgentList[0];

                    BattleFactors monsterBF = MonsterBattleFactors[enemyIndex];
                    BattleFactors playerBF  = Player.BattleFactors;
                    PlayerSkillEffectStatuses.ForEach(x => x.effector.Use(playerBF, null));
                    if (HitCheck(monsterBF, playerBF))
                    {
                        Skill skill = Monsters[enemyIndex].Action();
                        if (skill == null)
                        {
                            Player.AbilityFactors.HP -= Math.Max(monsterBF.physicalAttackPoint - playerBF.physicalDefencePoint, 1);
                        }
                        else
                        {
                            skill.Use(monsterBF, new List <BattleFactors> {
                                playerBF
                            });
                            skill.SkillEffectors.OfType <SustainSkillEffector>().ToList().ForEach(x =>
                            {
                                SkillEffectStatus status = new SkillEffectStatus {
                                    effector = x, remainedRound = x.SustainRound
                                };
                                if (x is TargetSpeedPointSkillEffector || x is TargetStopActionSkillEffector)
                                {
                                    PlayerSkillEffectStatuses.Add(status);
                                }
                                else
                                {
                                    MonstersSkillEffectStatuses[enemyIndex].Add(status);
                                }
                            });
                        }
                    }
                    else
                    {
                        OnMiss?.Invoke(true, enemyIndex);
                    }
                    ProcessTurn();
                }
            }
            else
            {
                EndTurn();
            }
        }
Example #9
0
        public WBIResultsDialogSwizzler(OnTransmit transmitMethod, OnDiscard discardMethod, OnProcess processMethod, OnKeep keepMethod)
        {
            onTransmit = transmitMethod;
            onDiscard  = discardMethod;
            onProcess  = processMethod;
            onKeep     = keepMethod;

            SwizzleResultsDialog();
        }
Example #10
0
        public async Task ProcessMessage(TestOutboxCommand message, CancellationToken cancellationToken)
        {
            //Console.WriteLine($"TestCommandHandler - Processing command at {DateTime.Now}, Args: {message.Args}");

            await Task.Delay(2_000, cancellationToken);

            Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}");

            OnProcess?.Invoke(this, EventArgs.Empty);
        }
 private void ProcessInvoke(TransmissionPayload payload)
 {
     try
     {
         OnProcess?.Invoke(this, payload);
     }
     catch (Exception ex)
     {
         Collector?.LogException("ManualChannelSender/ProcessInvoke", ex);
     }
 }
Example #12
0
 public void Unsubscribe(FileCheckerProcess handler)
 {
     try
     {
         if (OnProcess.GetInvocationList().Contains(handler))
         {
             OnProcess -= handler;
         }
     }
     catch (NullReferenceException) { }
 }
 public void Listen()
 {
     while (_listener.IsListening)
     {
         var result = _listener.BeginGetContext(ar =>
         {
             var listener = ar.AsyncState as HttpListener;
             var context  = listener?.EndGetContext(ar);
             OnProcess?.Invoke(context);
         }, _listener);
         result.AsyncWaitHandle.WaitOne();
     }
 }
Example #14
0
 protected override void OnShown(EventArgs e)
 {
     Task.Run(
         () => OnProcess?.Invoke(this, new EventArgs()),
         cancellationTokenSource.Token)
     .ContinueWith((t) =>
     {
         if (!t.IsCanceled)
         {
             Invoke((Action)Close);
         }
     });
 }
Example #15
0
            /// <summary>
            /// Process an asset and register it for further reprocessing in the future.
            /// Apply any mod-related changes to the asset based on the existing mod asset meta map.
            /// </summary>
            /// <param name="asset">The asset to process.</param>
            /// <param name="assetNameFull">The "full name" of the asset, preferable the relative asset path.</param>
            /// <returns>The processed asset.</returns>
            public static object Process(object asset, string assetNameFull)
            {
                if (DumpOnLoad)
                {
                    Dump(assetNameFull, asset);
                }

                string assetName = assetNameFull;

                if (assetName.StartsWith(PathContentOrig))
                {
                    assetName = assetName.Substring(PathContentOrig.Length + 1);
                }

                int loadedIndex = LoadedAssetPaths.IndexOf(assetName);

                if (loadedIndex == -1)
                {
                    LoadedAssetPaths.Add(assetName);
                    LoadedAssetFullPaths.Add(assetNameFull);
                    LoadedAssets.Add(new WeakReference(asset));
                }
                else
                {
                    LoadedAssets[loadedIndex] = new WeakReference(asset);
                }

                if (asset is Atlas)
                {
                    Atlas    atlas = asset as Atlas;
                    ModAsset mapping;

                    mapping = Get(assetName + "LQ", true);
                    if (mapping != null && mapping.AssetType == typeof(AssetTypeDirectory))
                    {
                        atlas.Ingest(mapping);
                    }

                    mapping = Get(assetName, true);
                    if (mapping != null && mapping.AssetType == typeof(AssetTypeDirectory))
                    {
                        atlas.Ingest(mapping);
                    }

                    return(asset);
                }

                return(OnProcess?.InvokePassing(asset, assetNameFull) ?? asset);
            }
        public async Task <IEnumerable <string> > ProcessMultipleMessages(int numOfTasksToRun = 1)
        {
            // Console.WriteLine(messageQueue.Count);

            OnProcess?.Invoke(messageQueue.Count.ToString());
            List <Task <string> > listTask = new List <Task <string> >();

            for (int i = 0; i < numOfTasksToRun; i++)
            {
                listTask.Add(Task.Run(ProcessOneMessage));
            }

            var results = await Task.WhenAll(listTask.ToArray());

            return(results);
        }
Example #17
0
        public Task ProcessMessage(TestErrorOutboxCommand message, CancellationToken cancellationToken)
        {
            _count++;

            Console.WriteLine($"Try processed command at {DateTime.Now}, Count: {message.CountDown}");

            if (message.CountDown > _count)
            {
                throw new InvalidDataException();
            }

            Console.WriteLine($"Processed command at {DateTime.Now}, Count: {message.CountDown}");

            OnProcess?.Invoke(this, EventArgs.Empty);
            return(Task.CompletedTask);
        }
        public static void CallProcess(string message, Server.Connection connection)
        {
            OnProcess?.Invoke(message, connection);
            PacketBase pkt = StringToPacket(message);

            if (pkt == null)
            {
                return;
            }
            if (tcpProcessors.ContainsKey(pkt.t))
            {
                tcpProcessors[pkt.t]?.Invoke(pkt, connection);
            }
            if (tcpIdProcessors.ContainsKey(connection.NetId))
            {
                tcpIdProcessors[connection.NetId]?.Invoke(pkt, connection);
            }
        }
Example #19
0
        public async Task <Device> GetDevice(string address)
        {
            OVERRIDE_ONPROCESSEVENT = true;
            OnProcess?.Invoke(true);

            var name = await GetProp(address, "ro.product.model");

            if (string.IsNullOrWhiteSpace(name))
            {
                name = await GetProp(address, "ro.product.brand");
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                name = await GetProp(address, "ro.product.device");
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                name = "Unknown";
            }

            var android = await GetProp(address, "ro.build.version.release");

            if (string.IsNullOrWhiteSpace(android))
            {
                android = "Unknown";
            }

            var sdk = await GetProp(address, "ro.build.version.sdk");

            int.TryParse(sdk, out int _sdk);

            var _abi = await GetProp(address, "ro.product.cpu.abi");

            OnProcess?.Invoke(false);
            OVERRIDE_ONPROCESSEVENT = false;

            return(new Device()
            {
                Name = name,
                Android = android,
                Sdk = _sdk,
                Abi = _abi
            });
        }
Example #20
0
        protected void Perform(OnProcess process)
        {
            //using (Common.TestSpan span = new Common.TestSpan(ErrorTrap.TimeSpanLogger.Bin, mType.ToString(), Common.DebugLevel.Stats))
            {
                foreach (Pair <Type, List <ObjectLookup.Item> > pair in mList)
                {
                    Dictionary <ReferenceWrapper, bool> performed = new Dictionary <ReferenceWrapper, bool>();

                    foreach (ObjectLookup.Item item in pair.Second)
                    {
                        try
                        {
                            T obj = item.mChild as T;
                            if (obj == null)
                            {
                                continue;
                            }

                            SubPerform(obj, item.mParent, item.mField, performed, process);

                            if (DereferenceManager.Logger.OnWorldQuit)
                            {
                                return;
                            }
                        }
                        catch (Exception e)
                        {
                            if (item.mChild is SimDescription)
                            {
                                Common.Exception(item.mChild as SimDescription, e);
                            }
                            else
                            {
                                Common.Exception(item.mChild as GameObject, e);
                            }
                        }
                    }
                }
            }
        }
        protected override void OnShown(EventArgs e)
        {
            Task.Run(
                () => OnProcess?.Invoke(this, new EventArgs()),
                cancellationTokenSource.Token)
            .ContinueWith((t) =>
            {
                if (t.Exception != null)
                {
                    Console.Error.WriteLine(t.Exception);
                    SetProgress(t.Exception.Message);

                    // TODO: Throwing doesn't actually display the exception ui
                    throw t.Exception;
                }

                if (!t.IsCanceled)
                {
                    Invoke((Action)Close);
                }
            });
        }
Example #22
0
 /// <summary>
 /// Lanza el evento de procesado
 /// </summary>
 /// <param name="state">Estado</param>
 protected void RaiseOnProcess(EProcessState state)
 {
     OnProcess?.Invoke(this, state);
 }
Example #23
0
 public void Invoke()
 {
     OnProcess?.Invoke();
 }
Example #24
0
 protected void OnProcessAction(ProcessEventArgs e)
 {
     OnProcess?.Invoke(this, e);
 }
Example #25
0
 public override void Process(TRow row)
 {
     InvokeBeforeTargetAdapterProcessRowEvent(row);
     OnProcess?.Invoke(this, row);
     InvokeAfterTargetAdapterProcessRowEvent(row);
 }
Example #26
0
 public Task ProcessMessage(TestOutboxCommand message, CancellationToken cancellationToken)
 {
     Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}");
     OnProcess?.Invoke(this, message);
     return(Task.CompletedTask);
 }
Example #27
0
 public override void Process()
 {
     OnProcess?.Invoke(Manager);
 }
Example #28
0
 public void SeOnProcess(int percent, string itemDescription, bool showProgress = true)
 {
     OnProcess?.Invoke(this, new ProcessArgs(percent, "", itemDescription, showProgress));
 }
Example #29
0
        private async Task <string> RunAsync(string command, params object[] args)
        {
            using (var p = new Process())
            {
                var OutputMessage = string.Empty;
                p.OutputDataReceived += (s, e) => {
                    if (string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    OutputMessage += e.Data + Environment.NewLine;
                    if (!OVERRIDE_ONREPORTEVENT)
                    {
                        OutputDataReceived?.Invoke(e.Data);
                    }
                };

                var ErrorMessage = string.Empty;
                p.ErrorDataReceived += (s, e) => {
                    if (string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    ErrorMessage += e.Data + Environment.NewLine;
                    if (!OVERRIDE_ONREPORTEVENT)
                    {
                        ErrorDataReceived?.Invoke(e.Data);
                    }
                };

                p.StartInfo = new ProcessStartInfo()
                {
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    WindowStyle            = ProcessWindowStyle.Hidden,
                    FileName  = Path.Combine("Lib", "adb.exe"),
                    Arguments = string.Format(command, args)
                };

                p.Start();

                Debug.Print("Adb.Command: adb {0}", string.Format(command, args));

                if (!OVERRIDE_ONPROCESSEVENT)
                {
                    OnProcess?.Invoke(true);
                }

                p.BeginOutputReadLine();
                p.BeginErrorReadLine();

                await Task.Run(() => p.WaitForExit());

                if (!OVERRIDE_ONPROCESSEVENT)
                {
                    OnProcess?.Invoke(false);
                }

                if (p.ExitCode != 0)
                {
                    throw new Exception(ErrorMessage);
                }

                Debug.Print("Adb.Output: {0}", OutputMessage);
                return(OutputMessage);
            };
        }
Example #30
0
 public override void _Process(float delta) => OnProcess?.Invoke(this, delta);
        public WBIResultsDialogSwizzler(OnTransmit transmitMethod, OnDiscard discardMethod, OnProcess processMethod, OnKeep keepMethod)
        {
            onTransmit = transmitMethod;
            onDiscard = discardMethod;
            onProcess = processMethod;
            onKeep = keepMethod;

            SwizzleResultsDialog();
        }