Пример #1
0
        public static SortedList <string, Complate> ExtractPatterns(string objectDesignPreset, SortedList <string, bool> enabledStencils)
        {
            //  string objectDesignPreset = ObjectDesigner.GetObjectDesignPreset(objectId);
            if (objectDesignPreset == null || objectDesignPreset.Length == 0)
            {
                return(new SortedList <string, Complate>());
            }
            Dictionary <string, Complate> dictionary = new Dictionary <string, Complate>();
            string text = Complate.ProcessPreset(objectDesignPreset, dictionary);

            if (text == null || text.Length == 0)
            {
                return(new SortedList <string, Complate>());
            }
            Complate complate;

            if (enabledStencils != null && dictionary.TryGetValue(text, out complate))
            {
                Complate.Variable[] variables = complate.Variables;
                for (int i = 0; i < variables.Length; i++)
                {
                    Complate.Variable variable = variables[i];
                    if (variable.Type == Complate.Variable.Types.Bool)
                    {
                        string text2 = variable.Name.ToLower();
                        if (text2.StartsWith("stencil ") && text2.EndsWith(" enabled"))
                        {
                            enabledStencils.Add(variable.Name, bool.Parse(variable.Value));
                        }
                    }
                }
            }
            dictionary.Remove(text);
            return(new SortedList <string, Complate>(dictionary));
        }
Пример #2
0
        private static void OnProcessRandomizeMaterial()
        {
            CASCompositorController ths = CASCompositorController.sController;

            if (ths == null)
            {
                return;
            }

            int selection = ths.MaterialSkewerSelectedPattern;

            if (selection >= 0x0)
            {
                List <Complate> choices = new List <Complate>();

                foreach (ItemGridCellItem item in ths.mMaterialsWindowGrid.Items)
                {
                    Complate choice = item.mTag as Complate;
                    if (choice == null)
                    {
                        continue;
                    }

                    choices.Add(choice);
                }

                if (choices.Count > 0)
                {
                    ths.ApplyMaterial(RandomUtil.GetRandomObjectFromList(choices).Clone() as Complate, selection, false, false);

                    ProcessAlterColor(true);
                }
            }
        }
Пример #3
0
 public void DwnloadFile(string path, IAppToInstall app)
 {
     using (WebClient wc = new WebClient())
     {
         wc.DownloadFileCompleted += (sender, e) =>
         {
             Complate?.Invoke(app, e);
         };
         wc.DownloadProgressChanged += Progress;
         wc.DownloadFileTaskAsync(new Uri("http://vps458649.ovh.net/" + app.FileDwnlName), Path.Combine(path + "\\" + app.FileDwnlName));
     }
 }
Пример #4
0
            protected override void OnPerform()
            {
                CompositorUtil.ApplyPreset(mPresetEntry);
                SortedList <string, Complate> patterns = new SortedList <string, Complate>();

                foreach (KeyValuePair <string, Complate> pair2 in mPresetEntry.Value)
                {
                    patterns.Add(pair2.Key, pair2.Value);
                }

                using (DesignModeSwap swap = new DesignModeSwap())
                {
                    if (swap.SetSourceObject(this.mObject))
                    {
                        swap.ClearOldCompositors();
                    }

                    string   key      = mPresetEntry.Key;
                    Complate complate = null;
                    if (!patterns.TryGetValue(key, out complate))
                    {
                        return;
                    }

                    SortedList <string, bool> enabledStencils = new SortedList <string, bool>();
                    foreach (Complate.Variable variable in complate.Variables)
                    {
                        if (variable.Type == Complate.Variable.Types.Bool)
                        {
                            string str2 = variable.Name.ToLower();
                            if (str2.StartsWith("stencil ") && str2.EndsWith(" enabled"))
                            {
                                enabledStencils.Add(variable.Name, bool.Parse(variable.Value));
                            }
                        }
                    }

                    string presetStringFromPresetEntry = SimBuilder.GetPresetStringFromPresetEntry(mPresetEntry);

                    Complate.SetupDesignSwap(swap, patterns, presetStringFromPresetEntry, true, enabledStencils);

                    swap.ApplyToObject();
                }
            }
Пример #5
0
        /// <summary>
        ///     Intercept
        /// </summary>
        /// <param name="invocation"></param>
        public void Intercept(IInvocation invocation)
        {
            try
            {
                //需设置为Config
                var retryPolicy =
                    Policy
                    .Handle <Exception>()
                    .Retry(RetryCount);

                retryPolicy
                .Execute(invocation.Proceed);
            }
            catch (Exception e)
            {
                Error?.Invoke(e);
            }
            finally
            {
                Complate?.Invoke(invocation);
            }
        }
