コード例 #1
0
        static void PreallocateObjects()
        {
            if (m_objectPool == null)
            {
                m_objectPool = new MyObjectsPool <MyExplosionDebrisModel>(MyExplosionsConstants.MAX_EXPLOSION_DEBRIS_OBJECTS);
            }
            m_objectPool.DeallocateAll();

            List <MyRBElementDesc> collisionPrimitives = new List <MyRBElementDesc>();

            MyPhysicsObjects      physobj    = MyPhysics.physicsSystem.GetPhysicsObjects();
            MyRBSphereElementDesc sphereDesc = physobj.GetRBSphereElementDesc();

            sphereDesc.SetToDefault();
            sphereDesc.m_RBMaterial = MyMaterialsConstants.GetMaterialProperties(MODEL_DEBRIS_MATERIAL_TYPE).PhysicsMaterial;

            collisionPrimitives.Add(sphereDesc);

            int counter = 0;

            foreach (var item in m_objectPool.GetPreallocatedItemsArray())
            {
                MyModelsEnum   modelEnum      = (MyModelsEnum)((int)MyModelsEnum.Debris1 + counter % 31);
                MyModel        model          = MyModels.GetModelOnlyData(modelEnum);
                BoundingSphere boundingSphere = model.BoundingSphere;

                sphereDesc.m_Radius             = boundingSphere.Radius;
                sphereDesc.m_Matrix.Translation = boundingSphere.Center;

                item.Value.Init(collisionPrimitives, modelEnum);
                counter++;
            }
        }
コード例 #2
0
        public ActionResult SaveItem(DocumentsType model)
        {
            string             ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int                IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            DocumentsTypeModel data           = new DocumentsTypeModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    DocumentsTypeService.SaveItem(model);
                    if (model.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index"));
                }
            }
            return(View(data));
        }
コード例 #3
0
        public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Ablums item           = new Ablums()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Status = Status
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateStatus = AblumsService.UpdateStatus(item);
                    TempData["MessageSuccess"] = "Cập nhật Trạng Thái thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật Trạng Thái Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageSuccess"] = "Cập nhật Trạng Thái không thành công";
                return(Json(new MsgError()));
            }
        }
コード例 #4
0
        public IActionResult SaveItem(string Id = null)
        {
            ArticlesModel data           = new ArticlesModel();
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            int           IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchArticles()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsDanhMuc = CategoriesArticlesService.GetListItems();
            data.ListItemsAuthors = API.Areas.Admin.Models.USUsers.USUsersService.GetListItemsAuthor(4);
            data.ListItemType     = ArticlesService.GetListItemsType();
            Articles Item = new Articles()
            {
                PublishUp = DateTime.Now, PublishUpShow = DateTime.Now.ToString("dd/MM/yyyy"), Status = true
            };

            if (IdDC > 0)
            {
                Item = ArticlesService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }

            data.Item = Item;
            return(View(data));
        }
コード例 #5
0
        public ActionResult UpdateFeatured([FromQuery] string Ids, Boolean Featured)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Videos item           = new Videos()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Featured = Featured
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateFeatured = VideosService.UpdateFeatured(item);
                    TempData["MessageSuccess"] = "Cập nhật Nổi Bật thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật Nổi Bật Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageError"] = "Cập nhật Nổi Bật không thành công";
                return(Json(new MsgError()));
            }
        }
コード例 #6
0
        internal void InitInternal(MyModels models, bool isVisible, MyVisibilityExtFlags visibilityExt, MyCompatibilityDataForTheOldPipeline compatibilityData)
        {
            Models              = models;
            KeyColor            = new HalfVector3();
            m_instanceMaterials = MyObjectPoolManager.Allocate <MyInstanceMaterialList>();
            int instanceMaterialsCount = models.StandardModel.GetUniqueMaterialsCount(); // the other models do not use this mechanism

            m_instanceMaterials.SetSize(instanceMaterialsCount);
            for (int i = 0; i < instanceMaterialsCount; i++)
            {
                m_instanceMaterials.Set(i, MyInstanceMaterial.Default);
            }
            m_cpuCulledEntity = MyObjectPoolManager.Allocate <MyCpuCulledEntity>();

            // Bounding entity will be just registered, bounding box will be updated in the loopback OnAabbChange()
            BoundingBoxD boxTemporary = new BoundingBoxD(models.StandardModel.BoundingBox.Min, models.StandardModel.BoundingBox.Max);

            m_cpuCulledEntity.Register(boxTemporary, this);

            m_visibilityStrategy.Init(isVisible, visibilityExt);
            SetSingleInstanceTransformStrategy();

            m_lodStrategy.Init();

            Owner.SetMatrix(ref MatrixD.Identity);
            Owner.SetLocalAabb(models.StandardModel.BoundingBox);

            CompatibilityDataForTheOldPipeline = compatibilityData;
        }
