private void AddPrerequisiteInformation(int newUpdateIndex, Identity newUpdateIdentity, XDocument updateXml) { var prerequisites = Prerequisite.FromXml(updateXml); if (prerequisites.Count > 0) { // Save this for later when we use prerequisites to resolve product and classification AddedPrerequisites.Add(newUpdateIdentity, prerequisites); } foreach (var prereq in prerequisites) { if (prereq is Simple) { PrerequisitesList.Add(new KeyValuePair <int, List <Guid> >(newUpdateIndex, new List <Guid>() { (prereq as Simple).UpdateId })); } else if (prereq is AtLeastOne) { PrerequisitesList.Add( new KeyValuePair <int, List <Guid> >( newUpdateIndex, new List <Guid>((prereq as AtLeastOne).Simple.Select(s => s.UpdateId)))); if ((prereq as AtLeastOne).IsCategory) { // Add an empty guid at the end to mark that this atLeast group is a category group PrerequisitesList.Last().Value.Add(Guid.Empty); } } } }
public static void AddPrerequisite(this ModelBuilder builder, Prerequisite prerequisite, BasePrerequisiteBinding binding) { binding.PrerequisiteId = prerequisite.Id; prerequisite.BindingId = binding.Id; builder.AddData(binding.GetType(), binding); switch (prerequisite) { case ChoicePrerequisite choicePrerequisite: foreach (Prerequisite innerPrerequisite in choicePrerequisite.Choices) { builder.AddPrerequisite(innerPrerequisite, new ChoicePrerequisiteBinding { Id = innerPrerequisite.Id, ChoiceId = choicePrerequisite.Id }); } choicePrerequisite.Choices = Array.Empty <Prerequisite>(); break; case CombinedPrerequisite combinedPrerequisite: foreach (Prerequisite innerPrerequisite in combinedPrerequisite.Entries) { builder.AddPrerequisite(innerPrerequisite, new CombinedPrerequisiteBinding { Id = innerPrerequisite.Id, CombinationId = combinedPrerequisite.Id }); } combinedPrerequisite.Entries = Array.Empty <Prerequisite>(); break; } builder.Entity(prerequisite.GetType()).HasData(prerequisite); }
public JsonResponse Create(Prerequisite prerequisite) { if (prerequisite == null) { return(new JsonResponse { Result = "Failed", Message = "Create requires an instance of PreRequisites" }); } if (!ModelState.IsValid) { return(new JsonResponse { Result = "Failed", Message = "Model state is invalid. See data.", Error = ModelState }); } db.Prerequisites.Add(prerequisite); db.SaveChanges(); return(new JsonResponse { Message = "Create successful.", Data = prerequisite }); }
static void Postfix(Prerequisite __instance, ref bool __result, ref bool?__state) { if (__state ?? IsAvailable(__instance.GetType())) { __result = true; } }
public void RepairSets(FocusModel focus, List <FocusModel> fociList) { //Relative ids if (focus.CoordinatesRelativeTo != null) { CoordinatesRelativeTo = fociList.FirstOrDefault(f => f.UniqueName == focus.CoordinatesRelativeTo.UniqueName); } //Prerequisites foreach (PrerequisitesSetModel set in focus.Prerequisite) { //Add the linked focus PrerequisitesSetModel prerequiste = new PrerequisitesSetModel( fociList.FirstOrDefault(f => f.UniqueName == set.Focus.UniqueName)); //Run through all the parents and add them foreach (FocusModel parent in set.FociList) { prerequiste.FociList.Add( fociList.FirstOrDefault(f => f.UniqueName == parent.UniqueName)); } Prerequisite.Add(prerequiste); } //Mutually exclusives foreach (MutuallyExclusiveSetModel set in focus.MutualyExclusive) { //Create the set with both foci MutualyExclusive.Add(new MutuallyExclusiveSetModel( fociList.FirstOrDefault(f => f.UniqueName == set.Focus1.UniqueName), fociList.FirstOrDefault(f => f.UniqueName == set.Focus2.UniqueName))); } }
public void MergeFrom(ProfessionNodeLevel other) { if (other == null) { return; } if (other.BuffGmtId.Length != 0) { BuffGmtId = other.BuffGmtId; } if (other.prerequisite_ != null) { if (prerequisite_ == null) { Prerequisite = new global::WUProtos.Data.Requirements(); } Prerequisite.MergeFrom(other.Prerequisite); } if (other.cost_ != null) { if (cost_ == null) { Cost = new global::WUProtos.Data.Loot.LootCollection(); } Cost.MergeFrom(other.Cost); } mapAbilities_.Add(other.mapAbilities_); if (other.RankPoints != 0) { RankPoints = other.RankPoints; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
/** * Arrive in the node: * - Interact with the prop if it's enabled; * - Make this object interactable if prerequisite is met. */ public override void Arrive() { if (inter != null && inter.enabled) { inter.Interact(); return; } PathReactor path = GetComponent <PathReactor>(); if (path == null || path.switcher.state) { base.Arrive(); } // Make this object interactable if prerequisite is met if (inter != null) { Prerequisite pre = GetComponent <Prerequisite>(); if (pre && !inter.inspectObject && !pre.Complete) { return; } col.enabled = true; inter.enabled = true; changeMouseIcon(); } }
public IHttpActionResult PutPrerequisite(int id, Prerequisite prerequisite) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prerequisite.Id) { return(BadRequest()); } db.Entry(prerequisite).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PrerequisiteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public override int GetHashCode() { int hash = 1; if (BuffGmtId.Length != 0) { hash ^= BuffGmtId.GetHashCode(); } if (prerequisite_ != null) { hash ^= Prerequisite.GetHashCode(); } if (cost_ != null) { hash ^= Cost.GetHashCode(); } hash ^= mapAbilities_.GetHashCode(); if (RankPoints != 0) { hash ^= RankPoints.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public ActionResult Create(CourseViewModel courseViewModel) { Course course = courseViewModel.Course; IEnumerable <int> prerequisites = courseViewModel.PrerequisiteIds; try { course = courseService.Add(course); if (prerequisites != null) { foreach (int prerequisiteId in prerequisites) { Prerequisite prerequisite = new Prerequisite { CourseId = course.Id, CoursePrerequisiteId = prerequisiteId }; prerequisiteService.Add(prerequisite); } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View(courseViewModel)); } }
/// <summary> /// To create a category /// </summary> /// <param name="categoryObj">Category Object</param> public void Post(Prerequisite categoryObj) { try { ServiceFactory.GetPrerequisite().Create(categoryObj); } catch (Exception ex) {} }
public ActionResult DeleteConfirmed(int id) { Prerequisite prerequisite = db.Prerequisites.Find(id); db.Prerequisites.Remove(prerequisite); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Configure(Action<Prerequisite> action) { var prerequisite = new Prerequisite(); action(prerequisite); _prerequisites.Add(prerequisite); _rules.Add(prerequisite.Rule); }
public static bool AddPrereq(Prerequisite prereq) { using (var connection = DbConn.GetConnection()) { connection.Open(); return(AddPrereq(connection, prereq)); } }
static bool Prefix(Prerequisite __instance, ref bool?__state) { if ((__state = IsAvailable(__instance.GetType())).Value) { return(false); } return(true); }
/// <summary> /// To Update a category /// </summary> /// <param name="id">CategoryId</param> /// <param name="categoryObj">category Object</param> public void Put(string id, Prerequisite categoryObj) { try { categoryObj.Id = new Guid(id); ServiceFactory.GetPrerequisite().Update(categoryObj); } catch (Exception exp) {} }
/** *Deafult object interaction */ public virtual void Interact() { pre = GetComponent<Prerequisite>(); if (pre && !pre.Complete) { Debug.Log(message); interact = false; return; } interact = true; }
internal static Prerequisite Read(Stream input, Endian endian) { var instance = new Prerequisite(); instance.Name = input.ReadValueU32(endian); instance.RewardIndex = input.ReadValueS32(endian); instance.Tag = input.ReadValueU32(endian); return(instance); }
public static void UpdatePrerequisite(Prerequisite p) { using (IDbConnection conn = new SqlConnection(Connection)) { string sql = "UPDATE PREREQUISITE SET parent_id = @ParentId, child_id = @ChildId " + "WHERE prerequisite_id = @PrerequisiteId;"; conn.Query(sql, p); } }
public ActionResult Edit([Bind(Include = "ID,PrereqName,BaseCourse_PreReqIsFor_ID")] Prerequisite prerequisite) { if (ModelState.IsValid) { db.Entry(prerequisite).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BaseCourse_PreReqIsFor_ID = new SelectList(db.BaseCourses, "ID", "Name", prerequisite.BaseCourse_PreReqIsFor_ID); return(View(prerequisite)); }
/** * Deafult object interaction */ public virtual void Interact() { pre = GetComponent <Prerequisite>(); if (pre && !pre.Complete) { Debug.Log(message); interact = false; return; } interact = true; }
public IHttpActionResult GetPrerequisite(int id) { Prerequisite prerequisite = db.Prerequisites.Find(id); if (prerequisite == null) { return(NotFound()); } return(Ok(prerequisite)); }
public IHttpActionResult PostPrerequisite(Prerequisite prerequisite) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Prerequisites.Add(prerequisite); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = prerequisite.Id }, prerequisite)); }
public ActionResult AddPreReq(int?id, string preReqName) { BaseCourse bc = db.BaseCourses.Find(id); Prerequisite prereq = new Prerequisite(); prereq.BaseCourse_PreReqIsFor = bc; prereq.PrereqName = preReqName; db.Prerequisites.Add(prereq); bc.Prerequisites.Add(prereq); db.Entry(bc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = bc.ID })); }
public void Delete() { //Kill the focus sets foreach (MutuallyExclusiveSet set in MutualyExclusive.ToList()) { set.DeleteSetRelations(); } foreach (PrerequisitesSet set in Prerequisite.ToList()) { set.DeleteSetRelations(); } Messenger.Default.Send(new NotificationMessage(this, "DeleteFocus")); }
public ResearchTechStep(TechType target, IEnumerable <Prerequisite> extraPrerequisites) { Research = TechTypes.All[target]; ResearchedBy = Research.WhatResearches.Type; var defaultPrerequisites = new Prerequisite[] { new BuildingExistsPrerequisite(ResearchedBy), new ResourcePrerequisite(Research.Price.Minerals, Research.Price.Gas) }; Prerequisites = defaultPrerequisites.Concat(extraPrerequisites).ToList(); Target = target; }
// GET: Prerequisites/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Prerequisite prerequisite = db.Prerequisites.Find(id); if (prerequisite == null) { return(HttpNotFound()); } return(View(prerequisite)); }
public RegularLine(XmlElement element, LineCatalogue catalogue, Conversation conversation) : base(element, catalogue, conversation) { text = element.GetAttribute("text"); speakerName = element.GetAttribute("speaker"); if (speakerName.Equals("")){ speakerName = "Abby"; } prerequisite = new Prerequisite(element.GetAttribute("prerequisite"), speakerName, conversation); consequence = new Consequence(element.GetAttribute("consequence"), speakerName, conversation); cameraAngle = CameraAngle.GetCameraAngle(element.GetAttribute("camera_angle")); emotion = Emotion.GetEmotion(element.GetAttribute("expression")); id = element.GetAttribute("id"); }
public ResearchUpgradeStep(UpgradeType target, IEnumerable <Prerequisite> extraPrerequisites) { Research = UpgradeTypes.All[target]; ResearchedBy = Research.WhatUpgrades.Type; var defaultPrerequisites = new Prerequisite[] { new BuildingExistsPrerequisite(ResearchedBy), new ResourcePrerequisite(Research.MineralPrice(0), Research.GasPrice(0)), }; Prerequisites = defaultPrerequisites.Concat(extraPrerequisites).ToList(); Target = target; }
/** * Move to the next Scene * - Plays an animation if exists */ public override void Interact() { Prerequisite pre = GetComponent <Prerequisite>(); if (pre && !pre.Complete) { return; } //anim.Play("OpeningDoor", -1, 0f); anim.SetBool("Open", true); Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); GameManager.gm.currentLevel = nextLevel; StartCoroutine(LoadingScene()); }
private void unlockPredefinedDesigns(MainGame game) { var playerTechs = game.States.DevelopmentAdvances.Of[this.Player]; var techLevels = playerTechs.ToDictionary(x => x.Topic.IdCode, x => (double)x.Level); foreach (var predefDesign in game.Statics.PredeginedDesigns) { if (!this.Player.UnlockedDesigns.Contains(predefDesign) && Prerequisite.AreSatisfied(predefDesign.Prerequisites(game.Statics), 0, techLevels)) { this.Player.UnlockedDesigns.Add(predefDesign); makeDesign(game.Statics, game.States, predefDesign, techLevels); } } }
public IHttpActionResult DeletePrerequisite(int id) { Prerequisite prerequisite = db.Prerequisites.Find(id); if (prerequisite == null) { return(NotFound()); } db.Prerequisites.Remove(prerequisite); db.SaveChanges(); return(Ok(prerequisite)); }
static public void RestrictPrerequisites(BlueprintArchetype archetype, UnitDescriptor unit, LevelUpState state) { if (IgnorePrerequisites.Ignore) { return; } for (int index = 0; index < archetype.ComponentsArray.Length; ++index) { Prerequisite components = archetype.ComponentsArray[index] as Prerequisite; if ((bool)((UnityEngine.Object)components)) { components.Restrict((FeatureSelectionState)null, unit, state); } } }
/// <summary> /// Synchronously loads the binary /// </summary> /// <param name="filename"> </param> /// <param name="loadOptions"> </param> private Binary(string filename, BinaryLoadOptions loadOptions) { _loadOptions = loadOptions; Filename = filename; IsPEFile = new Prerequisite<bool>(LoadPEInfo); Is64Bit = Is64BitPE = new Prerequisite<bool>(LoadPEInfo); Is32BitPE = new Prerequisite<bool>(LoadPEInfo); IsManaged = new Prerequisite<bool>(LoadPEInfo); IsNative = new Prerequisite<bool>(LoadPEInfo); Is32Bit = new Prerequisite<bool>(LoadPEInfo); IsAnyCpu = new Prerequisite<bool>(LoadPEInfo, () => IsPEFile && (Is32BitPE && IsManaged && ((CorHeader.Flags & 0x0002) == 0))); IsConsoleApp = new Prerequisite<bool>(LoadPEInfo, () => IsPEFile && (NtHeader.SubSystem & 1) == 1); ExecutableInformation = new Prerequisite<ExecutableInfo>(LoadPEInfo, () => { var result = IsManaged ? ExecutableInfo.managed : ExecutableInfo.native; if (IsAnyCpu) { result |= ExecutableInfo.any; } else { switch (CoffHeader.Machine) { case 0x01c0: result |= ExecutableInfo.arm; break; case 0x014c: result |= ExecutableInfo.x86; break; case 0x0200: result |= ExecutableInfo.ia64; break; case 0x8664: result |= ExecutableInfo.x64; break; default: throw new CoAppException("Unrecognized Executable Machine Type."); } } return result; }); VersionInfo = new Prerequisite<FileVersionInfo>(LoadVersionInfo); MD5 = new Prerequisite<string>(LoadMD5); ILOnly = new Prerequisite<bool>(LoadManagedData); NativeResources = new Prerequisite<ResourceInfo>(LoadResourceData); Manifest = new Prerequisite<NativeManifest>(LoadManifestData); IsSigned = new Prerequisite<bool>(LoadSignature); IsValidSigned = new Prerequisite<bool>(LoadSignature); IsStrongNamed = new Prerequisite<bool>(LoadManagedData); AssemblyCulture = new Prerequisite<string>(LoadManagedData); AssemblyVersion = new Prerequisite<FourPartVersion>(LoadManagedData); IsDelaySigned = new Prerequisite<bool>(LoadManagedData); LoadData(); }