コード例 #1
0
        // GET: SupportTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupportType supportType = db.MySupportTypeContext.Find(id);

            if (supportType == null)
            {
                return(HttpNotFound());
            }

            //----------Get All Time----//
            var AllTimeSpan = db.DateTimeSpans.ToList();

            List <SelectListItem> MyTimeSpan = new List <SelectListItem>();

            foreach (var STItem in AllTimeSpan)
            {
                var item = new SelectListItem();
                if (STItem.Id == supportType.DateTimeSpanId)
                {
                    item.Selected = true;
                }
                item.Value = STItem.Id.ToString();
                item.Text  = STItem.DateTimeName;

                MyTimeSpan.Add(item);
            }
            ViewBag.TimeSpanOption = MyTimeSpan;
            return(View(supportType));
        }
コード例 #2
0
        public JsonResult SaveDataInDatabase(SupportType model)
        {
            var result = false;

            try
            {
                if (model.Id > 0)
                {
                    _context.Update(model);
                    _context.SaveChanges();
                    result = true;
                }
                else
                {
                    _context.Add(model);
                    _context.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result));
        }
コード例 #3
0
       public bool EditSupportType(SupportType entity)
       {
           _unitOfWork.SupportTypeRepository.Edit(entity);
           _unitOfWork.Save();
           return true;

       }
コード例 #4
0
  public bool DeleteSupportType(SupportType entity)
 {
      if(entity==null) return false;
    _unitOfWork.SupportTypeRepository.Delete(entity);
    _unitOfWork.Save();
    return true;
 }
コード例 #5
0
        public ActionResult Create(FormCollection collection)
        {
            var supportType = new SupportType();

            try
            {
                this.RadynTryUpdateModel(supportType);
                supportType.CongressId           = this.Homa.Id;
                supportType.CurrentUICultureName = collection["LanguageId"];
                if (CongressComponent.Instance.BaseInfoComponents.SupportTypeFacade.Insert(this.Homa.Id, supportType))
                {
                    ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle,
                                messageIcon: MessageIcon.Succeed);
                    return(this.SubmitRedirect(collection, new { Id = supportType.Id }));
                }
                ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle,
                            messageIcon: MessageIcon.Error);
                return(Redirect("~/Congress/SupportType/Index"));
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
                return(View(supportType));
            }
        }
コード例 #6
0
 public bool AddSupportType(SupportType entity)
 {
     _unitOfWork.SupportTypeRepository.Add(entity);
     _unitOfWork.Save();
     return true;
     
 }
コード例 #7
0
ファイル: GameMode.cs プロジェクト: 737871854/FireMen2
    /// <summary>
    /// 帧更新
    /// </summary>
    private void UpdatePreFrame()
    {
        if (IsPlaying())
        {
            //OnJudgePassCondition();
        }

        if (mFogType == FogType.Foging)
        {
            if (mFogTime > 0)
            {
                mFogTime -= Time.deltaTime;
            }
            else
            {
                mFogType = FogType.Normal;
                // 向下位机发送结束冰冻消息
                Debugger.Log("结束喷雾消息");
            }
        }

        if (mSupportType == SupportType.Support)
        {
            if (mSupportTime > 0)
            {
                mSupportTime -= Time.deltaTime;
            }
            else
            {
                mSupportType = SupportType.Normal;
            }
        }
    }
コード例 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Defenition")] SupportType supportType)
        {
            if (id != supportType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supportType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupportTypeExists(supportType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supportType));
        }
