Example #1
0
 public virtual void ResetWeaponToDefaults()
 {
     salvoSize     = defaultSalvoSize;
     reloadType    = defaultReloadType;
     reloadTime    = defaultReloadTime;
     fireRate      = defaultFireRate;
     ammoPerShot   = defaultAmmoPerShot;
     unlimitedAmmo = defaultUnlimitedAmmo;
     reserveAmmo   = defaultReserveAmmo;
 }
Example #2
0
        //public static DatabaseController<Expenditure> ExpenseDataBase
        //{
        //    get
        //    {
        //        if (ExpenseDataBase == null)
        //        {
        //            ExpenseDataBase = new DatabaseController<Expenditure>(DependencyService.Get<ISQLHelper>().getLocalFilePath("LifeBudget_moneyDB.db3"));
        //        }
        //        return ExpenseDataBase;
        //    }
        //}

        private void ReloadExpenses(ReloadType type, ContentType content, ReloadMode mode)
        {
            // This function will take the last 10 expenses (if available) and place them in the 'TopTenExpenses' stack layout
            // First, I need to clear out the table
            TopTenTable.Clear();

            // Second, I need to get the whole list of expenses
            switch (mode)
            {
            case ReloadMode.display:
                switch (content)
                {
                case ContentType.Spending:
                    switch (type)
                    {
                    case ReloadType.most_recent:
                        for (int i = 1; i <= 10; i++)
                        {
                            try
                            {
                                TopTenTable.Add(new TopTenItem(ExpenseDataBase.GetItem(ExpenseDataBase.CountItems() - i), ReloadMode.display));
                            }
                            catch { break; }                    // this will kick out of the for loop whenever an exception is raised
                        }
                        break;
                    }
                    break;
                }
                break;

            case ReloadMode.delete:
                switch (content)
                {
                case ContentType.Spending:
                    switch (type)
                    {
                    case ReloadType.most_recent:
                        for (int i = ExpenseDataBase.CountItems() - 1; i >= 0; i--)
                        {
                            try
                            {
                                TopTenTable.Add(new TopTenItem(ExpenseDataBase.GetItem(i), ReloadMode.delete));
                            }
                            catch { break; }                    // this will kick out of the for loop whenever an exception is raised
                        }
                        break;
                    }
                    break;
                }
                break;
            }
            ResizeTable();
        }
        /// <summary>
        /// Calculate bullet and clip count
        /// </summary>
        public virtual void ReCalculateAmmo(ReloadType reloadType)
        {
            switch (reloadType)
            {
            case ReloadType.Standard:
                StandardCalculate();
                break;

            case ReloadType.Realistic:
                RealisticCalculate();
                break;
            }
        }
 public static void RequestReload(ReloadType type, string name)
 {
     if (type == ReloadType.Chr)
     {
         RequestReloadChr(name);
     }
     else if (type == ReloadType.Object)
     {
         RequestReloadObj(name);
     }
     else if (type == ReloadType.Parts)
     {
         RequestReloadParts();
     }
 }
Example #5
0
    protected void Awake()
    {
        defaultSalvoSize     = salvoSize;
        defaultReloadType    = reloadType;
        defaultReloadTime    = reloadTime;
        defaultFireRate      = fireRate;
        defaultAmmoPerShot   = ammoPerShot;
        defaultUnlimitedAmmo = unlimitedAmmo;
        defaultReserveAmmo   = reserveAmmo;

        turretCam = transform.root.GetComponentInChildren <PlayerGunnerController>().camera;
        cinemachineBasicMultiChannelPerlin = turretCam.GetCinemachineComponent <CinemachineBasicMultiChannelPerlin>();
        driverCamScript    = transform.root.GetComponentInChildren <DriverCinematicCam>();
        rigidbodyVehicleId = GetComponentInParent <PhysXRigidBody>().vehicleId;
    }
Example #6
0
 void homegear_OnReloadRequired(Homegear sender, ReloadType reloadType)
 {
     if (reloadType == ReloadType.Full)
     {
         //WriteLog("Received reload required event. Reloading.");
         //Finish all operations on the Homegear object and then call:
         _homegear.Reload();
     }
     else if (reloadType == ReloadType.SystemVariables)
     {
         //WriteLog("Reloading system variables.");
         //Finish all operations on the system variables and then call:
         _homegear.SystemVariables.Reload();
     }
     else if (reloadType == ReloadType.Events)
     {
         //WriteLog("Reloading timed events.");
         //Finish all operations on the timed events and then call:
         _homegear.TimedEvents.Reload();
     }
 }
Example #7
0
    public Spell(InputAction.Spell type, ReloadType reloadType, int reloadData, bool instant)
    {
        this.type         = type;
        this.reloadType   = reloadType;
        ReloadData        = reloadData;
        Instant           = instant;
        _actualReloadData = reloadData;
        _icon             = null;
        _dataDisplay      = null;
        switch (reloadType)
        {
        case ReloadType.USAGE:
            _actualReloadData = reloadData;
            break;

        case ReloadType.COOLDOWN:
            _actualReloadData = 0;
            if (_icon != null)
            {
                _icon.color = Color.white;
            }
            break;
        }
    }
