/** * Executing the upgrades */ public override void Execute(MinEventParams _params) { if (GameManager.Instance.World == null) { return; } World world = GameManager.Instance.World; for (int i = 0; i < this.targets.Count; i++) { Log.Out("Checking for Entity"); if (this.targets[i] as Entity == null) { Log.Out("Null, continue"); continue; } Vector3i currentPosition = new Vector3i(this.targets[i].GetPosition()); Dictionary <Vector3i, Block> blockPositions = CoordinateHelper.GetBlocksFromCoordinates(world, CoordinateHelper.GetCoOrdinatesAround(currentPosition, this.range)); foreach (KeyValuePair <Vector3i, Block> entry in blockPositions) { Block blockToCheck = entry.Value; if (blockToCheck.GetBlockName() != this.blockName) { continue; } BlockHelpers.DoBlockUpgrade(entry.Key, this.targets[i], this.requireMaterials); } } }
public ActionResult SubmitRating(RatingInputModel input) { if (ModelState.Keys.Contains("ReCaptcha") && ModelState["ReCaptcha"].Errors.Any()) { Response.TrySkipIisCustomErrors = true; Response.StatusCode = 400; return(Json("Captcha error - please complete the captcha and try again.")); } if (input.Valid && Request.UserHostAddress != null) { if (!input.Flags.Contains((int)EnumTag.Spotless) && (string.IsNullOrEmpty(input.Basically) || string.IsNullOrEmpty(input.RatingExplanation))) { Response.TrySkipIisCustomErrors = true; Response.StatusCode = 400; return(Json(System.Text.RegularExpressions.Regex.Unescape("When submitting a game without the 'Spotless'-tag, we require that you fill out the 'Basically' and 'Rating Explanation'-fields explaining the game's purchases in some detail. Please fill out those fields and submit again."))); } input.SubmitterIp = string.Empty; if (!Request.IsAuthenticated) { input.SubmitterIp = CryptHelper.Hash(Request.UserHostAddress); var blockStatus = BlockHelpers.GetBlockStatus(input.SubmitterIp); if (blockStatus == BlockType.ExplicitBlocked) { Response.TrySkipIisCustomErrors = true; Response.StatusCode = 400; return(Json("We have temporarily stopped your ability to send in submissions - come back tomorrow and you can submit ratings again.")); } if (blockStatus == BlockType.HiddenBlocked) { return(Json("Your submission has been accepted. It will go live as soon as it's been verified. Thank you for helping out!")); } } GameHelpers.SubmitRating(input, Request.IsAuthenticated); if (Request.IsAuthenticated) { return(Json("All clear.")); } return(Json("Your submission has been accepted. It will go live as soon as it's been verified. Thank you for helping out!")); } Response.TrySkipIisCustomErrors = true; Response.StatusCode = 400; // Bad Request return(Json("Something went wrong with your submission - most likely, you have a malformed URL in the \"Links\"-section. Please try again or contact one of the site administrators.")); }
public ActionResult ProcessButton(string buttonName) { string[] keys = buttonName.Split(':'); string buttonType = keys[0]; string buttonLevel = keys[1]; Guid ofReferenceId = Guid.Empty; Guid byAppUserId = Guid.Empty; Guid.TryParse(keys[2], out ofReferenceId); Guid.TryParse(keys[3], out byAppUserId); Guid byReferenceId = Guid.Empty; LevelEnum levelEnum = LevelEnum.User; //Set the byReference to be either the user, the user's branch or the user's company depending on level switch (buttonLevel) { case "company": levelEnum = LevelEnum.Company; byReferenceId = CompanyHelpers.GetCompanyForUser(byAppUserId).CompanyId; break; case "branch": levelEnum = LevelEnum.Branch; byReferenceId = AppUserHelpers.GetAppUser(byAppUserId).CurrentBranchId; break; case "user": levelEnum = LevelEnum.User; byReferenceId = byAppUserId; break; } switch (buttonType) { case "block": BlockHelpers.CreateBlock(levelEnum, ofReferenceId, byReferenceId, byAppUserId); break; case "friend": FriendHelpers.CreateFriend(levelEnum, ofReferenceId, byReferenceId, byAppUserId); break; case "group": //Need to go to Group screen to select a group or allow adding of a new group return(RedirectToAction("Create", "Groups", new { level = levelEnum, ofReferenceId = ofReferenceId, byReferenceId = byReferenceId, appUserid = byAppUserId })); } return(Json(new { success = true })); }
public T[] GetDevices <T>(IStructureData structure, string names) where T : class, IDevice => BlockHelpers.Devices(structure, names) .OfType <BlockData>() .Select(B => B?.GetStructure()?.GetDevice <T>(B.Position)) .Where(B => B != null) .ToArray();
public IBlockData[] DevicesOfType(IStructureData structure, DeviceTypeName deviceType) => BlockHelpers.DevicesOfType(structure, deviceType);
public IBlockData[] Devices(IStructureData structure, string names) => BlockHelpers.Devices(structure, names);
public ActionResult RemoveBlock(Guid blockId) { BlockHelpers.RemoveBlock(blockId); return(Json(new { success = true })); }