コード例 #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            SupportType supportType = db.MySupportTypeContext.Find(id);

            db.MySupportTypeContext.Remove(supportType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #10
0
 public NugetPackage(string id, IReadOnlyList <string> dependencies, SupportType supportType, Option <SemanticVersion> version, IReadOnlyList <FrameworkName> frameworks)
 {
     Id           = id;
     Dependencies = dependencies;
     SupportType  = supportType;
     Version      = version;
     Frameworks   = frameworks;
 }
コード例 #11
0
        public SupportType FindSupportTypeByName(string supportTypeName)
        {
            SupportType f1 = _context.SupportTypes.Where(x => x.SupportTypeName.ToUpper().StartsWith(supportTypeName.ToUpper())).FirstOrDefault();
            SupportType f2 = (from cf in _context.SupportTypes
                              where cf.SupportTypeName.ToUpper().StartsWith(supportTypeName.ToUpper())
                              select cf).FirstOrDefault();

            return(f2);
        }
コード例 #12
0
 void deleteSupport()
 {
     Destroy(sup);
     Main.reactions.Remove(x);
     Main.reactions.Remove(y);
     x       = null;
     y       = null;
     supType = SupportType.NONE;
 }
コード例 #13
0
 void addMovableSupport()
 {
     supType            = type;
     sup                = (GameObject)Instantiate(prefabMovable, transform.position, transform.rotation);
     y                  = new Reaction(this, Reaction.Direction.Y);
     sup.transform.name = this.transform.name + "Movable";
     Main.reactions.Add(y);
     sup.transform.SetParent(Main.Supports.transform);
 }
コード例 #14
0
 private void LogSupportTicket(UserModel user, string message, SupportType supportType)
 {
     this.supportApi.CreateSupportTicketOnTrello(new SupportTicketModel()
                                                 {
                                                     Message = String.Format("Support Ticket Logged From Bot: {0}", message),
                                                     Subject = String.Format("Support Ticket from {0}", user.DisplayName),
                                                     Status = 1,
                                                     Type = (int)supportType
                                                 });
 }
コード例 #15
0
 public ActionResult Edit([Bind(Include = "Id,SupportName,CostPerSupport,Minutes,TimeToAction,DateTimeSpanId,Description")] SupportType supportType, int TimeSpanOption)
 {
     if (ModelState.IsValid)
     {
         supportType.DateTimeSpanId  = TimeSpanOption;
         db.Entry(supportType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supportType));
 }
コード例 #16
0
ファイル: GameMode.cs プロジェクト: 737871854/FireMen2
    /// <summary>
    /// 支援飞机
    /// </summary>
    /// <param name="index"></param>
    private void OnSupport(int index)
    {
        if (mSupportType != SupportType.Support)
        {
            return;
        }

        mSupportType = SupportType.Normal;
        Player player = ioo.playerManager.GetPlayer(index);
        //ScenesManager.Instance.OnCallSupport(player);
    }
コード例 #17
0
 void addHingedSupport()
 {
     supType            = type;
     sup                = (GameObject)Instantiate(prefabHinged, transform.position, transform.rotation);
     x                  = new Reaction(this, Reaction.Direction.X);
     y                  = new Reaction(this, Reaction.Direction.Y);
     sup.transform.name = this.transform.name + "Hinged";
     Main.reactions.Add(x);
     Main.reactions.Add(y);
     sup.transform.SetParent(Main.Supports.transform);
 }
コード例 #18
0
        public JsonResult OnCreate(string pTieuDe, int?pUuTien)
        {
            var mSupportType = new SupportType()
            {
                Date = DateTime.Now, Number = pUuTien, Name = pTieuDe
            };

            MpStartEntities.AddToSupportType(mSupportType);
            MpStartEntities.SaveChanges();
            return(Json(new { code = 1, message = "Lưu loại hỗ trợ thành công." }));
        }
コード例 #19
0
        public async Task <IActionResult> Create([Bind("Id,Defenition")] SupportType supportType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supportType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(supportType));
        }
コード例 #20
0
        public ActionResult Create([Bind(Include = "Id,SupportName,CostPerSupport,Minutes,TimeToAction,DateTimeSpanId,Description")] SupportType supportType, int TimeSpanOption)
        {
            if (ModelState.IsValid)
            {
                supportType.DateTimeSpanId = TimeSpanOption;
                db.MySupportTypeContext.Add(supportType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supportType));
        }
コード例 #21
0
        public async Task <string> Create(ulong userId, string title, string text, SupportType supportType, int atleastAdminLevel)
        {
            var request = new CreateRequest
            {
                UserId            = userId,
                Title             = title,
                Text              = text,
                Type              = (int)supportType,
                AtleastAdminLevel = atleastAdminLevel
            };
            var reply = await _client.CreateAsync(request);

            return(reply.Message);
        }
コード例 #22
0
        // GET: SupportTypes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupportType supportType = db.MySupportTypeContext.Find(id);

            if (supportType == null)
            {
                return(HttpNotFound());
            }
            return(View(supportType));
        }
