public ActionResult AssoEdit(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Rift rift = db.Rifts.Find(id); if (rift == null) { return(HttpNotFound()); } ViewBag.Races = db.Races.OrderBy(r => r.RaceName).ToList(); var selected = db.VarietyOfInhabitants.Where(v => v.RiftId == rift.RiftId).ToList(); List <AssoVar> theSelected = new List <AssoVar>(); foreach (VarietyOfInhabitant variety in selected) { AssoVar toAdd = new AssoVar(variety); theSelected.Add(toAdd); } var infoId = rift.InfoId; AssoRiftVM model = new AssoRiftVM { InfoId = infoId, RiftId = rift.RiftId, Submit = "Save", Assos = theSelected, Name = rift.Nickname }; return(View(model)); }
public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); Rift rift = entity.GetOrCreate <Rift>("Rift"); VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, false, false, null); attachable.Enabled.Value = true; VoxelAttachable.BindTarget(entity, rift.Position); this.SetMain(entity, main); PointLight light = entity.GetOrCreate <PointLight>(); light.Color.Value = new Vector3(1.2f, 1.4f, 1.6f); light.Add(new Binding <Vector3>(light.Position, rift.Position)); light.Add(new Binding <bool>(light.Enabled, () => rift.Type == Rift.Style.In && rift.Enabled, rift.Type, rift.Enabled)); light.Add(new Binding <float>(light.Attenuation, x => x * 2.0f, rift.CurrentRadius)); rift.Add(new Binding <Entity.Handle>(rift.Voxel, attachable.AttachedVoxel)); rift.Add(new Binding <Voxel.Coord>(rift.Coordinate, attachable.Coord)); entity.Add("Enable", rift.Enable); entity.Add("Disable", rift.Disable); entity.Add("AttachOffset", attachable.Offset); entity.Add("Enabled", rift.Enabled); entity.Add("Radius", rift.Radius); entity.Add("Style", rift.Type); }
public override void AttachEditorComponents(Entity entity, Main main) { base.AttachEditorComponents(entity, main); Rift.AttachEditorComponents(entity, main, this.Color); VoxelAttachable.AttachEditorComponents(entity, main, entity.Get <Model>().Color); }
public override Entity Create(Main main) { Entity entity = new Entity(main, "Rift"); Rift rift = new Rift(); rift.Enabled.Value = false; entity.Add("Rift", rift); return(entity); }
public RiftEditVM(Rift rift, Info info) { InfoId = rift.InfoId; RiftId = rift.RiftId; Nickname = rift.Nickname; Location = rift.Location; Environment = rift.Environment; Hazards = rift.Hazards; IsPublished = rift.IsPublished; Blurb = info.Blurb; IsSecret = info.IsSecret; }
// GET: Rifts/Delete/5 public ActionResult Delete(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Rift rift = db.Rifts.Find(id); if (rift == null) { return(HttpNotFound()); } return(View(rift)); }
private void Form1_Load(object sender, EventArgs e) { LeagueClient lcu = new LeagueClient(); rift = new Rift(lcu); dDragon = new DDragon(); Console.WriteLine(dDragon.LastPatch()); List <string> champions = dDragon.GetAllChampions(); foreach (var champion in champions) { cmbBox_Champion.Items.Add(champion); } }
public ActionResult Details(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Rift rift = db.Rifts.Find(id); if (rift == null) { return(HttpNotFound()); } //prevent users from seeing un-published work if (!rift.IsPublished && !User.IsInRole("Admin")) { return(View("Error")); //todo change redirect to a error 404 page } ViewBag.Variety = Variety((short)id); return(View(rift)); }
// GET: Rifts/Edit/5 public ActionResult Edit(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Rift rift = db.Rifts.Find(id); if (rift == null) { return(HttpNotFound()); } short infoid = rift.InfoId; Info info = db.Infos.Find(infoid); RiftEditVM model = new RiftEditVM(rift, info); List <short> selectedTags = db.InfoTags.Where(t => t.InfoId == infoid).Select(t => t.TagId).ToList(); ViewBag.Selected = selectedTags; ViewBag.Tags = db.Tags.ToList(); return(View(model)); }
public static void Run(Entity script) { Updater updater = script.Create <Updater>(); Command enable = command(script, "Enable"); Command disable = command(script, "Disable"); Property <bool> enabled = property <bool>(script, "Enabled"); updater.Add(new Binding <bool>(updater.Enabled, enabled)); script.Add(new CommandBinding(enable, () => !enabled, delegate() { enabled.Value = true; })); script.Add(new CommandBinding(disable, () => enabled, delegate() { enabled.Value = false; })); AmbientSound sound = script.Create <AmbientSound>(); sound.PlayCue.Value = AK.EVENTS.PLAY_MONOLITH_LOOP; sound.StopCue.Value = AK.EVENTS.STOP_ALL_OBJECT; sound.Add(new Binding <bool>(sound.Enabled, enabled)); script.Add(new Binding <float, bool>(WorldFactory.Instance.Get <World>().CameraShakeAmount, x => x ? 0.02f : 0.0f, enabled)); script.Add(new ChangeBinding <bool>(enabled, delegate(bool old, bool value) { if (!old && value) { enable.Execute(); } else if (old && !value) { disable.Execute(); } })); RiftFactory riftFactory = Factory.Get <RiftFactory>(); const float minInterval = 3.0f; const float maxInterval = 8.0f; float interval = minInterval + (float)random.NextDouble() * (maxInterval - minInterval); updater.Action = delegate(float dt) { Entity player = PlayerFactory.Instance; if (player != null) { interval -= dt; if (interval < 0.0f) { Vector3 pos = player.Get <Transform>().Position; Vector3 dir = Vector3.Normalize(new Vector3((float)random.NextDouble() * 2.0f - 1.0f, (float)random.NextDouble() * 2.0f - 1.0f, (float)random.NextDouble() * 2.0f - 1.0f)); Voxel.GlobalRaycastResult hit = default(Voxel.GlobalRaycastResult); int radius = random.Next(4, 10); int tries = 30; bool success = false; while (tries > 0) { hit = Voxel.GlobalRaycast(pos, dir, 50.0f); if (hit.Voxel != null && hit.Distance > radius && Rift.Query(hit.Position) == null && Zone.CanSpawnRift(hit.Position) && MapExit.Query(hit.Position, 5 + radius) == null) { success = true; break; } tries--; } if (success) { Entity rift = riftFactory.CreateAndBind(main); rift.Get <Transform>().Position.Value = hit.Position; VoxelAttachable attachment = rift.Get <VoxelAttachable>(); attachment.AttachedVoxel.Value = hit.Voxel.Entity; attachment.Coord.Value = hit.Coordinate.Value; Rift riftComponent = rift.Get <Rift>(); riftComponent.Radius.Value = radius; main.Add(rift); riftComponent.Enabled.Value = true; interval = minInterval + (float)random.NextDouble() * (maxInterval - minInterval); } } } }; script.Add(updater); }
public ActionResult Create([Bind(Include = "Nickname,Location,Environment,Hazards,Blurb, IsSecret")] RiftCreateVM rift, List <short> tags, string submit) { rift.IsPublished = false; if (ModelState.IsValid) { #region Info Info info; info = new Info { InfoTypeId = 5, //<-------------------Info Type ID. CHANGE UPON COPY IdWithinType = null, Blurb = rift.Blurb, Name = rift.Nickname, IsPublished = rift.IsPublished, IsSecret = rift.IsSecret }; db.Infos.Add(info); db.SaveChanges(); //this has to go here in order to ensure that the infoId short below is accurate. Also at this point I am doing no further gets on validity so there is no point to not saving #endregion short infoId = db.Infos.Max(i => i.InfoId); #region Adding Tags if (tags != null) { foreach (short t in tags) { InfoTag infoTag = new InfoTag { InfoId = infoId, TagId = t }; db.InfoTags.Add(infoTag); } } #endregion #region Rift Rift daRift = new Rift { InfoId = infoId, Nickname = rift.Nickname, Location = rift.Location, Environment = rift.Environment, Hazards = rift.Hazards, IsPublished = rift.IsPublished }; db.Rifts.Add(daRift); db.SaveChanges(); #endregion #region give info the IdWithinType short riftId = db.Rifts.Max(l => l.RiftId); info.IdWithinType = riftId; db.Entry(info).State = EntityState.Modified; db.SaveChanges(); #endregion return(RedirectToAction("AssoCreate", new { id = riftId, submit = submit })); } ViewBag.Tags = new MultiSelectList(db.Tags, "TagId", "TagName", tags); ModelState.AddModelError("", "Something has gone wrong. Look for red text to see where is went wrong"); return(View(rift)); }
public ActionResult DeleteConfirmed(short id) { Rift rift = db.Rifts.Find(id); short infoId = rift.InfoId; #region Remove Associations #region Remove Varieties List <VarietyOfInhabitant> vari = db.VarietyOfInhabitants.Where(x => x.RiftId == id).ToList(); foreach (VarietyOfInhabitant gone in vari) { db.VarietyOfInhabitants.Remove(gone); } #endregion #endregion db.Rifts.Remove(rift); #region Remove Rumors var rumors = db.Rumors.Where(r => r.RumorOfId == infoId); foreach (Rumor r in rumors) { db.Rumors.Remove(r); } #endregion #region Remove Secrets var secrets = db.Secrets.Where(s => s.IsAboutId == infoId); List <short> secretIds = db.Secrets.Where(s => s.IsAboutId == infoId).Select(s => s.SecretId).ToList(); List <SecretSecretTag> ssts = db.SecretSecretTags.Where(s => secretIds.Contains(s.SecretId)).ToList(); //remove sst foreach (SecretSecretTag secretSecretTag in ssts) { db.SecretSecretTags.Remove(secretSecretTag); } //remove secrets foreach (Secret secret in secrets) { db.Secrets.Remove(secret); } #endregion #region remove stories var stories = db.Stories.Where(s => s.IsAboutId == infoId); List <short> storyIds = db.Stories.Where(s => s.IsAboutId == infoId).Select(s => s.StoryId).ToList(); List <StoryTag> st = db.StoryTags.Where(s => storyIds.Contains(s.StoryId)).ToList(); //remove story tags foreach (StoryTag storyTag in st) { db.StoryTags.Remove(storyTag); } //remove stories foreach (Story story in stories) { db.Stories.Remove(story); } #endregion #region Remove info Info info = db.Infos.Where(i => i.InfoId == infoId).First(); var infoTags = db.InfoTags.Where(it => it.InfoId == infoId).ToList(); foreach (InfoTag infoTag in infoTags) { db.InfoTags.Remove(infoTag); } db.Infos.Remove(info); #endregion db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "RiftId,InfoId,Nickname,Location,Environment,Hazards,Blurb, IsPublished, IsSecret")] RiftEditPostVM rift, List <short> tags, string submit) { if (ModelState.IsValid) { #region Save or Publish? switch (submit) { case "Save Progress": case "Un-Publish": rift.IsPublished = false; break; case "Publish": case "Save": rift.IsPublished = true; break; case "Save and go to complex edit": break; } #endregion var infoid = rift.InfoId; #region Info Update //Info info = db.Infos.Find(infoid); Info info = db.Infos.Where(i => i.InfoId == infoid).FirstOrDefault(); info.Name = rift.Nickname; info.Blurb = rift.Blurb; info.IsPublished = rift.IsPublished; info.IsSecret = rift.IsSecret; #endregion #region Update tags List <short> currentTagIds = db.InfoTags.Where(x => x.InfoId == infoid).Select(x => x.TagId).ToList(); if (tags != null) { foreach (short tag in tags) { //if this is an already existing tag if (currentTagIds.Contains(tag)) { currentTagIds.Remove(tag); } //if this is a newly added tag else { InfoTag newTag = new InfoTag { InfoId = infoid, TagId = tag }; db.InfoTags.Add(newTag); } } } if (currentTagIds.Count != 0) { foreach (short id in currentTagIds) { InfoTag gone = db.InfoTags.Where(x => x.InfoId == infoid & x.TagId == id).FirstOrDefault(); db.InfoTags.Remove(gone); } } #endregion #region Update Rift Rift daRift = new Rift { InfoId = rift.InfoId, RiftId = rift.RiftId, Nickname = rift.Nickname, Location = rift.Location, Environment = rift.Environment, Hazards = rift.Hazards, IsPublished = rift.IsPublished }; db.Entry(daRift).State = EntityState.Modified; db.Entry(info).State = EntityState.Modified; db.SaveChanges(); #endregion if (submit == "Save and go to complex edit") { return(RedirectToAction("AssoEdit", new { id = rift.RiftId })); } return(RedirectToAction("Details", new { id = rift.RiftId })); } //if model invalid ViewBag.Tags = db.Tags.ToList(); if (tags != null) { ViewBag.Selected = tags; } else { ViewBag.Selected = new List <short>(); } ModelState.AddModelError("", "Something has gone wrong. Look for red text to see where is went wrong"); RiftEditVM aRift = new RiftEditVM(rift); return(View(aRift)); }
public ActionResult TogglePub(short id, string submit) { Info info = db.Infos.Where(i => i.InfoId == id).First(); if (submit == "Publish") { info.IsPublished = true; switch (info.InfoTypeId) { case 1: //lore Lore lore = db.Lores.Where(x => x.LoreId == info.IdWithinType).First(); lore.IsPublished = true; db.Entry(lore).State = EntityState.Modified; break; case 2: //npc NPC npc = db.NPCs.Where(x => x.NpcId == info.IdWithinType).First(); npc.IsPublished = true; db.Entry(npc).State = EntityState.Modified; break; case 3: //org Org org = db.Orgs.Where(x => x.OrgId == info.IdWithinType).First(); org.IsPublished = true; db.Entry(org).State = EntityState.Modified; break; case 4: //locale Locale locale = db.Locales.Where(x => x.LocaleId == info.IdWithinType).First(); locale.IsPublished = true; db.Entry(locale).State = EntityState.Modified; break; case 5: // rift Rift rift = db.Rifts.Where(x => x.RiftId == info.IdWithinType).First(); rift.IsPublished = true; db.Entry(rift).State = EntityState.Modified; break; case 6: //event Event taevent = db.Events.Where(x => x.EventId == info.IdWithinType).First(); taevent.IsPublished = true; db.Entry(taevent).State = EntityState.Modified; break; case 7: //item Item item = db.Items.Where(x => x.ItemId == info.IdWithinType).First(); item.IsPublished = true; db.Entry(item).State = EntityState.Modified; break; } } else { info.IsPublished = false; switch (info.InfoTypeId) { case 1: //lore Lore lore = db.Lores.Where(x => x.LoreId == info.IdWithinType).First(); lore.IsPublished = false; db.Entry(lore).State = EntityState.Modified; break; case 2: //npc NPC npc = db.NPCs.Where(x => x.NpcId == info.IdWithinType).First(); npc.IsPublished = false; db.Entry(npc).State = EntityState.Modified; break; case 3: //org Org org = db.Orgs.Where(x => x.OrgId == info.IdWithinType).First(); org.IsPublished = false; db.Entry(org).State = EntityState.Modified; break; case 4: //locale Locale locale = db.Locales.Where(x => x.LocaleId == info.IdWithinType).First(); locale.IsPublished = false; db.Entry(locale).State = EntityState.Modified; break; case 5: // rift Rift rift = db.Rifts.Where(x => x.RiftId == info.IdWithinType).First(); rift.IsPublished = false; db.Entry(rift).State = EntityState.Modified; break; case 6: //event Event taevent = db.Events.Where(x => x.EventId == info.IdWithinType).First(); taevent.IsPublished = false; db.Entry(taevent).State = EntityState.Modified; break; case 7: //item Item item = db.Items.Where(x => x.ItemId == info.IdWithinType).First(); item.IsPublished = false; db.Entry(item).State = EntityState.Modified; break; } } db.Entry(info).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = id })); }