コード例 #7
0
ファイル: MenusController.cs プロジェクト: chipdlk/THD
        public ActionResult SaveItem(MenusModel model)
        {
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int        IdDC           = Int32.Parse(MyModels.Decode(model.Item.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            MenusModel data           = model;

            if (ModelState.IsValid)
            {
                if (model.Item.Id == IdDC)
                {
                    model.Item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    MenusService.SaveItem(model.Item);
                    if (model.Item.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index", new { IdCoQuan = model.Item.IdCoQuan }));
                }
            }
            data.ListType = MenusService.GetListType();
            return(View(data));
        }
コード例 #8
0
        private void CutTree(int itemInstanceId, Vector3D hitWorldPosition, Vector3 hitNormal, float forceMultiplier = 1f)
        {
            int num;
            HkStaticCompoundShape shape = (HkStaticCompoundShape)base.Physics.RigidBody.GetShape();

            if (base.m_localIdToPhysicsShapeInstanceId.TryGetValue(itemInstanceId, out num))
            {
                MyEnvironmentItems.MyEnvironmentItemData itemData = base.m_itemsData[itemInstanceId];
                MyDefinitionId   id = new MyDefinitionId(base.Definition.ItemDefinitionType, itemData.SubtypeId);
                MyTreeDefinition environmentItemDefinition = (MyTreeDefinition)MyDefinitionManager.Static.GetEnvironmentItemDefinition(id);
                if ((base.RemoveItem(itemInstanceId, num, true, true) && ((environmentItemDefinition != null) && (environmentItemDefinition.BreakSound != null))) && (environmentItemDefinition.BreakSound.Length > 0))
                {
                    EndpointId targetEndpoint = new EndpointId();
                    MyMultiplayer.RaiseStaticEvent <Vector3D, string>(s => new Action <Vector3D, string>(MyTrees.PlaySound), hitWorldPosition, environmentItemDefinition.BreakSound, targetEndpoint, new Vector3D?(hitWorldPosition));
                }
                if (MyPerGameSettings.Destruction && (MyModels.GetModelOnlyData(environmentItemDefinition.Model).HavokBreakableShapes != null))
                {
                    if ((environmentItemDefinition.FallSound != null) && (environmentItemDefinition.FallSound.Length > 0))
                    {
                        this.CreateBreakableShape(environmentItemDefinition, ref itemData, ref hitWorldPosition, hitNormal, forceMultiplier, environmentItemDefinition.FallSound);
                    }
                    else
                    {
                        this.CreateBreakableShape(environmentItemDefinition, ref itemData, ref hitWorldPosition, hitNormal, forceMultiplier, "");
                    }
                }
            }
        }
コード例 #9
0
        protected override unsafe MyEntity DestroyItem(int itemInstanceId)
        {
            int      num;
            MyEntity entity;

            if (!base.m_localIdToPhysicsShapeInstanceId.TryGetValue(itemInstanceId, out num))
            {
                num = -1;
            }
            MyEnvironmentItems.MyEnvironmentItemData data = base.m_itemsData[itemInstanceId];
            base.RemoveItem(itemInstanceId, num, false, true);
            Vector3D position   = data.Transform.Position;
            string   modelAsset = data.Model.AssetName.Insert(data.Model.AssetName.Length - 4, "_broken");
            bool     flag       = false;

            if (MyModels.GetModelOnlyData(modelAsset) == null)
            {
                entity = MyDebris.Static.CreateDebris(data.Model.AssetName);
            }
            else
            {
                flag   = true;
                entity = MyDebris.Static.CreateDebris(modelAsset);
            }
            MyDebrisBase.MyDebrisBaseLogic gameLogic = entity.GameLogic as MyDebrisBase.MyDebrisBaseLogic;
            gameLogic.LifespanInMiliseconds = 0x4e20;
            MatrixD  xd     = MatrixD.CreateFromQuaternion(data.Transform.Rotation);
            MatrixD *xdPtr1 = (MatrixD *)ref xd;

            xdPtr1.Translation = position + (xd.Up * (flag ? ((double)0) : ((double)5)));
            gameLogic.Start(xd, Vector3.Zero, false);
            return(entity);
        }
コード例 #10
0
ファイル: ContactsController.cs プロジェクト: chipdlk/THD
        public IActionResult SaveItem(string Id = null, int Type = 0)
        {
            ContactsModel data           = new ContactsModel();
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchContacts()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item = new Contacts()
                {
                    CreatedDateShow = DateTime.Now.ToString("dd/MM/yyyy HH:mm"), Type = Type
                };
            }
            else
            {
                data.Item = ContactsService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
コード例 #11
0
ファイル: ContactsController.cs プロジェクト: chipdlk/THD
        public ActionResult SaveItem(Contacts model)
        {
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            ContactsModel data           = new ContactsModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy   = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.CreatedDate = DateTime.ParseExact(model.CreatedDateShow, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
                    ContactsService.SaveItem(model);
                    if (model.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index", new { @Type = model.Type, @EventId = model.EventId }));
                }
            }
            return(View(data));
        }
コード例 #12
0
        public IActionResult SaveItem(string Id = null)
        {
            ProductsCategoriesModel data = new ProductsCategoriesModel();
            string ControllerName        = this.ControllerContext.RouteData.Values["controller"].ToString();
            int    IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.ListItemsDanhMuc = ProductsCategoriesService.GetListItems();
            data.SearchData       = new SearchProductsCategories()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item = new ProductsCategories()
                {
                    Status = true
                };
            }
            else
            {
                data.Item = ProductsCategoriesService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
コード例 #13
0
        public IActionResult SaveItem(string Id = null)
        {
            USUsersModel data           = new USUsersModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchUSUsers()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsGroups = USGroupsService.GetListSelectItems();
            data.ListItemsStatus = USUsersService.GetStatusSelectItems();
            data.ListDMCoQuan    = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            data.ListDMChucVu    = DMChucVuService.GetListSelectItems();
            if (IdDC == 0)
            {
                data.Item = new USUsers();
            }
            else
            {
                data.Item = USUsersService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
コード例 #14
0
ファイル: VideosService.cs プロジェクト: chipdlk/THD
        public static Videos GetItem(decimal Id, string SecretId = null)
        {
            DataTable tabl = ConnectDb.ExecuteDataTableTask(Startup.ConnectionString, "SP_Videos",
                                                            new string[] { "@flag", "@Id" }, new object[] { "GetItem", Id });

            return((from r in tabl.AsEnumerable()
                    select new Videos
            {
                Id = (int)r["Id"],
                Title = (string)((r["Title"] == System.DBNull.Value) ? null : r["Title"]),
                IdType = (int)((r["IdType"] == System.DBNull.Value) ? null : r["IdType"]),
                Description = (string)((r["Description"] == System.DBNull.Value) ? null : r["Description"]),
                Link = (string)((r["Link"] == System.DBNull.Value) ? null : r["Link"]),
                CatId = (int?)((r["CatId"] == System.DBNull.Value) ? null : r["CatId"]),
                Image = (string)((r["Image"] == System.DBNull.Value) ? null : r["Image"]),
                Status = (Boolean)r["Status"],
                Featured = (Boolean)r["Featured"],
                Deleted = (Boolean)r["Deleted"],
                CreatedBy = (int)r["CreatedBy"],
                CreatedDate = (DateTime?)((r["CreatedDate"] == System.DBNull.Value) ? null : r["CreatedDate"]),
                ModifiedBy = (int?)((r["ModifiedBy"] == System.DBNull.Value) ? null : r["ModifiedBy"]),
                ModifiedDate = (DateTime?)((r["ModifiedDate"] == System.DBNull.Value) ? null : r["ModifiedDate"]),
                Ids = MyModels.Encode((int)r["Id"], SecretId),
            }).FirstOrDefault());
        }
コード例 #15
0
        private void GenerateStaticAsteroidPreviews(int sizeInPixels, DirectoryInfo directoryInfo)
        {
            var directoryGuiHelpers = Directory.CreateDirectory(Path.Combine(directoryInfo.FullName, "GuiHelpers"));
            int index = 1;

            foreach (MyMwcObjectBuilder_StaticAsteroid_TypesEnum enumValue in MyGuiAsteroidHelpers.MyMwcStaticAsteroidTypesEnumValues)
            {
                Debug.WriteLine(string.Format("Exporting Static Asteroid Preview {0}/{1} ..", index++,
                                              MyGuiAsteroidHelpers.MyMwcStaticAsteroidTypesEnumValues.Count));

                var modelEnum = MyStaticAsteroid.GetModelsFromType(enumValue).LOD0;
                var model     = MyModels.GetModelOnlyData(modelEnum);
                model.SetDrawTechnique(MyMeshDrawTechnique.MESH);

                string assetName = Path.GetFileName(MyModels.GetModelAssetName(modelEnum));
                assetName = assetName.Substring(assetName.Length - 5, 5) == "_LOD0"
                                ? assetName.Substring(0, assetName.Length - 5)
                                : assetName;

                var    result   = RenderModelPreview(model, sizeInPixels, sizeInPixels);
                string fileName = Path.Combine(directoryGuiHelpers.FullName, string.Format("{0}.dds", assetName));
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                //TODO
                //MyDDSFile.DDSToFile(fileName, true, result, false);
            }
        }
コード例 #16
0
ファイル: AblumsService.cs プロジェクト: chipdlk/THD
        public static List <Ablums> GetList(int Id = 0, string SecretId = null)
        {
            DataTable tabl = ConnectDb.ExecuteDataTableTask(Startup.ConnectionString, "SP_Ablums",
                                                            new string[] { "@flag", "@Id" }, new object[] { "GetListAlbums", Id });

            if (tabl == null)
            {
                return(new List <Ablums>());
            }
            else
            {
                return((from r in tabl.AsEnumerable()
                        select new Ablums
                {
                    Id = (int)r["Id"],
                    CatId = (int)r["CatId"],
                    Title = (string)r["Title"],
                    Description = (string)((r["Description"] == System.DBNull.Value) ? null : r["Description"]),
                    Images = (string)r["Images"],
                    Status = (Boolean)r["Status"],
                    LinkImg = (string)r["LinkImg"],
                    Ids = MyModels.Encode((int)r["Id"], SecretId)
                }).ToList());
            }
        }
コード例 #17
0
        private void ChangeModelLod0(MyMwcObjectBuilder_CargoBox_TypesEnum cargoBoxType)
        {
            var modelLod0Enum = GetModelLod0EnumFromType(cargoBoxType);
            var modelLod0     = MyModels.GetModelForDraw(modelLod0Enum);

            m_modelLod0 = modelLod0;
        }
コード例 #18
0
        private MyEntity CreateDebris(int itemId)
        {
            ProfilerShort.Begin("Spawning tree");
            var itemData = m_sector.DataView.Items[itemId];

            Vector3D worldPos = itemData.Position + m_sector.SectorCenter;

            var model = m_sector.Owner.GetModelForId(itemData.ModelIndex);

            var      brokenModel = model.Model.Insert(model.Model.Length - 4, "_broken");
            MyEntity debris;
            bool     hasBrokenModel = false;

            if (MyModels.GetModelOnlyData(brokenModel) != null)
            {
                hasBrokenModel = true;
                debris         = MyDebris.Static.CreateDebris(brokenModel);
            }
            else
            {
                debris = MyDebris.Static.CreateDebris(model.Model);
            }

            var debrisLogic = (MyDebrisBase.MyDebrisBaseLogic)debris.GameLogic;

            debrisLogic.RandomScale           = 1;
            debrisLogic.LifespanInMiliseconds = BrokenItemLifeSpan;
            var m = MatrixD.CreateFromQuaternion(itemData.Rotation);

            m.Translation = worldPos + m.Up * (hasBrokenModel ? 0 : 5);
            debrisLogic.Start(m, Vector3.Zero, 1, false);
            ProfilerShort.End();
            return(debris);
        }
コード例 #19
0
ファイル: MenusController.cs プロジェクト: chipdlk/THD
        public IActionResult SaveItem(string Id = null, int IdCoQuan = 1)
        {
            MenusModel data           = new MenusModel();
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();

            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchMenus()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = "", IdCoQuan = IdCoQuan
            };
            data.ListItemsArticle       = ArticlesService.GetListStaticArticle();
            data.ListType               = MenusService.GetListType();
            data.ListCategoriesArticles = CategoriesArticlesService.GetList();
            data.ListCategoriesProducts = ProductsCategoriesService.GetList();
            data.ListItemsMenus         = MenusService.GetListItems(true, IdCoQuan);

            if (IdDC == 0)
            {
                data.Item = new Menus();
            }
            else
            {
                data.Item = MenusService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
コード例 #20
0
ファイル: MenusService.cs プロジェクト: chipdlk/THD
        public static Menus GetItem(decimal Id, string SecretId = null)
        {
            DataTable tabl = ConnectDb.ExecuteDataTableTask(Startup.ConnectionString, "SP_Menus",
                                                            new string[] { "@flag", "@Id" }, new object[] { "GetItem", Id });

            return((from r in tabl.AsEnumerable()
                    select new Menus
            {
                Id = (int)r["Id"],
                Title = (string)r["Title"],
                CatId = (int)r["CatId"],
                StaticId = (int)r["StaticId"],
                Link = (string)((r["Link"] == System.DBNull.Value) ? null : r["Link"]),
                IdCoQuan = (int)((r["IdCoQuan"] == System.DBNull.Value) ? 0 : r["IdCoQuan"]),
                ParentId = (int)r["ParentId"],
                Type = (int)r["Type"],
                ModifiedBy = (int?)((r["ModifiedBy"] == System.DBNull.Value) ? null : r["ModifiedBy"]),
                Status = (Boolean?)((r["Status"] == System.DBNull.Value) ? null : r["Status"]),
                Deleted = (Boolean?)((r["Deleted"] == System.DBNull.Value) ? null : r["Deleted"]),
                ModifiedDate = (DateTime?)((r["ModifiedDate"] == System.DBNull.Value) ? null : r["ModifiedDate"]),
                ArticleId = (int?)((r["ArticleId"] == System.DBNull.Value) ? null : r["ArticleId"]),
                Ordering = (int?)((r["Ordering"] == System.DBNull.Value) ? null : r["Ordering"]),
                Icon = (string)((r["Icon"] == System.DBNull.Value) ? null : r["Icon"]),
                Ids = MyModels.Encode((int)r["Id"], SecretId),
            }).FirstOrDefault());
        }
コード例 #21
0
        public ActionResult UpdateNotification([FromQuery] string Ids, Boolean Notification)
        {
            string   ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            Articles item           = new Articles()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Notification = Notification
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateFeatured = ArticlesService.UpdateNotification(item);
                    TempData["MessageSuccess"] = "Cập nhật thông báo thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật thông báo Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageSuccess"] = "Cập nhật thông báo không thành công";
                return(Json(new MsgError()));
            }
        }
コード例 #22
0
        private void ProcessBatch()
        {
            foreach (var modifyModel in m_batchedModifyItems)
            {
                ModifyItemModel(modifyModel.LocalId, modifyModel.LocalModelId, false, false);
            }

            if (Physics != null)
            {
                Physics.ContactPointCallback -= Physics_ContactPointCallback;
                Physics.Close();
                Physics = null;
            }

            BoundingBoxD aabbWorld = BoundingBoxD.CreateInvalid();
            Dictionary <MyStringHash, HkShape> subtypeIdToShape = new Dictionary <MyStringHash, HkShape>(MyStringHash.Comparer);
            HkStaticCompoundShape sectorRootShape = new HkStaticCompoundShape(HkReferencePolicy.None);

            m_physicsShapeInstanceIdToLocalId.Clear();
            m_localIdToPhysicsShapeInstanceId.Clear();

            foreach (var item in m_itemsData)
            {
                if (!item.Value.Enabled)
                {
                    continue;
                }

                int     physicsShapeInstanceId;
                var     data    = item.Value;
                int     modelId = data.ModelId;
                MyModel model   = MyModels.GetModelOnlyData(MyModel.GetById(modelId));
                var     matrix  = data.Transform.TransformMatrix;

                aabbWorld.Include(model.BoundingBox.Transform(matrix));

                if (AddPhysicsShape(data.SubtypeId, model, ref matrix, sectorRootShape, subtypeIdToShape, out physicsShapeInstanceId))
                {
                    m_physicsShapeInstanceIdToLocalId[physicsShapeInstanceId] = item.Key;
                    m_localIdToPhysicsShapeInstanceId[item.Key] = physicsShapeInstanceId;
                }
            }

            foreach (var item in m_batchedAddItems)
            {
                var matrix     = MatrixD.CreateWorld(item.Position, Vector3D.Forward, Vector3D.Up);
                var definition = m_definition.GetItemDefinition(item.SubtypeId);
                AddItem(definition, ref matrix, ref aabbWorld, sectorRootShape, subtypeIdToShape, item.LocalModelId);
            }

            PrepareItemsPhysics(sectorRootShape, ref aabbWorld);
            PrepareItemsGraphics();

            foreach (var pair in subtypeIdToShape)
            {
                pair.Value.RemoveReference();
            }

            subtypeIdToShape.Clear();
        }
コード例 #23
0
        /// <summary>
        /// Check if the missile does not collide too close to ship
        /// after shooting and correct its starting position if it does.
        /// </summary>
        private Vector3 CorrectPosition(Vector3 position, Vector3 direction, MyEntity viewerEntity)
        {
            //var predictedTrajectory = new MyLine(
            //    position - (MyMissileConstants.DISTANCE_TO_CHECK_MISSILE_CORRECTION) * direction,
            //    position + (MyMissileConstants.DISTANCE_TO_CHECK_MISSILE_CORRECTION) * direction,
            //    true);
            //var intersection = MyEntities.GetIntersectionWithLine(ref predictedTrajectory, this, viewerEntity);


            // This is fix for missles hitting voxels when you are near them (missles do not use per triangle collision as optimalization)
            float radius = MyModels.GetModel(MyModelsEnum.Missile).BoundingSphere.Radius;

            BoundingSphere boundingSphere = viewerEntity.WorldVolume;

            boundingSphere.Center += viewerEntity.WorldMatrix.Up * 1;

            var intersection = MyEntities.GetIntersectionWithSphere(ref boundingSphere, this, viewerEntity);

            if (intersection != null && !(intersection is MyMissile))
            {
                position = viewerEntity.GetPosition() + 2 * Vector3.One;
            }

            return(position);
        }
コード例 #24
0
 private void StartJobs()
 {
     foreach (var pool in m_pools)
     {
         foreach (var model in pool.Value)
         {
             if (model.Value.Count < PREALLOCATE_COUNT && !m_tracker.Exists(pool.Key))
             {
                 MyPhysicalModelDefinition def;
                 MyDefinitionManager.Static.TryGetDefinition <MyPhysicalModelDefinition>(pool.Key, out def);
                 var modelData = MyModels.GetModelOnlyData(def.Model);
                 if (modelData.HavokBreakableShapes == null)
                 {
                     continue;
                 }
                 MyBreakableShapeCloneJob.Args args = new MyBreakableShapeCloneJob.Args();
                 args.Model        = model.Key;
                 args.DefId        = pool.Key;
                 args.ShapeToClone = modelData.HavokBreakableShapes[0];
                 args.Count        = PREALLOCATE_COUNT - pool.Value.Count;
                 args.Tracker      = m_tracker;
                 MyBreakableShapeCloneJob.Start(args);
             }
         }
     }
 }
コード例 #25
0
        internal void InitAndRegister(MyInstanceComponent instance, MyModels models, bool isVisible, MyVisibilityExtFlags visibilityExt, MyCompatibilityDataForTheOldPipeline compatibilityData)
        {
            MyRenderProxy.Assert(!m_instances.Contains(instance));

            instance.InitInternal(models, isVisible, visibilityExt, compatibilityData);
            m_instances.Add(instance);
        }
コード例 #26
0
ファイル: ProductsDetailService.cs プロジェクト: chipdlk/THD
        public static List <ProductsOrderDetail> GetListPagination(SearchProductsOrderDetail dto, string SecretId)
        {
            var tabl = ConnectDb.ExecuteDataTableTask(Startup.ConnectionString, "SP_ProductsOrderDetail",
                                                      new string[] { "@flag", "@ProductOrderId" },
                                                      new object[] { "GetListByProductsOrderDetailId", dto.ProductOrderId });

            if (tabl == null)
            {
                return(new List <ProductsOrderDetail>());
            }
            else
            {
                return((from r in tabl.AsEnumerable()
                        select new ProductsOrderDetail
                {
                    Id = (int)r["Id"],
                    ProductId = (int)r["ProductId"],
                    Name = (string)((r["Name"] == System.DBNull.Value) ? null : r["Name"]),
                    Price = (decimal)((r["Price"] == System.DBNull.Value) ? 0 : r["Price"]),
                    Quantity = (int)((r["Quantity"] == System.DBNull.Value) ? null : r["Quantity"]),
                    Unit = (string)((r["Unit"] == System.DBNull.Value) ? null : r["Unit"]),
                    Ids = MyModels.Encode((int)r["Id"], SecretId),
                }).ToList());
            }
        }
コード例 #27
0
        public ActionResult DeleteItem(string Id)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Ablums model          = new Ablums()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (model.Id > 0)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    AblumsService.DeleteItem(model);
                    TempData["MessageSuccess"] = "Xóa thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Xóa Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch {
                TempData["MessageSuccess"] = "Xóa không thành công";
                return(Json(new MsgError()));
            }
        }
コード例 #28
0
        private void GenerateSmallShipPreviews(int sizeInPixels, DirectoryInfo directoryInfo)
        {
            var directoryGuiHelpers = Directory.CreateDirectory(Path.Combine(directoryInfo.FullName, "GuiHelpers"));
            int index = 1;

            foreach (MyMwcObjectBuilder_SmallShip_TypesEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues)
            {
                Debug.WriteLine(string.Format("Exporting SmallShip Preview {0}/{1} ..", index++,
                                              MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues.Length));

                var modelEnum = MyShipTypeConstants.GetShipTypeProperties(enumValue).Visual.ModelLod0Enum;
                var model     = MyModels.GetModelForDraw(modelEnum);

                string assetName = Path.GetFileName(MyModels.GetModelAssetName(modelEnum));

                var    result   = RenderModelPreview(model, sizeInPixels, sizeInPixels);
                string fileName = Path.Combine(directoryGuiHelpers.FullName, string.Format("{0}.dds", assetName));
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                //TODO
                //MyDDSFile.DDSToFile(fileName, true, result, false);
            }
        }
コード例 #29
0
        public static void GetAllBlockBreakableShapeNames(MyCubeBlockDefinition blockDef, HashSet <Tuple <string, float> > outNamesAndBuildProgress)
        {
            string modelAsset = blockDef.Model;

            if (MyModels.GetModelOnlyData(modelAsset).HavokBreakableShapes == null)
            {
                MyDestructionData.Static.LoadModelDestruction(modelAsset, blockDef, Vector3.One, true, false);
            }
            GetAllBlockBreakableShapeNames(MyModels.GetModelOnlyData(modelAsset).HavokBreakableShapes[0], outNamesAndBuildProgress, 1f);
            if (blockDef.BuildProgressModels != null)
            {
                float buildRatioUpperBound = 0f;
                foreach (MyCubeBlockDefinition.BuildProgressModel model in blockDef.BuildProgressModels)
                {
                    modelAsset = model.File;
                    if (MyModels.GetModelOnlyData(modelAsset).HavokBreakableShapes == null)
                    {
                        MyDestructionData.Static.LoadModelDestruction(modelAsset, blockDef, Vector3.One, true, false);
                    }
                    float buildProgress = 0.5f * (model.BuildRatioUpperBound + buildRatioUpperBound);
                    GetAllBlockBreakableShapeNames(MyModels.GetModelOnlyData(modelAsset).HavokBreakableShapes[0], outNamesAndBuildProgress, buildProgress);
                    buildRatioUpperBound = model.BuildRatioUpperBound;
                }
            }
        }
コード例 #30
0
ファイル: ReviewsController.cs プロジェクト: chipdlk/THD
        public IActionResult SaveItem(string Id = null, int CatId = 0, int IdCoQuan = 1)
        {
            ReviewsModel data           = new ReviewsModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchReviews()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };

            if (IdDC == 0)
            {
                data.Item = new Reviews()
                {
                    ReviewDate = DateTime.Now, ReviewDateShow = DateTime.Now.ToString("dd/MM/yyyy"), DisplayOder = 1, Status = true
                };
            }
            else
            {
                data.Item = ReviewsService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }
            data.ListStart = ReviewsService.GetListStart();
            return(View(data));
        }