Inheritance: LookupDataPartial, IDimensionalModelData
コード例 #1
0
        /// <summary>
        /// constructor for 0 dimension models
        /// </summary>
        /// <param name="length">Length parameter of the model</param>
        /// <param name="height">Height parameter of the model</param>
        /// <param name="width">Width parameter of the model</param>
        public DimensionalModel(int length, int height, int width, int vacuity, int surfaceCavitation)
        {
            Length = length;
            Height = height;
            Width = width;
            Vacuity = vacuity;
            SurfaceCavitation = surfaceCavitation;
            Composition = new Dictionary<string, IMaterial>();

            ModelBackingData = new DimensionalModelData();
            ModelBackingData.ModelType = DimensionalModelType.None;
        }
コード例 #2
0
        public ActionResult Add(AddEditDimensionalModelDataViewModel vModel, HttpPostedFileBase modelFile)
        {
            string message = string.Empty;
            var authedUser = UserManager.FindById(User.Identity.GetUserId());

            try
            {
                DimensionalModelData newModel = null;

                //So we have file OR manual now so file trumps manual
                if (modelFile != null && modelFile.ContentLength > 0)
                {
                    byte[] bytes = new byte[modelFile.InputStream.Length];
                    modelFile.InputStream.Read(bytes, 0, (int)modelFile.InputStream.Length);
                    var fileContents = Encoding.UTF8.GetString(bytes);

                    newModel = new DimensionalModelData(fileContents, vModel.NewModelType);
                }
                else if(vModel.ModelPlaneNames.Count(m => !String.IsNullOrEmpty(m)) == 11
                    && vModel.CoordinateDamageTypes.Any(m => !m.Equals(0))) //can't have an entirely null typed model
                {
                    //We're going to be cheaty and build a cDel string based on the arrays
                    var arrayString = new StringBuilder();

                    var i = 11;
                    foreach(var name in vModel.ModelPlaneNames)
                    {
                        arrayString.AppendLine(
                            String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}"
                                , name
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 1]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 2]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 3]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 4]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 5]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 6]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 7]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 8]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 9]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 10]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 11]))
                            )
                        );

                        i--;
                    }

                    newModel = new DimensionalModelData(arrayString.ToString(), vModel.NewModelType);
                }
                else
                    message = "You must post a comma delimited file with the model in it or use the manual form.";

                if (newModel != null)
                {
                    newModel.Name = vModel.NewName;

                    if (newModel.IsModelValid())
                    {
                        if (newModel.Create() == null)
                            message = "Error; Creation failed.";
                        else
                        {
                            LoggingUtility.LogAdminCommandUsage("*WEB* - AddDimensionalModelData[" + newModel.ID.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                            message = "Creation Successful.";
                        }
                    }
                    else
                        message = "Invalid model file; Model files must contain 11 planes of a tag name followed by 11 rows of 11 nodes.";
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                message = "Error; Creation failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
コード例 #3
0
        public ActionResult Edit(long id, AddEditDimensionalModelDataViewModel vModel)
        {
            string message = string.Empty;
            var authedUser = UserManager.FindById(User.Identity.GetUserId());

            var obj = BackingDataCache.Get<IDimensionalModelData>(id);
            if (obj == null)
            {
                message = "That does not exist";
                return RedirectToAction("Index", new { Message = message });
            }

            try
            {
                DimensionalModelData newModel = null;

                if (vModel.ModelPlaneNames.Count(m => !String.IsNullOrEmpty(m)) == 11
                    && vModel.CoordinateDamageTypes.Any(m => !m.Equals(0))) //can't have an entirely null typed model
                {
                    //We're going to be cheaty and build a cDel string based on the arrays
                    var arrayString = new StringBuilder();

                    var i = 11;
                    foreach (var name in vModel.ModelPlaneNames)
                    {
                        arrayString.AppendLine(
                            String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}"
                                , name
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 1]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 2]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 3]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 4]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 5]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 6]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 7]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 8]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 9]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 10]))
                                , NetMud.Physics.Render.DamageTypeToCharacter(((DamageType)vModel.CoordinateDamageTypes[i * 11 - 11]))
                            )
                        );

                        i--;
                    }

                    newModel = new DimensionalModelData(arrayString.ToString(), vModel.NewModelType);
                }
                else
                    message = "You must post a comma delimited file with the model in it or use the manual form.";

                if (newModel != null)
                {
                    if (newModel.IsModelValid())
                    {
                        obj.Name = vModel.NewName;
                        obj.ModelType = newModel.ModelType;
                        obj.ModelPlanes = newModel.ModelPlanes;

                        if (obj.Save())
                        {
                            LoggingUtility.LogAdminCommandUsage("*WEB* - EditDimensionalModelData[" + obj.ID.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                            message = "Edit Successful.";
                        }
                        else
                            message = "Error; Edit failed.";
                    }
                    else
                        message = "Invalid model; Models must contain 11 planes of a tag name followed by 11 rows of 11 nodes.";
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                message = "Error; Creation failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }