public ActionResult Edit(long zoneId, long id) { IZoneTemplate zone = TemplateCache.Get <IZoneTemplate>(zoneId); if (zone == null) { return(RedirectToAction("Index", "Zone", new { Id = zoneId, Message = "Invalid zone" })); } AddEditLocaleTemplateViewModel vModel = new AddEditLocaleTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()) }; ILocaleTemplate obj = TemplateCache.Get <ILocaleTemplate>(id); if (obj == null) { string message = "That does not exist"; return(RedirectToAction("Index", "Zone", new { Id = zoneId, Message = message })); } vModel.DataObject = obj; return(View("~/Views/GameAdmin/Locale/Edit.cshtml", vModel)); }
public ActionResult RemoveDescriptive(long id = -1, string authorize = "") { string message = string.Empty; long zoneId = -1; if (string.IsNullOrWhiteSpace(authorize)) { message = "You must check the proper authorize radio button first."; } else { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); string[] values = authorize.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries); if (values.Count() != 2) { message = "You must check the proper authorize radio button first."; } else { string type = values[0]; string phrase = values[1]; IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); if (obj == null) { message = "That does not exist"; } else { GrammaticalType grammaticalType = (GrammaticalType)Enum.Parse(typeof(GrammaticalType), type); ISensoryEvent existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType && occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase)); zoneId = obj.Id; if (existingOccurrence != null) { obj.Descriptives.Remove(existingOccurrence); if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveDescriptive[" + id.ToString() + "|" + type.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Delete Successful."; } else { message = "Error; Removal failed."; } } else { message = "That does not exist"; } } } } return(RedirectToAction("Edit", new { Message = message, id = zoneId })); }
/// <summary> /// Get the current luminosity rating of the place you're in /// </summary> /// <returns>The current Luminosity</returns> public override float GetCurrentLuminosity() { IZoneTemplate zD = Template <IZoneTemplate>(); float lumins = 0; bool canSeeSky = IsOutside(); //TODO: Add cloud cover. Commented out for testing purposes ATM if (canSeeSky) { IGaia world = GetWorld(); if (world != null) { IEnumerable <ICelestialPosition> celestials = world.CelestialPositions; float rotationalPosition = world.PlanetaryRotation; float orbitalPosition = world.OrbitalPosition; foreach (ICelestialPosition celestial in celestials) { float celestialAffectModifier = AstronomicalUtilities.GetCelestialLuminosityModifier(celestial.CelestialObject, celestial.Position, rotationalPosition, orbitalPosition , zD.Hemisphere, world.Template <IGaiaTemplate>().RotationalAngle); lumins += celestial.CelestialObject.Luminosity * celestialAffectModifier; } } } return(lumins); }
/// <summary> /// Spawn this into the world and live cache /// </summary> /// <param name="spawnTo">Where this will go</param> public override void SpawnNewInWorld(IGlobalPosition spawnTo) { //We can't even try this until we know if the data is there IZoneTemplate bS = Template <IZoneTemplate>() ?? throw new InvalidOperationException("Missing backing data store on zone spawn event."); Keywords = bS.Keywords; if (string.IsNullOrWhiteSpace(BirthMark)) { BirthMark = LiveCache.GetUniqueIdentifier(bS); Birthdate = DateTime.Now; } Qualities = bS.Qualities; Descriptives = bS.Descriptives; WeatherEvents = Enumerable.Empty <IWeatherEvent>(); FloraNaturalResources = new HashSet <INaturalResourceSpawn <IFlora> >(); FaunaNaturalResources = new HashSet <INaturalResourceSpawn <IFauna> >(); MineralNaturalResources = new HashSet <INaturalResourceSpawn <IMineral> >(); PopulateMap(); UpsertToLiveWorldCache(true); KickoffProcesses(); CurrentLocation = new GlobalPosition(this, null, null); UpsertToLiveWorldCache(true); Save(); }
public ActionResult Edit(AddEditZoneTemplateViewModel vModel, long id) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); string message; if (obj == null) { message = "That does not exist"; return(RedirectToAction("Index", new { Message = message })); } obj.Name = vModel.DataObject.Name; obj.BaseElevation = vModel.DataObject.BaseElevation; obj.PressureCoefficient = vModel.DataObject.PressureCoefficient; obj.TemperatureCoefficient = vModel.DataObject.TemperatureCoefficient; obj.Hemisphere = vModel.DataObject.Hemisphere; obj.World = vModel.DataObject.World; obj.FloraResourceSpawn = vModel.DataObject.FloraResourceSpawn; obj.FaunaResourceSpawn = vModel.DataObject.FaunaResourceSpawn; obj.MineralResourceSpawn = vModel.DataObject.MineralResourceSpawn; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditZone[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return(RedirectToAction("Index", new { Message = message })); }
public ActionResult Edit(long zoneId, AddEditLocaleTemplateViewModel vModel, long id) { IZoneTemplate zone = TemplateCache.Get <IZoneTemplate>(zoneId); if (zone == null) { return(RedirectToAction("Index", "Zone", new { Id = zoneId, Message = "Invalid zone" })); } ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILocaleTemplate obj = TemplateCache.Get <ILocaleTemplate>(id); string message; if (obj == null) { message = "That does not exist"; return(RedirectToAction("Index", new { Message = message })); } obj.Name = vModel.DataObject.Name; obj.AlwaysDiscovered = vModel.DataObject.AlwaysDiscovered; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditLocale[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return(RedirectToAction("Index", "Zone", new { Id = zoneId, Message = message })); }
public ActionResult Add(long zoneId, AddEditLocaleTemplateViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate zone = TemplateCache.Get <IZoneTemplate>(zoneId); if (zone == null) { return(RedirectToAction("Index", "Zone", new { Id = zoneId, Message = "Invalid zone" })); } LocaleTemplate newObj = new LocaleTemplate { Name = vModel.DataObject.Name, AlwaysDiscovered = vModel.DataObject.AlwaysDiscovered, ParentLocation = zone }; string message; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddLocale[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Creation Successful."; } return(RedirectToAction("Index", "Zone", new { Id = zoneId, Message = message })); }
public ActionResult AddEditDescriptive(long id, OccurrenceViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); if (obj == null) { message = "That does not exist"; return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); } ISensoryEvent existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role && occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase)); if (existingOccurrence == null) { existingOccurrence = new SensoryEvent(vModel.SensoryEventDataObject.SensoryType) { Strength = vModel.SensoryEventDataObject.Strength, Event = new Lexica(vModel.SensoryEventDataObject.Event.Type, vModel.SensoryEventDataObject.Event.Role, vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null)) { Modifiers = vModel.SensoryEventDataObject.Event.Modifiers } }; } else { existingOccurrence.Strength = vModel.SensoryEventDataObject.Strength; existingOccurrence.SensoryType = vModel.SensoryEventDataObject.SensoryType; existingOccurrence.Event = new Lexica(vModel.SensoryEventDataObject.Event.Type, vModel.SensoryEventDataObject.Event.Role, vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null)) { Modifiers = vModel.SensoryEventDataObject.Event.Modifiers }; } obj.Descriptives.RemoveWhere(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role && occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase)); obj.Descriptives.Add(existingOccurrence); if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - Zone AddEditDescriptive[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { message = "Error; Edit failed."; } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "") { string message; if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(removeId); if (obj == null) { message = "That does not exist"; } else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveZone[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Delete Successful."; } else { message = "Error; Removal failed."; } } else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(unapproveId); if (obj == null) { message = "That does not exist"; } else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned)) { LoggingUtility.LogAdminCommandUsage("*WEB* - UnapproveZone[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Unapproval Successful."; } else { message = "Error; Unapproval failed."; } } else { message = "You must check the proper remove or unapprove authorization radio button first."; } return(RedirectToAction("Index", new { Message = message })); }
/// <summary> /// News up an entity with its backing data /// </summary> /// <param name="room">the backing data</param> public Zone(IZoneTemplate zone) { TemplateId = zone.Id; Qualities = new HashSet <IQuality>(); WeatherEvents = Enumerable.Empty <IWeatherEvent>(); MobilesInside = new EntityContainer <IMobile>(); Contents = new EntityContainer <IInanimate>(); FloraNaturalResources = new HashSet <INaturalResourceSpawn <IFlora> >(); FaunaNaturalResources = new HashSet <INaturalResourceSpawn <IFauna> >(); MineralNaturalResources = new HashSet <INaturalResourceSpawn <IMineral> >(); Descriptives = new HashSet <ISensoryEvent>(); GetFromWorldOrSpawn(); }
public ActionResult Add(long zoneId) { IZoneTemplate zone = TemplateCache.Get <IZoneTemplate>(zoneId); if (zone == null) { return(RedirectToAction("Index", "Zone", new { Id = zoneId, Message = "Invalid zone" })); } AddEditLocaleTemplateViewModel vModel = new AddEditLocaleTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ZoneId = zoneId, DataObject = new LocaleTemplate() }; return(View("~/Views/GameAdmin/Locale/Add.cshtml", vModel)); }
public ActionResult AddEditLocalePath(long id, long localeId) { ILocaleTemplate locale = TemplateCache.Get <ILocaleTemplate>(localeId); if (locale == null) { return(RedirectToAction("Edit", new { Message = "Locale is invalid.", id })); } IEnumerable <IRoomTemplate> validRooms = TemplateCache.GetAll <IRoomTemplate>().Where(rm => rm.ParentLocation.Equals(locale)); if (validRooms.Count() == 0) { return(RedirectToAction("Edit", new { Message = "Locale has no rooms.", id })); } IZoneTemplate origin = TemplateCache.Get <IZoneTemplate>(id); IPathwayTemplate existingPathway = origin.GetLocalePathways().FirstOrDefault(path => ((IRoomTemplate)path.Destination).ParentLocation.Equals(locale)); AddEditZonePathwayTemplateViewModel vModel = new AddEditZonePathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = validRooms, }; if (existingPathway != null) { vModel.DataObject = existingPathway; vModel.DestinationRoom = (IRoomTemplate)existingPathway.Destination; } else { vModel.DataObject = new PathwayTemplate() { Origin = origin }; } return(View("~/Views/GameAdmin/Zone/AddEditLocalePath.cshtml", vModel)); }
public ActionResult Add(AddEditZoneTemplateViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate newObj = vModel.DataObject; string message; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddZone[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Creation Successful."; } return(RedirectToAction("Index", new { Message = message })); }
public ActionResult AddEditDescriptive(long id, short descriptiveType, string phrase) { string message = string.Empty; IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); if (obj == null) { message = "That does not exist"; return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); } OccurrenceViewModel vModel = new OccurrenceViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), DataObject = obj, AdminTypeName = "Zone" }; if (descriptiveType > -1) { GrammaticalType grammaticalType = (GrammaticalType)descriptiveType; vModel.SensoryEventDataObject = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType && occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase)); } if (vModel.SensoryEventDataObject != null) { vModel.LexicaDataObject = vModel.SensoryEventDataObject.Event; } else { vModel.SensoryEventDataObject = new SensoryEvent { Event = new Lexica() }; } return(View("~/Views/GameAdmin/Zone/SensoryEvent.cshtml", "_chromelessLayout", vModel)); }
public ActionResult AddLocalePathway(long id, AddEditZonePathwayTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); IPathwayTemplate newObj = vModel.DataObject; newObj.Destination = TemplateCache.Get <IRoomTemplate>(vModel.DestinationRoom.Id); newObj.Origin = obj; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathway[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } return(RedirectToAction("Edit", new { Message = message, id })); }
/// <summary> /// Get the visibile celestials. Depends on luminosity, viewer perception and celestial positioning /// </summary> /// <param name="viewer">Whom is looking</param> /// <returns>What celestials are visible</returns> public override IEnumerable <ICelestial> GetVisibileCelestials(IEntity viewer) { IZoneTemplate zD = Template <IZoneTemplate>(); bool canSeeSky = IsOutside(); //TODO: cloud cover List <ICelestial> returnList = new List <ICelestial>(); if (!canSeeSky) { return(returnList); } IGaia world = GetWorld(); IEnumerable <ICelestialPosition> celestials = world.CelestialPositions; if (celestials.Count() > 0) { //TODO: Add cloud cover stuff float rotationalPosition = world.PlanetaryRotation; float orbitalPosition = world.OrbitalPosition; float currentBrightness = GetCurrentLuminosity(); foreach (ICelestialPosition celestial in celestials) { float celestialLumins = celestial.CelestialObject.Luminosity * AstronomicalUtilities.GetCelestialLuminosityModifier(celestial.CelestialObject, celestial.Position, rotationalPosition, orbitalPosition , zD.Hemisphere, world.Template <IGaiaTemplate>().RotationalAngle); //how washed out is this thing compared to how bright the room is if (celestialLumins / currentBrightness > 0.01) { returnList.Add(celestial.CelestialObject); } } } return(returnList); }
public ActionResult Edit(long id) { IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); if (obj == null) { return(RedirectToAction("Index", new { Message = "That does not exist" })); } IEnumerable <ILocaleTemplate> locales = TemplateCache.GetAll <ILocaleTemplate>().Where(locale => locale.ParentLocation.Equals(obj)); AddEditZoneTemplateViewModel vModel = new AddEditZoneTemplateViewModel(locales) { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), DataObject = obj, ValidWorlds = TemplateCache.GetAll <IGaiaTemplate>(true) }; vModel.FloraNaturalResources = TemplateCache.GetAll <IFlora>(true); vModel.FaunaNaturalResources = TemplateCache.GetAll <IFauna>(true); vModel.MineralNaturalResources = TemplateCache.GetAll <IMineral>(true); return(View("~/Views/GameAdmin/Zone/Edit.cshtml", vModel)); }
private bool AdvanceResources() { Random rand = new Random(); IZoneTemplate bS = Template <IZoneTemplate>(); if (FloraNaturalResources.Count() == 0 && bS.FloraResourceSpawn.Count() != 0) { foreach (INaturalResourceSpawn <IFlora> population in bS.FloraResourceSpawn) { FloraNaturalResources.Add(new FloraResourceSpawn() { RateFactor = population.RateFactor, Resource = population.Resource }); } } else { foreach (INaturalResourceSpawn <IFlora> population in FloraNaturalResources) { INaturalResourceSpawn <IFlora> baseRate = bS.FloraResourceSpawn.FirstOrDefault(spawn => spawn.Resource.Equals(population.Resource)); if (baseRate == null || population.RateFactor > 100 * baseRate.RateFactor) { continue; } population.RateFactor = Math.Min(100 * baseRate.RateFactor, baseRate.RateFactor * rand.Next(1, 3) + population.RateFactor); } } if (MineralNaturalResources.Count() == 0 && bS.MineralResourceSpawn.Count() != 0) { foreach (INaturalResourceSpawn <IMineral> population in bS.MineralResourceSpawn) { MineralNaturalResources.Add(new MineralResourceSpawn() { RateFactor = population.RateFactor, Resource = population.Resource }); } } else { foreach (INaturalResourceSpawn <IMineral> population in MineralNaturalResources) { INaturalResourceSpawn <IMineral> baseRate = bS.MineralResourceSpawn.FirstOrDefault(spawn => spawn.Resource.Equals(population.Resource)); if (baseRate == null || population.RateFactor > 25 * baseRate.RateFactor) { continue; } population.RateFactor = Math.Min(100 * baseRate.RateFactor, baseRate.RateFactor + population.RateFactor); } } if (FaunaNaturalResources.Count() == 0 && bS.FaunaResourceSpawn.Count() != 0) { foreach (INaturalResourceSpawn <IFauna> population in bS.FaunaResourceSpawn) { FaunaNaturalResources.Add(new FaunaResourceSpawn() { RateFactor = population.RateFactor, Resource = population.Resource }); } } else { foreach (INaturalResourceSpawn <IFauna> population in FaunaNaturalResources) { INaturalResourceSpawn <IFauna> baseRate = bS.FaunaResourceSpawn.FirstOrDefault(spawn => spawn.Resource.Equals(population.Resource)); if (baseRate == null || population.RateFactor > 1000 * baseRate.RateFactor) { continue; } population.RateFactor = Math.Min(100 * baseRate.RateFactor, baseRate.RateFactor * population.Resource.FemaleRatio * 5 + population.RateFactor); } } Save(); return(true); }
private void PopulateMap() { IZoneTemplate dt = Template <IZoneTemplate>(); }
public ActionResult Edit(int id, AddEditRoomTemplateViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate zoneDestination = null; IPathwayTemplate localeRoomPathway = null; IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id); if (obj == null) { string message = "That does not exist"; return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); } obj.Name = vModel.DataObject.Name; obj.Medium = vModel.DataObject.Medium; obj.Qualities = vModel.DataObject.Qualities; if (vModel.ZonePathway?.Destination != null && !string.IsNullOrWhiteSpace(vModel.ZonePathway.Name)) { IZoneTemplate destination = TemplateCache.Get <IZoneTemplate>(vModel.ZonePathway.Destination.Id); zoneDestination = obj.GetZonePathways().FirstOrDefault(); if (zoneDestination == null) { zoneDestination = new PathwayTemplate() { DegreesFromNorth = vModel.ZonePathway.DegreesFromNorth, Name = vModel.ZonePathway.Name, Origin = obj, Destination = destination, InclineGrade = vModel.ZonePathway.InclineGrade, Model = vModel.ZonePathway.Model }; } else { zoneDestination.Model = vModel.ZonePathway.Model; zoneDestination.Name = vModel.ZonePathway.Name; zoneDestination.InclineGrade = vModel.ZonePathway.InclineGrade; //We switched zones, this makes things more complicated if (zoneDestination.Id != vModel.ZonePathway.Destination.Id) { zoneDestination.Destination = destination; } } } if (vModel.LocaleRoomPathwayDestination != null && !string.IsNullOrWhiteSpace(vModel.LocaleRoomPathwayDestination.Name)) { IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(vModel.LocaleRoomPathwayDestination.Id); localeRoomPathway = obj.GetLocalePathways().FirstOrDefault(); if (localeRoomPathway == null) { localeRoomPathway = new PathwayTemplate() { DegreesFromNorth = vModel.LocaleRoomPathway.DegreesFromNorth, Name = vModel.LocaleRoomPathway.Name, Origin = obj, Destination = destination, InclineGrade = vModel.LocaleRoomPathway.InclineGrade, Model = vModel.LocaleRoomPathway.Model }; } else { localeRoomPathway.Model = vModel.LocaleRoomPathway.Model; localeRoomPathway.Name = vModel.LocaleRoomPathway.Name; localeRoomPathway.InclineGrade = vModel.LocaleRoomPathway.InclineGrade; localeRoomPathway.Destination = destination; } } if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { if (zoneDestination != null) { zoneDestination.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } if (localeRoomPathway != null) { localeRoomPathway.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } LoggingUtility.LogAdminCommandUsage("*WEB* - EditRoomTemplate[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { } return(RedirectToRoute("ModalErrorOrClose")); }
public ActionResult Add(long localeId, AddEditRoomTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILocaleTemplate locale = TemplateCache.Get <ILocaleTemplate>(localeId); IRoomTemplate newObj = vModel.DataObject; newObj.ParentLocation = locale; newObj.Coordinates = new Coordinate(0, 0, 0); //TODO: fix this IPathwayTemplate zoneDestination = null; if (vModel.ZonePathway?.Destination != null && !string.IsNullOrWhiteSpace(vModel.ZonePathway.Name)) { IZoneTemplate destination = TemplateCache.Get <IZoneTemplate>(vModel.ZonePathway.Destination.Id); zoneDestination = new PathwayTemplate() { DegreesFromNorth = -1, Name = vModel.ZonePathway.Name, Origin = newObj, Destination = destination, InclineGrade = vModel.ZonePathway.InclineGrade, Model = vModel.ZonePathway.Model }; } IPathwayTemplate localeRoomPathway = null; if (vModel.LocaleRoomPathwayDestination != null && !string.IsNullOrWhiteSpace(vModel.LocaleRoomPathwayDestination.Name)) { IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(vModel.LocaleRoomPathwayDestination.Id); localeRoomPathway = new PathwayTemplate() { DegreesFromNorth = vModel.LocaleRoomPathway.DegreesFromNorth, Name = vModel.LocaleRoomPathway.Name, Origin = newObj, Destination = destination, InclineGrade = vModel.LocaleRoomPathway.InclineGrade, Model = vModel.LocaleRoomPathway.Model }; } if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { if (zoneDestination != null) { zoneDestination.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } if (localeRoomPathway != null) { localeRoomPathway.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddRoomTemplate[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }