示例#1
0
        IEnumerator LoadUnloadScene(string sceneName, LoadAction loadAction)
        {
            while (isBusy)
            {
                yield return(null);
            }

            isBusy = true;

            if (loadAction == LoadAction.Load)
            {
                yield return(SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive));
            }
            else
            {
                yield return(SceneManager.UnloadSceneAsync(sceneName));

                yield return(Resources.UnloadUnusedAssets());
            }

            isBusy = false;
            Debug.LogFormat("{0} {1} Done", sceneName, loadAction.ToString());

            CmdSceneDone(sceneName, loadAction);
        }
 private void loadMenuItem_Click(object sender, EventArgs e)
 {
     if (_openFileDialog.ShowDialog() == DialogResult.OK)
     {
         FileLocationName = _openFileDialog.FileName;
         LoadAction?.Invoke();
     }
 }
示例#3
0
        public CutScene(IState return_state, LoadAction load_action)
        {
            TextureManager tm = Globals.tm;

            this.return_state = return_state;
            this.load_action  = load_action;
            this.tm           = tm;
            white_dot         = tm.find_texture("white_dot");
        }
示例#4
0
        public CutScene(IState return_state, LoadAction load_action, DialogueOptions dialogue_options)
        {
            TextureManager tm = Globals.tm;

            this.return_state     = return_state;
            this.load_action      = load_action;
            this.tm               = tm;
            this.dialogue_options = dialogue_options;
            white_dot             = tm.find_texture("white_dot");
        }
 public RenderPassColorAttachmentDescriptor(
     TextureView attachment,
     LoadAction loadAction   = LoadAction.Clear,
     StoreAction storeAction = StoreAction.Store)
 {
     Guard.NotNull(attachment, nameof(attachment));
     Attachment  = attachment;
     LoadAction  = loadAction;
     StoreAction = storeAction;
     ClearColor  = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
 }
 public RenderPassColorAttachmentDescriptor(
     TextureView attachment,
     LoadAction loadAction,
     StoreAction storeAction,
     Color4 clearColor)
 {
     Guard.NotNull(attachment, nameof(attachment));
     Attachment  = attachment;
     LoadAction  = loadAction;
     StoreAction = storeAction;
     ClearColor  = clearColor;
 }
示例#7
0
        private void LoadPluginSettings(string name, T plugin, string path = null)
        {
            path = path ?? GetDefaultSettingsPath(name, plugin);

            if (string.IsNullOrWhiteSpace(path) || !File.Exists(path))
            {
                return;
            }

            var text = File.ReadAllText(path);

            LoadAction?.Invoke(plugin, text);
        }
示例#8
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = Texture?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ ClearDepth.GetHashCode();
         hashCode = (hashCode * 397) ^ ClearStencil.GetHashCode();
         hashCode = (hashCode * 397) ^ LoadAction.GetHashCode();
         hashCode = (hashCode * 397) ^ StoreAction.GetHashCode();
         hashCode = (hashCode * 397) ^ MipLevel.GetHashCode();
         hashCode = (hashCode * 397) ^ Slice.GetHashCode();
         return(hashCode);
     }
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderPassDepthStencilAttachmentDescriptor"/> struct.
 /// </summary>
 /// <param name="texture"><see cref="Texture"/> attachment</param>
 /// <param name="clearDepth">The clear depth.</param>
 /// <param name="clearStencil">The clear stencil.</param>
 /// <param name="loadAction">The attachment <see cref="Graphics.LoadAction"/></param>
 /// <param name="storeAction">The attachment <see cref="Graphics.StoreAction"/></param>
 /// <param name="mipLevel">The attachment texture mip level</param>
 /// <param name="slice">The attachment texture slice</param>
 public RenderPassDepthStencilAttachmentDescriptor(
     Texture texture,
     float clearDepth        = 1.0f,
     byte clearStencil       = 0,
     LoadAction loadAction   = LoadAction.Clear,
     StoreAction storeAction = StoreAction.DontCare,
     int mipLevel            = 0,
     int slice = 0)
 {
     Texture      = texture;
     ClearDepth   = clearDepth;
     ClearStencil = clearStencil;
     LoadAction   = loadAction;
     StoreAction  = storeAction;
     MipLevel     = mipLevel;
     Slice        = slice;
 }