Example #8
0
        static IEnumerable <IRemoteItem> FindItems(string path_str, bool recursive = false, IRemoteItem root = null, CancellationToken ct = default(CancellationToken), ReloadType reload = ReloadType.Reload)
        {
            ct.ThrowIfCancellationRequested();
            List <IRemoteItem> ret = new List <IRemoteItem>();

            if (string.IsNullOrEmpty(path_str))
            {
                if (root == null)
                {
                    if (recursive)
                    {
                        ret.AddRange(RemoteServerFactory.ServerList.Values.Select(x => x[""]).Select(x => FindItems("", true, x, ct, reload)).SelectMany(x => x));
                        return(ret);
                    }
                    else
                    {
                        ret.AddRange(RemoteServerFactory.ServerList.Values.Select(x => x[""]));
                        return(ret);
                    }
                }
                else
                {
                    root = RemoteServerFactory.PathToItem(root.FullPath, reload).Result;
                    if (root == null)
                    {
                        return(ret);
                    }
                    ret.Add(root);
                    var children = root.Children;
                    if (recursive)
                    {
                        ret.AddRange(children.Where(x => x.ItemType == RemoteItemType.File));
                        ret.AddRange(children.Where(x => x.ItemType == RemoteItemType.Folder).Select(x => FindItems("", true, x, ct, reload)).SelectMany(x => x));
                    }
                    return(ret);
                }
            }

            var m = Regex.Match(path_str, @"^(?<server>[^:]+)(://)(?<path>.*)$");

            if (m.Success)
            {
                var servername = m.Groups["server"].Value;
                if (servername.IndexOfAny(new[] { '?', '*' }) < 0)
                {
                    var server = RemoteServerFactory.ServerList[servername];
                    return(FindItems(m.Groups["path"].Value, recursive, server[""], ct, reload));
                }
                else
                {
                    var servers = RemoteServerFactory.ServerList.Keys;
                    return(servers.Where(x => Regex.IsMatch(x, "^" + Regex.Escape(servername).Replace("\\*", ".*").Replace("\\?", ".") + "$"))
                           .Select(x => FindItems(m.Groups["path"].Value, recursive, RemoteServerFactory.ServerList[x][""], ct, reload))
                           .SelectMany(x => x));
                }
            }
            else
            {
                if (root == null)
                {
                    return(ret);
                }

                m        = Regex.Match(path_str, @"^(?<current>[^/\\]*)(/|\\)?(?<next>.*)$");
                path_str = m.Groups["next"].Value;

                root = RemoteServerFactory.PathToItem(root.FullPath, reload).Result;
                if (root == null)
                {
                    return(ret);
                }
                var children = root.Children;

                var itemname = m.Groups["current"].Value;
                if (itemname == "**")
                {
                    ret.AddRange(FindItems(path_str, true, root, ct, reload));
                    ret.AddRange(children
                                 .Select(x => FindItems(path_str, true, x, ct, reload))
                                 .SelectMany(x => x));
                    ret.AddRange(children
                                 .Select(x => FindItems("**/" + path_str, true, x, ct, reload))
                                 .SelectMany(x => x));
                    return(ret.Distinct(new RemoteItemEqualityComparer()));
                }
                else if (itemname.IndexOfAny(new[] { '?', '*' }) < 0)
                {
                    return(children.Where(x => x.Name == itemname || x.PathItemName == itemname)
                           .Select(x => FindItems(path_str, recursive, x, ct, reload))
                           .SelectMany(x => x));
                }
                else
                {
                    return(children.Where(x => Regex.IsMatch(x.Name, "^" + Regex.Escape(itemname).Replace("\\*", ".*").Replace("\\?", ".") + "$"))
                           .Select(x => FindItems(path_str, recursive, x, ct, reload))
                           .SelectMany(x => x));
                }
            }
        }