Пример #6
0
        public static GameObject RecreateSoldObject(RestockItem restockItem, SimDescription actor)
        {
            try
            {
                IGameObject      gameObject       = null;
                bool             restockBuyMode   = false;
                bool             restockCraftable = false;
                StoreSetRegister register         = null;

                bool         isRug;
                StoreSetBase shopBase = ReturnStoreSetBase(restockItem, out isRug);

                if (shopBase != null)
                {
                    if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                    {
                        register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
                    }

                    restockBuyMode   = shopBase.Info.RestockBuyMode;
                    restockCraftable = shopBase.Info.RestockCraftable;

                    #region Find the slot

                    bool slotFound = false;
                    Slot slot      = Slot.ContainmentSlot_0;
                    if (!isRug)
                    {
                        Slot[] containmentSlots = shopBase.GetContainmentSlots();

                        if (containmentSlots != null)
                        {
                            for (int i = 0; i < containmentSlots.Length; i++)
                            {
                                GameObject o = shopBase.GetContainedObject(containmentSlots[i]) as GameObject;

                                if (o != null && o.ObjectId == restockItem.ObjectId)
                                {
                                    slotFound = true;
                                    slot      = containmentSlots[i];
                                    break;
                                }
                            }
                        }
                    }
                    #endregion

                    //Restock from inventory only, if not buy object and linked to register
                    bool restockFromInventory = RestockFromInventory(restockItem, restockCraftable);

                    //Restock from buy mode
                    #region Buy Mode
                    if (!restockFromInventory)
                    {
                        if (restockItem.info.Type == ItemType.Buy || restockItem.info.Type == ItemType.Craftable)
                        {
                            gameObject = GlobalFunctions.CreateObject(restockItem.info.Key, restockItem.Position, restockItem.mLevel, restockItem.ForwardVector);
                            if (!(gameObject is FailureObject))
                            {
                                if (!string.IsNullOrEmpty(restockItem.info.DesignPreset))
                                {
                                    SortedList <string, bool>     enabledStencils = new SortedList <string, bool>();
                                    SortedList <string, Complate> patterns        = StoreHelperClass.ExtractPatterns(restockItem.info.DesignPreset, enabledStencils);
                                    DesignModeSwap designModeSwap = Complate.SetupDesignSwap(gameObject.ObjectId, patterns, false, enabledStencils);
                                    if (designModeSwap != null)
                                    {
                                        designModeSwap.ApplyToObject();
                                    }
                                }
                            }
                        }
                        else
                        {
                            gameObject = ReturnShoppingObject(restockItem, actor, register);
                            gameObject.AddToWorld();
                            gameObject.SetPosition(restockItem.Position);
                        }
                        #region Pay for Restock

                        //Reduce from base owner or register's owner
                        if (shopBase.Info.Owner != 0uL)
                        {
                            SimDescription sd = CMStoreSet.ReturnSim(shopBase.Info.Owner);
                            if (sd != null)
                            {
                                sd.ModifyFunds(-restockItem.info.Price);
                            }
                            else
                            {
                                CMStoreSet.PrintMessage("Couldn't find owner sim");
                            }
                        }
                        else if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                        {
                            //StoreSetRegister register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
                            if (register != null && register.Info.OwnerId != 0uL)
                            {
                                SimDescription sd = CMStoreSet.ReturnSim(register.Info.OwnerId);
                                if (sd != null)
                                {
                                    sd.ModifyFunds(-restockItem.info.Price);
                                }
                            }
                        }

                        #endregion
                    }
                    #endregion Buy Mode

                    #region Inventory
                    else
                    {
                        //Restock from Inventory
                        if (shopBase != null && shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                        {
                            gameObject = ReturnRestocableObject(restockItem, shopBase.Info.RegisterId);

                            if (gameObject != null)
                            {
                                gameObject.AddToWorld();
                                gameObject.SetPosition(restockItem.Position);
                                gameObject.SetForward(restockItem.ForwardVector);
                            }
                            else
                            {
                                CMStoreSet.PrintMessage("Restockable object null");
                            }
                        }
                    }
                    #endregion Inventory

                    //Delete restock object
                    if (restockItem != null)
                    {
                        restockItem.Destroy();
                    }

                    //Add restocked item back to slot
                    if (slotFound)
                    {
                        IGameObject io = (IGameObject)shopBase;
                        gameObject.ParentToSlot(io, slot);
                    }


                    return((GameObject)gameObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Exception ex)
            {
                CMStoreSet.PrintMessage("RecreateSoldObject: " + ex.Message);
                return(null);
            }
        }
Пример #7
0
 public void RegisterPatternKeys(CASPart part, Complate topComplate)
 {
     mCASModel.RegisterPatternKeys(part, topComplate);
 }