示例#10
0
        public static MTLLoadAction ToMTLLoadAction(this LoadAction value)
        {
            switch (value)
            {
            case LoadAction.DontCare:
                return(MTLLoadAction.DontCare);

            case LoadAction.Clear:
                return(MTLLoadAction.Clear);

            case LoadAction.Load:
                return(MTLLoadAction.Load);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#11
0
        private void LoadPluginSettings(string name, T plugin)
        {
            var path = GetSettingsFilePath(name);

            if (string.IsNullOrWhiteSpace(path) || !File.Exists(path))
            {
                return;
            }

            var text = File.ReadAllText(path);
            var list = JsonConvert.DeserializeObject <List <SettingItem> >(text);

            if (list == null || plugin == null)
            {
                return;
            }

            LoadAction?.Invoke(plugin, list);
        }
示例#12
0
        public virtual bool Load(string fileName, LoadAction loadAction)
        {
            if (!Directory.Exists(this.RootDirectory))
            {
                Directory.CreateDirectory(this.RootDirectory);
            }
            bool   flag = false;
            string path = Path.Combine(this.RootDirectory, fileName);

            try
            {
                using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (BinaryReader reader = new BinaryReader((Stream)fileStream))
                    {
                        reader.ReadInt64();
                        loadAction(reader);
                        flag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                if (!fileName.EndsWith("_Backup"))
                {
                    if (System.IO.File.Exists(path + "_Backup"))
                    {
                        PCSaveDevice.Log("Loading error, will try with backup : " + (object)ex);
                        return(this.Load(fileName + "_Backup", loadAction));
                    }
                    else
                    {
                        PCSaveDevice.Log("Loading error, no backup found : " + (object)ex);
                    }
                }
                else
                {
                    PCSaveDevice.Log("Error loading backup : " + (object)ex);
                }
            }
            return(flag);
        }
        /// <summary>
        /// Gets the result by invoking the <see cref="LoadAction"/> if not already loaded.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Collections.Generic.IEnumerable`1"/> that can be used to iterate through the collection.
        /// </returns>
        protected virtual IEnumerable <T> GetResult()
        {
            if (IsLoaded)
            {
                return(_result);
            }

            // no load action, run query directly
            if (LoadAction == null)
            {
                _isLoaded = true;
                _result   = _query as IEnumerable <T>;
                return(_result);
            }

            // invoke the load action on the datacontext
            // result will be set with a callback to SetResult
            LoadAction.Invoke();
            return(_result ?? Enumerable.Empty <T>());
        }
示例#14
0
        private T ReadFile <T>(string filePath)
        {
            LoadAction <T> loadAction = null;

            switch (fileFormat)
            {
            case FileFormat.Binary:
                loadAction = ReadBinary <T>;
                break;

            case FileFormat.Xml:
                loadAction = ReadXml <T>;
                break;

            case FileFormat.Json:
                loadAction = ReadJson <T>;
                break;
            }
            return(loadAction.Invoke(filePath));
        }
示例#15
0
        /// <summary>
        /// Blits a fullscreen triangle using a given material.
        /// </summary>
        /// <param name="cmd">The command buffer to use</param>
        /// <param name="source">The source render target</param>
        /// <param name="destination">The destination render target</param>
        /// <param name="depth">The depth render target</param>
        /// <param name="propertySheet">The property sheet to use</param>
        /// <param name="pass">The pass from the material to use</param>
        /// <param name="clear">Should the destination target be cleared?</param>
        /// <param name="viewport">An optional viewport to consider for the blit</param>
        public static void BlitFullscreenTriangle(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, RenderTargetIdentifier depth, PropertySheet propertySheet, int pass, bool clear = false, Rect?viewport = null)
        {
            cmd.SetGlobalTexture(ShaderIDs.MainTex, source);

            LoadAction loadAction = viewport == null ? LoadAction.DontCare : LoadAction.Load;

            if (clear)
            {
                cmd.SetRenderTargetWithLoadStoreAction(destination, loadAction, StoreAction.Store, depth, loadAction, StoreAction.Store);
                cmd.ClearRenderTarget(true, true, Color.clear);
            }
            else
            {
                cmd.SetRenderTargetWithLoadStoreAction(destination, loadAction, StoreAction.Store, depth, LoadAction.Load, StoreAction.Store);
            }

            if (viewport != null)
            {
                cmd.SetViewport(viewport.Value);
            }

            cmd.DrawMesh(fullscreenTriangle, Matrix4x4.identity, propertySheet.material, 0, pass, propertySheet.properties);
        }
示例#16
0
 public void TargetLoadUnloadScene(NetworkConnection networkConnection, string SceneName, LoadAction loadAction)
 {
     // Check if server here because we already pre-loaded the subscenes on the server
     if (!isServer)
     {
         StartCoroutine(LoadUnloadScene(SceneName, loadAction));
     }
 }
示例#17
0
 public virtual bool Load(string fileName, LoadAction loadAction)
 {
   if (!Directory.Exists(this.RootDirectory))
     Directory.CreateDirectory(this.RootDirectory);
   bool flag = false;
   string path = Path.Combine(this.RootDirectory, fileName);
   try
   {
     using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
       using (BinaryReader reader = new BinaryReader((Stream) fileStream))
       {
         reader.ReadInt64();
         loadAction(reader);
         flag = true;
       }
     }
   }
   catch (Exception ex)
   {
     if (!fileName.EndsWith("_Backup"))
     {
       if (System.IO.File.Exists(path + "_Backup"))
       {
         PCSaveDevice.Log("Loading error, will try with backup : " + (object) ex);
         return this.Load(fileName + "_Backup", loadAction);
       }
       else
         PCSaveDevice.Log("Loading error, no backup found : " + (object) ex);
     }
     else
       PCSaveDevice.Log("Error loading backup : " + (object) ex);
   }
   return flag;
 }
示例#18
0
 public void SetRenderTargetDescriptor(RenderTarget renderTargetView, LoadAction loadAction, ColorRgbaF clearColor = default)
 {
     PlatformSetRenderTargetDescriptor(renderTargetView, loadAction, clearColor);
 }
示例#19
0
 private void LoadBaseAndSum_Click(object sender, EventArgs e)
 {
     LdAct = LoadAction.MULT;
     LoadBaseDialog.ShowDialog();
 }
        public int CalculateEstimate(State state)
        {
            int freePlaneStorageCount = 1; // + state.Planes.Min(p => p.FreeStorageCount);
            int freeVanStorageCount   = 1; // + state.Vans.Min(v => v.FreeStorageCount);

            int other          = 0;
            int totalFlyCost   = 0;
            int totalDriveCost = 0;

            foreach (var package in state.Packages.Where(p => !p.IsInDestination))
            {
                //have to fly
                if (package.Location.City != package.Destination.City)
                {
                    //have to get to the airport
                    if (!package.Location.IsAirport)
                    {
                        //no empty van there
                        if (!package.Location.Vans.Any(v => !v.IsFull))
                        {
                            other += new DriveAction().ActionCost;
                        }

                        if (package.LocationType != PackageLocationEnum.Van)
                        {
                            other += new LoadAction().ActionCost;
                        }

                        totalDriveCost += new DriveAction().ActionCost;
                        other          += new UnLoadAction().ActionCost;
                    }

                    //no plane there
                    if (!package.Location.City.Planes.Any(p => !p.IsFull))
                    {
                        other += new FlyAction().ActionCost;
                    }

                    //fly
                    if (package.LocationType != PackageLocationEnum.Plane)
                    {
                        other += new PickUpAction().ActionCost;
                    }

                    totalFlyCost += new FlyAction().ActionCost;

                    other += new DropOffAction().ActionCost;

                    //have to get from the airport
                    if (!package.Destination.IsAirport)
                    {
                        //no empty van there
                        if (!package.Destination.Vans.Any(v => !v.IsFull))
                        {
                            other += new DriveAction().ActionCost;
                        }

                        other          += new LoadAction().ActionCost;
                        totalDriveCost += new DriveAction().ActionCost;
                        other          += new UnLoadAction().ActionCost;
                    }
                }
                else //move just in city
                {
                    //no empty van there
                    if (!package.Location.Vans.Any(v => !v.IsFull))
                    {
                        other += new DriveAction().ActionCost;
                    }

                    if (package.LocationType == PackageLocationEnum.Plane)
                    {
                        other += new UnLoadAction().ActionCost;
                    }

                    if (package.LocationType != PackageLocationEnum.Van)
                    {
                        other += new LoadAction().ActionCost;
                    }

                    totalDriveCost += new DriveAction().ActionCost;

                    other += new UnLoadAction().ActionCost;
                }
            }
            return(other + totalFlyCost / freePlaneStorageCount + totalDriveCost / freeVanStorageCount);
        }
示例#21
0
 private void Btn_load_match_Click(object sender, EventArgs e)
 {
     LoadAction?.Invoke(txt_card_match_path.Text);
 }
示例#22
0
 private void LoadBaseAndOverride_Click(object sender, EventArgs e)
 {
     LdAct = LoadAction.OVER;
     LoadBaseDialog.ShowDialog();
 }
示例#23
0
 protected override void OnLoad(EventArgs e)
 {
     Text = "Produtos";
     base.OnLoad(e);
     LoadAction?.Invoke();
 }
示例#24
0
 private void PlatformSetRenderTargetDescriptor(RenderTarget renderTargetView, LoadAction loadAction, ColorRgbaF clearColor)
 {
     _renderTargetDescriptor = new RenderTargetDescriptor
     {
         RenderTarget = renderTargetView,
         LoadAction   = loadAction,
         ClearColor   = clearColor.ToRawColor4()
     };
 }
示例#25
0
 public void CmdSceneDone(string sceneName, LoadAction loadAction)
 {
     // The point of this is to show the client telling server it has loaded the subscene
     // so the server might take some further action, e.g. reposition the player.
     Debug.LogFormat("{0} {1} done on client", sceneName, loadAction.ToString());
 }
示例#26
0
        private void LoadBaseDialog_FileOk(object sender, CancelEventArgs e)
        {
            if (e.Cancel)
            {
                return;
            }
            switch (LdAct)
            {
            case LoadAction.MULT:
            {
                FiltersBase.FiltersBase fBase;
                try
                {
                    using (var input = File.OpenRead(LoadBaseDialog.FileNames[0]))
                    {
                        fBase = FiltersBase.FiltersBase.Parser.ParseFrom(input);
                        if (fBase.Filters.Count < 1)
                        {
                            return;
                        }
                        foreach (var item in fBase.Filters)
                        {
                            Filter temp = new Filter()
                            {
                                Band       = item.Band,
                                CenterFreq = item.CenterFreq,
                                IsTunable  = item.IsTunable,
                                Name       = item.Name
                            };
                            foreach (var point in item.Points)
                            {
                                temp.Points.Add(new Point(point.Freq, point.Att));
                            }
                            Form1.Filters.Add(temp);
                        }
                    }
                }
                catch (IOException exception)
                {
                    MessageBox.Show(exception.ToString());
                }
                LdAct = LoadAction.NOPE;
            }
            break;

            case LoadAction.OVER:
            {
                Form1.Filters.Clear();
                FiltersBase.FiltersBase fBase;
                try
                {
                    using (var input = File.OpenRead(LoadBaseDialog.FileNames[0]))
                    {
                        fBase = FiltersBase.FiltersBase.Parser.ParseFrom(input);
                        if (fBase.Filters.Count < 1)
                        {
                            return;
                        }
                        foreach (var item in fBase.Filters)
                        {
                            Filter temp = new Filter()
                            {
                                Band       = item.Band,
                                CenterFreq = item.CenterFreq,
                                IsTunable  = item.IsTunable,
                                Name       = item.Name
                            };
                            foreach (var point in item.Points)
                            {
                                temp.Points.Add(new Point(point.Freq, point.Att));
                            }
                            Form1.Filters.Add(temp);
                        }
                    }
                }
                catch (IOException exception)
                {
                    MessageBox.Show(exception.ToString());
                }

                LdAct = LoadAction.NOPE;
            }
            break;

            case LoadAction.NOPE:
            default:
                break;
            }
        }
        private void PlatformSetRenderTargetDescriptor(RenderTarget renderTargetView, LoadAction loadAction, ColorRgba clearColor)
        {
            var colorAttachment = DeviceDescriptor.ColorAttachments[0];

            colorAttachment.Texture    = renderTargetView.Texture;
            colorAttachment.LoadAction = loadAction.ToMTLLoadAction();
            colorAttachment.ClearColor = clearColor.ToMTLClearColor();
        }
示例#28
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     LoadAction?.Invoke();
 }