コード例 #23
0
 public void Update(SupportType obj, out OperationResult operationResult)
 {
     lock (Lock)
     {
         if (obj == null)
         {
             operationResult = new OperationResult {
                 Type = OperationResult.ResultType.Warning
             };
             return;
         }
         Common.Instance.Update
             (obj, objs => objs.SupportTypeId == obj.SupportTypeId && objs.LanguageId == obj.LanguageId, out operationResult);
     }
 }
コード例 #24
0
        public void UpdateSupportTypeFor(PackageStatistic stat, SupportType supportType)
        {
            const string sql = "UPDATE dbo.[PackageStatistics] SET LatestSupportType = @LatestSupportType WHERE Name = @Name";

            using (var con = new SqlConnection(_connectionString))
            {
                con.Open();
                using (var cmd = new SqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("Name", stat.Name);
                    cmd.Parameters.AddWithValue("LatestSupportType", supportType.ToString());
                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #25
0
 public void Insert(SupportType obj, out OperationResult operationResult)
 {
     lock (Lock)
     {
         if (obj == null)
         {
             operationResult = new OperationResult {
                 Type = OperationResult.ResultType.Warning
             };
         }
         else
         {
             Common.Instance.Insert(obj, out operationResult);
         }
     }
 }
コード例 #26
0
        private async Task CreateRequest(string title, string text, SupportType supportType, int atLeastAdminLevel)
        {
            await Context.Message.DeleteAsync();

            if (_guildEntity is null)
            {
                return;
            }


            if (title.Length == 0)
            {
                await Context.User.SendMessageAsync($"The title has to contain atleast {_guildEntity.SupportRequestMinTitleLength} characters." +
                                                    $"\nDid you maybe forget to use quotation marks for the title?");

                return;
            }

            if (title.Length < _guildEntity.SupportRequestMinTitleLength)
            {
                await Context.User.SendMessageAsync($"The title has to contain atleast {_guildEntity.SupportRequestMinTitleLength} characters." +
                                                    $"\nDid you maybe forget to use quotation marks for the title?");

                return;
            }
            if (title.Length > _guildEntity.SupportRequestMaxTitleLength)
            {
                await Context.User.SendMessageAsync($"The title can be a maximum of {_guildEntity.SupportRequestMaxTitleLength} characters long.");

                return;
            }

            if (title.Length < _guildEntity.SupportRequestMinTextLength)
            {
                await Context.User.SendMessageAsync($"The text has to contain atleast {_guildEntity.SupportRequestMinTextLength} characters.");

                return;
            }
            if (title.Length > _guildEntity.SupportRequestMaxTextLength)
            {
                await Context.User.SendMessageAsync($"The text can be a maximum of {_guildEntity.SupportRequestMaxTextLength} characters long.");

                return;
            }

            await _supportRequestHandler.CreateRequest(Context.Guild, Context.User, Context.User.Nickname, title, text, supportType, atLeastAdminLevel, true);
        }
コード例 #27
0
ファイル: SupportRepository.cs プロジェクト: war-man/Cfood
        public SupportType LaySupportTypeTheoId(int pId)
        {
            SupportType mSupportType = null;

            try
            {
                //lay danh sach tin moi dang nhat
                mSupportType = (from p in entities.SupportType
                                where p.ID == pId
                                select p).FirstOrDefault();
                return(mSupportType);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #28
0
        protected MiningParams(MiningParams another)
        {
            subtreeType = another.SubtreeType;

            mineOrdered = another.MineOrdered;

            mineFrequent = another.MineFrequent;
            mineClosed   = another.MineClosed;
            mineMaximal  = another.MineMaximal;

            supportType          = another.SupportType;
            thresholdRoot        = another.ThresholdRoot;
            thresholdTransaction = another.ThresholdTransaction;

            separator       = another.separator;
            backTrackSymbol = string.Copy(another.backTrackSymbol);
        }
コード例 #29
0
    public static void Add(UnturnedPlayer player, SupportType type, string text)
    {
        SupportList.Add(new SupportData(player, type, text));

        foreach (var Admin in Provider.clients)
        {
            if (Permission.hasPermission(UnturnedPlayer.FromSteamPlayer(Admin), Main.Instance.Configuration.Instance.PermissionSetting.permissionsConfig.CommandNotification))
            {
                var AdminToPlayer = UnturnedPlayer.FromSteamPlayer(Admin);

                if (AdminToPlayer.CSteamID != player.CSteamID)
                {
                    SupportUI.Sound(AdminToPlayer, SoundType.Sending);
                    Message.Send(AdminToPlayer, "SendingNotification", "{Player}", player.CharacterName);
                }
            }
        }
    }
コード例 #30
0
        public ActionResult NewSupportType([FromBody] SupportType[] supportTypes)
        {
            string result = "Sistem xətası";

            try
            {
                SupportType supportType = new SupportType();
                supportType.Defenition = supportTypes[0].Defenition;
                _context.Add(supportType);
                _context.SaveChanges();
                result = "Əməliyyat uğurla tamamlandı!";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }


            return(Json(result));
        }
コード例 #31
0
        private static string SupportTypeToLabel(SupportType supportType)
        {
            switch (supportType)
            {
            case SupportType.NotFound:
            case SupportType.Supported:
            case SupportType.PreRelease:
            case SupportType.Error:
            case SupportType.NoDotNetLibraries:
            case SupportType.InvestigationTarget:
                return(supportType.ToString());

            case SupportType.Unsupported:
            case SupportType.KnownReplacementAvailable:
                return("Unsupported");

            default:
                throw new ArgumentOutOfRangeException(nameof(supportType), supportType, null);
            }
        }
コード例 #32
0
        /// <summary>
        /// Grabs all available hooks and executes them to hook into the target assembly
        /// </summary>
        public void InjectHooks(SupportType currentType)
        {
            /*
             * Gather all methods marked with the OTAPatchAttribute.
             * These must then be fitered with the current SupportType, and order as appropriate.
             */
            var hooks = typeof(Injector)
                .GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
                .Select(x => new
                {
                    Attribute = x.GetCustomAttribute<OTAPatchAttribute>(false),

                    Method = x
                })
                .Where(z => z.Attribute != null && (z.Attribute.SupportedTypes & currentType) != 0)
                .OrderBy(o => o.Attribute.Order)
                .ToArray();

            //Run the patches
            var dbg = new System.Diagnostics.Stopwatch();
            var col = Console.ForegroundColor;
            for (var x = 0; x < hooks.Length; x++)
            {
                dbg.Reset();
                Console.Write("\t{0}/{1} - {2}", x + 1, hooks.Length, hooks[x].Attribute.Text);

                dbg.Start();
                hooks[x].Method.Invoke(this, null); //TODO get a boolean from this to determine the OK/FAIL
                dbg.Stop();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write(" [OK] ");
                Console.ForegroundColor = col;
                Console.WriteLine("Took {0}ms", dbg.ElapsedMilliseconds);
            }
            Console.ResetColor();
        }
コード例 #33
0
        private void WriteSupportPolygons(SliceDataStorage storage, GCodePlanner gcodeLayer, int layerIndex, ConfigSettings config, Polygons supportPolygons, SupportType interfaceLayer)
        {
            for (int volumeIndex = 0; volumeIndex < storage.volumes.Count; volumeIndex++)
            {
                SliceLayer layer = storage.volumes[volumeIndex].layers[layerIndex];
                for (int partIndex = 0; partIndex < layer.parts.Count; partIndex++)
                {
                    supportPolygons = supportPolygons.CreateDifference(layer.parts[partIndex].TotalOutline.Offset(config.supportXYDistance_um));
                }
            }

            //Contract and expand the support polygons so small sections are removed and the final polygon is smoothed a bit.
            supportPolygons = supportPolygons.Offset(-config.extrusionWidth_um * 1);
            supportPolygons = supportPolygons.Offset(config.extrusionWidth_um * 1);

            List<Polygons> supportIslands = supportPolygons.CreateLayerOutlines(PolygonsHelper.LayerOpperation.EvenOdd);
            PathOrderOptimizer islandOrderOptimizer = new PathOrderOptimizer(gcode.GetPositionXY());

            for (int islandIndex = 0; islandIndex < supportIslands.Count; islandIndex++)
            {
                islandOrderOptimizer.AddPolygon(supportIslands[islandIndex][0]);
            }
            islandOrderOptimizer.Optimize();

            for (int islandIndex = 0; islandIndex < supportIslands.Count; islandIndex++)
            {
                Polygons island = supportIslands[islandOrderOptimizer.bestPolygonOrderIndex[islandIndex]];
                Polygons supportLines = new Polygons();
                if (config.supportLineSpacing_um > 0)
                {
                    switch (interfaceLayer)
                    {
                        case SupportType.Interface:
                            Infill.GenerateLineInfill(config, island, ref supportLines, config.supportInfillStartingAngle + 90, config.extrusionWidth_um);
                            break;

                        case SupportType.General:
                            switch (config.supportType)
                            {
                                case ConfigConstants.SUPPORT_TYPE.GRID:
                                    Infill.GenerateGridInfill(config, island, ref supportLines, config.supportInfillStartingAngle, config.supportLineSpacing_um);
                                    break;

                                case ConfigConstants.SUPPORT_TYPE.LINES:
                                    Infill.GenerateLineInfill(config, island, ref supportLines, config.supportInfillStartingAngle, config.supportLineSpacing_um);
                                    break;
                            }
                            break;

                        default:
                            throw new NotImplementedException();
                    }
                }

                if (config.avoidCrossingPerimeters)
                {
                    gcodeLayer.SetOuterPerimetersToAvoidCrossing(island);
                }

                switch (interfaceLayer)
                {
                    case SupportType.Interface:
                        gcodeLayer.WritePolygonsByOptimizer(supportLines, supportInterfaceConfig);
                        break;

                    case SupportType.General:
                        if (config.supportType == ConfigConstants.SUPPORT_TYPE.GRID)
                        {
                            gcodeLayer.WritePolygonsByOptimizer(island, supportNormalConfig);
                        }
                        gcodeLayer.WritePolygonsByOptimizer(supportLines, supportNormalConfig);
                        break;

                    default:
                        throw new NotImplementedException();
                }

                gcodeLayer.SetOuterPerimetersToAvoidCrossing(null);
            }
        }
コード例 #34
0
        //        /// <summary>
        //        /// Hooks the console title.
        //        /// </summary> TODO: this might actually be needed to avoid using the XNA shims
        //        public void HookConsoleTitle()
        //        {
        //            var method = Terraria.Main.Methods.Single(x => x.Name == "DedServ");
        //            var callback = API.GameWindow.Methods.First(m => m.Name == "SetTitle");
        //
        ////            var il = method.Body.GetILProcessor();
        //
        //            var replacement = _asm.MainModule.Import(callback);
        //            foreach (var ins in method.Body.Instructions
        //                .Where(x => x.OpCode == OpCodes.Call
        //                    && x.Operand is MethodReference
        //                    && (x.Operand as MethodReference).DeclaringType.FullName == "System.Console"
        //                    && (x.Operand as MethodReference).Name == "set_Title"))
        //            {
        //                ins.Operand = replacement;
        //            }
        //        }
        /// <summary>
        /// Hooks start of the application for plugins to be loaded
        /// </summary>
        /// <param name="mode">Mode.</param>
        public void HookProgramStart(SupportType mode)
        {
            if (mode == SupportType.Server)
            {
                var method = Terraria.WindowsLaunch.Methods.Single(x => x.Name == "Main");
                var callback = API.MainCallback.Methods.First(m => m.Name == "OnProgramStarted");

                var il = method.Body.GetILProcessor();

                var ret = il.Create(OpCodes.Ret);
                var call = il.Create(OpCodes.Call, _asm.MainModule.Import(callback));
                var first = method.Body.Instructions.First();

                il.InsertBefore(first, il.Create(OpCodes.Ldarg_0));
                il.InsertBefore(first, call);
                il.InsertBefore(first, il.Create(OpCodes.Brtrue_S, first));
                il.InsertBefore(first, ret);
            }
            else if (mode == SupportType.Client)
            {
                var method = Terraria.Program.Methods.Single(x => x.Name == "LaunchGame");
                var callback = API.MainCallback.Methods.First(m => m.Name == "OnProgramStarted");

                var il = method.Body.GetILProcessor();

                var ret = il.Create(OpCodes.Ret);
                var call = il.Create(OpCodes.Call, _asm.MainModule.Import(callback));
                var first = method.Body.Instructions.First();

                il.InsertBefore(first, il.Create(OpCodes.Ldarg_0));
                il.InsertBefore(first, call);
                il.InsertBefore(first, il.Create(OpCodes.Brtrue_S, first));
                il.InsertBefore(first, ret);
            }
        }
コード例 #35
0
        //        /// <summary>
        //        /// Allows eclipse to be started at any time
        //        /// </summary>
        //        //TODO mark as a feature, not a requirement for a functional OTA
        //        public void HookEclipse()
        //        {
        //            var mth = Terraria.Main.Methods.Single(x => x.Name == "UpdateTime");
        //            var field = API.MainCallback.Fields.Single(x => x.Name == "StartEclipse");
        //
        //            var il = mth.Body.GetILProcessor();
        //            var start = il.Body.Instructions.Single(x =>
        //                x.OpCode == OpCodes.Ldsfld
        //                            && x.Operand is FieldReference
        //                            && (x.Operand as FieldReference).Name == "hardMode"
        //                            && x.Previous.OpCode == OpCodes.Call
        //                            && x.Previous.Operand is MethodReference
        //                            && (x.Previous.Operand as MethodReference).Name == "StartInvasion"
        //                        );
        //
        //            //Preserve
        //            var old = start.Operand as FieldReference;
        //
        //            //Replace with ours to keep the IL inline
        //            start.Operand = _asm.MainModule.Import(field);
        //            //Readd the preserved
        //            il.InsertAfter(start, il.Create(OpCodes.Ldsfld, old));
        //
        //            //Now find the target instruction if the value is true
        //            var startEclipse = il.Body.Instructions.Single(x =>
        //                x.OpCode == OpCodes.Stsfld
        //                                   && x.Operand is FieldReference
        //                                   && (x.Operand as FieldReference).Name == "eclipse"
        //                                   && x.Next.OpCode == OpCodes.Ldsfld
        //                                   && x.Next.Operand is FieldReference
        //                                   && (x.Next.Operand as FieldReference).Name == "eclipse"
        //                               ).Previous;
        //            il.InsertAfter(start, il.Create(OpCodes.Brtrue, startEclipse));
        //
        //            //Since all we care about is setting the StartEclipse to TRUE; we need to be able to disable once done.
        //            il.InsertAfter(startEclipse.Next, il.Create(OpCodes.Stsfld, start.Operand as FieldReference));
        //            il.InsertAfter(startEclipse.Next, il.Create(OpCodes.Ldc_I4_0));
        //        }
        //        public void HookBloodMoon()
        //        {
        //            var mth = Terraria.Main.Methods.Single(x => x.Name == "UpdateTime");
        //            var field = API.MainCallback.Fields.Single(x => x.Name == "StartBloodMoon");
        //            //return;
        //            var il = mth.Body.GetILProcessor();
        //            var start = il.Body.Instructions.Single(x =>
        //                x.OpCode == OpCodes.Ldsfld
        //                            && x.Operand is FieldReference
        //                            && (x.Operand as FieldReference).Name == "spawnEye"
        //                            && x.Next.Next.OpCode == OpCodes.Ldsfld
        //                            && x.Next.Next.Operand is FieldReference
        //                            && (x.Next.Next.Operand as FieldReference).Name == "moonPhase"
        //                        );
        //
        //            //Preserve
        //            var old = start.Operand as FieldReference;
        //            var target = start.Next as Instruction;
        //
        //            //Replace with ours to keep the IL inline
        //            start.Operand = _asm.MainModule.Import(field);
        //            //Readd the preserved
        //            il.InsertAfter(start, il.Create(OpCodes.Ldsfld, old));
        //
        //            //Now find the target instruction if the value is true
        //            Instruction begin = start.Next;
        //            var i = 12;
        //            while (i > 0)
        //            {
        //                i--;
        //                begin = begin.Next;
        //            }
        //            il.InsertAfter(start, il.Create(OpCodes.Brtrue, begin));
        //
        //            //Since all we care about is setting the StartBloodMoon to TRUE; we need to be able to disable once done.
        //            var startBloodMoon = il.Body.Instructions.Single(x =>
        //                x.OpCode == OpCodes.Ldsfld
        //                                     && x.Operand is FieldReference
        //                                     && (x.Operand as FieldReference).Name == "bloodMoon"
        //                                     && x.Next.Next.OpCode == OpCodes.Ldsfld
        //                                     && x.Next.Next.Operand is FieldReference
        //                                     && (x.Next.Next.Operand as FieldReference).Name == "netMode"
        //                                 );
        //            il.InsertAfter(startBloodMoon.Next, il.Create(OpCodes.Stsfld, start.Operand as FieldReference));
        //            il.InsertAfter(startBloodMoon.Next, il.Create(OpCodes.Ldc_I4_0));
        //        }
        /// <summary>
        /// Saves the patched assembly
        /// </summary>
        /// <param name="mode">Mode.</param>
        /// <param name="fileName">File name.</param>
        /// <param name="apiBuild">API build.</param>
        /// <param name="tdsmUID">Tdsm user interface.</param>
        /// <param name="name">Name.</param>
        /// <param name="swapOTA">If set to <c>true</c> swap OT.</param>
        public void Save(SupportType mode, string fileName, int apiBuild, string tdsmUID, string name, bool swapOTA = false)
        {
            if (mode == SupportType.Server)
            {
                //Ensure the name is updated to the new one
                _asm.Name = new AssemblyNameDefinition(name, new Version(0, 0, apiBuild, 0));
                _asm.MainModule.Name = fileName;

                //Change the uniqueness from what Terraria has, to something different (that way vanilla isn't picked up by assembly resolutions)
                //                var g = _asm.CustomAttributes.Single(x => x.AttributeType.Name == "GuidAttribute");

                for (var x = 0; x < _asm.CustomAttributes.Count; x++)
                {
                    if (_asm.CustomAttributes[x].AttributeType.Name == "GuidAttribute")
                    {
                        _asm.CustomAttributes[x].ConstructorArguments[0] =
                        new CustomAttributeArgument(_asm.CustomAttributes[x].ConstructorArguments[0].Type, tdsmUID);
                    }
                    else if (_asm.CustomAttributes[x].AttributeType.Name == "AssemblyTitleAttribute")
                    {
                        _asm.CustomAttributes[x].ConstructorArguments[0] =
                        new CustomAttributeArgument(_asm.CustomAttributes[x].ConstructorArguments[0].Type, name);
                    }
                    else if (_asm.CustomAttributes[x].AttributeType.Name == "AssemblyProductAttribute")
                    {
                        _asm.CustomAttributes[x].ConstructorArguments[0] =
                        new CustomAttributeArgument(_asm.CustomAttributes[x].ConstructorArguments[0].Type, name);
                    }
                    //else if (_asm.CustomAttributes[x].AttributeType.Name == "AssemblyFileVersionAttribute")
                    //{
                    //    _asm.CustomAttributes[x].ConstructorArguments[0] =
                    //        new CustomAttributeArgument(_asm.CustomAttributes[x].ConstructorArguments[0].Type, "1.0.0.0");
                    //}
                }
            }

            //            foreach (var mod in _asm.Modules)
            //            {
            //                for (var x = mod.Resources.Count - 1; x >= 0; x--)
            //                {
            //                    mod.Resources.RemoveAt(x);
            //                }
            //            }

            //_asm.Write(fileName);
            using (var fs = File.OpenWrite(fileName))
            {
                _asm.Write(fs);
                fs.Flush();
                fs.Close();
            }

            if (swapOTA) SwapOTAReferences();
        }
コード例 #36
0
 /// <summary>
 /// Onward from this specific instruction is client code, and code afterwards returns for the server. (Odd i know)
 /// However, if we dont return and skipMenu is set, the server will crash
 /// </summary>
 public void SkipMenu(SupportType mode)
 {
     if (mode != SupportType.Server) throw new Exception("SkipMenu is a server-only fix");
     var initialise = Terraria.Main.Methods.Single(x => x.Name == "Initialize");
     var loc = initialise.Body.Instructions
         .Where(x => x.OpCode == OpCodes.Ldsfld && x.Operand is FieldDefinition)
               //.Select(x => x.Operand as FieldDefinition)
         .Single(x => (x.Operand as FieldDefinition).Name == "skipMenu");
     var il = initialise.Body.GetILProcessor();
     il.InsertBefore(loc, il.Create(OpCodes.Ret));
 }
コード例 #37
0
 public OTAPatchAttribute(SupportType supportedTypes, string text, int order = 100)
 {
     this.SupportedTypes = supportedTypes;
     this.Text = text;
     this.Order = order;
 }
コード例 #38
0
 public NugetPackage(string id, IReadOnlyList<string> dependencies, SupportType supportType)
 {
     Id = id;
     Dependencies = dependencies;
     SupportType = supportType;
 }