Exemple #1
0
        public ActionResult Add(long id, long originRoomId, long destinationRoomId, int degreesFromNorth = 0, int incline = 0)
        {
            //New room or existing room
            if (destinationRoomId.Equals(-1))
            {
                IRoomTemplate origin = TemplateCache.Get <IRoomTemplate>(originRoomId);

                AddPathwayWithRoomTemplateViewModel vModel = new AddPathwayWithRoomTemplateViewModel
                {
                    AuthedUser = UserManager.FindById(User.Identity.GetUserId()),

                    ValidMaterials = TemplateCache.GetAll <IMaterial>(),
                    ValidModels    = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat),
                    ValidRooms     = TemplateCache.GetAll <IRoomTemplate>(),
                    Origin         = origin,
                    DataObject     = new PathwayTemplate()
                    {
                        DegreesFromNorth = degreesFromNorth, InclineGrade = incline
                    },
                    Destination = new RoomTemplate()
                    {
                        ParentLocation = origin.ParentLocation
                    }
                };

                vModel.Destination.ParentLocation = vModel.Origin.ParentLocation;

                return(View("~/Views/GameAdmin/Pathway/AddWithRoom.cshtml", "_chromelessLayout", vModel));
            }
            else
            {
                IRoomTemplate    origin          = TemplateCache.Get <IRoomTemplate>(originRoomId);
                IRoomTemplate    destination     = TemplateCache.Get <IRoomTemplate>(destinationRoomId);
                IPathwayTemplate pathwayTemplate = TemplateCache.Get <IPathwayTemplate>(id);

                if (pathwayTemplate == null)
                {
                    pathwayTemplate = new PathwayTemplate()
                    {
                        Origin = origin, Destination = destination, DegreesFromNorth = degreesFromNorth, InclineGrade = incline
                    };
                }

                AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel
                {
                    AuthedUser = UserManager.FindById(User.Identity.GetUserId()),

                    ValidMaterials = TemplateCache.GetAll <IMaterial>(),
                    ValidModels    = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat),
                    ValidRooms     = TemplateCache.GetAll <IRoomTemplate>().Where(rm => !rm.Id.Equals(originRoomId)),
                    DataObject     = pathwayTemplate
                };

                return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", "_chromelessLayout", vModel));
            }
        }
Exemple #2
0
        public ActionResult AddWithRoom(AddPathwayWithRoomTemplateViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRoomTemplate origin  = TemplateCache.Get <IRoomTemplate>(vModel.Origin.Id);
            IRoomTemplate newRoom = vModel.Destination;

            newRoom.ParentLocation = origin.ParentLocation;

            string message = string.Empty;

            if (newRoom.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) != null)
            {
                IPathwayTemplate newObj = vModel.DataObject;
                newObj.Destination = newRoom;
                newObj.Origin      = origin;

                if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                {
                    message = "Error; Creation failed.";
                }
                else
                {
                    if (vModel.CreateReciprocalPath)
                    {
                        PathwayTemplate reversePath = new PathwayTemplate
                        {
                            Name             = newObj.Name,
                            DegreesFromNorth = Utilities.ReverseDirection(newObj.DegreesFromNorth),
                            Origin           = newObj.Destination,
                            Destination      = newObj.Origin,
                            Model            = newObj.Model,
                            InclineGrade     = newObj.InclineGrade * -1
                        };

                        if (reversePath.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                        {
                            message = "Reverse Path creation FAILED. Origin path creation SUCCESS.";
                        }
                    }

                    LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathwayWithRoom[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                }
            }
            else
            {
                message = "Error; Creation failed.";
            }
            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
Exemple #3
0
        public ActionResult Edit(long id, long originRoomId, long destinationRoomId)
        {
            string message = string.Empty;
            AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId()),

                ValidMaterials = TemplateCache.GetAll <IMaterial>(),
                ValidModels    = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat),
                ValidRooms     = TemplateCache.GetAll <IRoomTemplate>()
            };

            PathwayTemplate obj = TemplateCache.Get <PathwayTemplate>(id);

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToAction("Index", "Room", new { Message = message }));
            }

            vModel.DataObject = obj;

            return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", "_chromelessLayout", vModel));
        }
Exemple #4
0
        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"));
        }
Exemple #5
0
        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 }));
        }
Exemple #6
0
        public string Quickbuild(long originId, long destinationId, int direction, int incline)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRoomTemplate origin      = TemplateCache.Get <IRoomTemplate>(originId);
            IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(destinationId);

            string message = string.Empty;

            if (destination == null)
            {
                destination = new RoomTemplate
                {
                    Name           = "Room",
                    Medium         = origin.Medium,
                    ParentLocation = origin.ParentLocation,
                    Model          = new DimensionalModel()
                    {
                        ModelTemplate     = origin.Model.ModelTemplate,
                        Composition       = origin.Model.Composition,
                        Height            = origin.Model.Height,
                        Length            = origin.Model.Length,
                        Width             = origin.Model.Width,
                        SurfaceCavitation = origin.Model.SurfaceCavitation,
                        Vacuity           = origin.Model.Vacuity
                    }
                };

                destination = (IRoomTemplate)destination.Create(authedUser.GameAccount, authedUser.GetStaffRank(User));
            }


            if (destination != null)
            {
                IPathwayTemplate newObj = new PathwayTemplate
                {
                    Name             = "Pathway",
                    Destination      = destination,
                    Origin           = origin,
                    InclineGrade     = incline,
                    DegreesFromNorth = direction,
                    Model            = new DimensionalModel()
                    {
                        ModelTemplate     = origin.Model.ModelTemplate,
                        Composition       = origin.Model.Composition,
                        Height            = origin.Model.Height,
                        Length            = origin.Model.Length,
                        Width             = origin.Model.Width,
                        SurfaceCavitation = origin.Model.SurfaceCavitation,
                        Vacuity           = origin.Model.Vacuity
                    }
                };

                if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                {
                    message = "Error; Creation failed.";
                }
                else
                {
                    PathwayTemplate reversePath = new PathwayTemplate
                    {
                        Name             = newObj.Name,
                        DegreesFromNorth = Utilities.ReverseDirection(newObj.DegreesFromNorth),
                        Origin           = newObj.Destination,
                        Destination      = newObj.Origin,
                        Model            = newObj.Model,
                        InclineGrade     = newObj.InclineGrade * -1
                    };

                    if (reversePath.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                    {
                        message = "Reverse Path creation FAILED. Origin path creation SUCCESS.";
                    }

                    LoggingUtility.LogAdminCommandUsage("*WEB* - Quickbuild[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                }
            }
            else
            {
                message = "Error; Creation failed.";
            }

            return(message);
        }