Example #9
0
        private static int RunDownload(string [] targetArgs, string[] paramArgs)
        {
            string remotePath;
            string localPath;

            if (targetArgs.Length < 3)
            {
                Console.Error.WriteLine("download needs more 2 arguments.");
                Console.Error.WriteLine("download (remotepath) (localpath)");
                return(0);
            }

            remotePath = targetArgs[1];
            remotePath = remotePath.Replace('\\', '/');
            localPath  = targetArgs[2];
            if (!localPath.Contains(':') && !localPath.StartsWith(@"\\"))
            {
                localPath = Path.GetFullPath(localPath);
            }
            if (!localPath.StartsWith(@"\\"))
            {
                localPath = ItemControl.GetLongFilename(localPath);
            }

            Console.Error.WriteLine("download");
            Console.Error.WriteLine("remote: " + remotePath);
            Console.Error.WriteLine("local: " + ItemControl.GetOrgFilename(localPath));

            ReloadType reload = ReloadType.Reload;

            foreach (var p in paramArgs)
            {
                switch (p)
                {
                case "cache":
                    Console.Error.WriteLine("(--cache: no reload)");
                    reload = ReloadType.Cache;
                    break;
                }
            }

            var job = JobControler.CreateNewJob(JobClass.ControlMaster);

            job.DisplayName = "Download";
            JobControler.Run(job, (j) =>
            {
                try
                {
                    var j2 = InitServer(j);
                    j2.Wait(ct: j.Ct);

                    var target = FindItems(remotePath, ct: j.Ct, reload: reload);

                    if (target.Count() < 1)
                    {
                        j.ResultAsObject = 2;
                        return;
                    }

                    string remotePathBase = null;
                    if (remotePath.IndexOfAny(new[] { '*', '?' }) < 0)
                    {
                        remotePathBase = ItemControl.GetCommonPath(target);
                    }
                    else
                    {
                        remotePathBase = GetBasePath(remotePath);
                    }

                    target = RemoveDup(target);

                    ConsoleJobDisp.Run();

                    var j3 = target
                             .Where(x => x.ItemType == RemoteItemType.File)
                             .Select(x => RemoteServerFactory.PathToItem(x.FullPath, ReloadType.Reload).Result)
                             .Select(x => ItemControl.DownloadFile(Path.Combine(localPath, ItemControl.GetLocalFullPath(x.FullPath, remotePathBase)), x, j, true));
                    var j4 = target
                             .Where(x => x.ItemType == RemoteItemType.Folder)
                             .Select(x => RemoteServerFactory.PathToItem(x.FullPath, ReloadType.Reload).Result)
                             .Select(x => ItemControl.DownloadFolder(Path.GetDirectoryName(Path.Combine(localPath, ItemControl.GetLocalFullPath(x.FullPath, remotePathBase))), new[] { x }, j, true));

                    foreach (var jx in j3.Concat(j4).ToArray())
                    {
                        j.Ct.ThrowIfCancellationRequested();
                        jx.Wait(ct: j.Ct);
                    }

                    job.ResultAsObject = 0;
                }
                catch (OperationCanceledException)
                {
                    job.ResultAsObject = -1;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("error: " + ex.ToString());
                    job.ResultAsObject = 1;
                }
            });
            try
            {
                job.Wait(ct: job.Ct);
            }
            catch (OperationCanceledException)
            {
            }
            TSviewCloudConfig.Config.ApplicationExit = true;
            Console.Out.Flush();
            return((job.ResultAsObject as int?) ?? -1);
        }
Example #10
0
        static int RunList(string[] targetArgs, string[] paramArgs)
        {
            string remotepath = null;
            IEnumerable <IRemoteItem> target = null;

            if (targetArgs.Length > 1)
            {
                remotepath = targetArgs[1];
                remotepath = remotepath.Replace('\\', '/');
            }

            bool       recursive = false;
            bool       showhash  = false;
            ReloadType reload    = ReloadType.Reload;

            foreach (var p in paramArgs)
            {
                switch (p)
                {
                case "recursive":
                    Console.Error.WriteLine("(--recursive: recursive mode)");
                    recursive = true;
                    break;

                case "hash":
                    Console.Error.WriteLine("(--hash: show hash)");
                    showhash = true;
                    break;

                case "cache":
                    Console.Error.WriteLine("(--cache: no reload)");
                    reload = ReloadType.Cache;
                    break;
                }
            }

            var job = JobControler.CreateNewJob(JobClass.ControlMaster);

            job.DisplayName = "ListItem";
            JobControler.Run(job, (j) =>
            {
                try
                {
                    var j2 = InitServer(j);
                    j2.Wait(ct: j.Ct);

                    target = FindItems(remotepath, recursive: recursive, ct: j.Ct, reload: reload);

                    if (target.Count() < 1)
                    {
                        j.ResultAsObject = 2;
                        return;
                    }

                    if (remotepath?.Contains("**") ?? true)
                    {
                        recursive = true;
                    }

                    Console.Error.WriteLine("Found : " + target.Count());
                    foreach (var item in target.OrderBy(x => x.FullPath))
                    {
                        string detail = "";
                        if (showhash)
                        {
                            detail = "\t" + item.Hash;
                        }

                        if (recursive)
                        {
                            Console.WriteLine(item.FullPath + "\t" + item.Name + detail);
                        }
                        else
                        {
                            if (item.IsRoot)
                            {
                                Console.WriteLine(item.FullPath + "\t" + item.Name + detail);
                            }
                            else
                            {
                                Console.WriteLine(item.Name + ((item.ItemType == RemoteItemType.Folder) ? "/" : "") + detail);
                            }
                        }
                    }

                    job.ResultAsObject = 0;
                }
                catch (OperationCanceledException)
                {
                    job.ResultAsObject = -1;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("error: " + ex.ToString());
                    job.ResultAsObject = 1;
                }
            });
            try
            {
                job.Wait(ct: job.Ct);
            }
            catch (OperationCanceledException)
            {
            }
            TSviewCloudConfig.Config.ApplicationExit = true;
            Console.Out.Flush();
            return((job.ResultAsObject as int?) ?? -1);
        }
 public void SetReloadType(ReloadType value)
 {
     reloadType = value;
 }