///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (ReverseInstance != null) { ReverseInstance.Dispose(); ReverseInstance = null; } if (ForwardInstance != null) { ForwardInstance.Dispose(); ForwardInstance = null; } Solution = null; Solution = null; if (_entityList != null) { foreach (Entity item in EntityList) { item.Dispose(); } EntityList.Clear(); EntityList = null; } #region protected #endregion protected base.OnDispose(); }
/// <summary> /// Initializes the IconCollection /// Creates Orbitrings, TextIcons and Entityicons and adds them to Collection /// </summary> /// <param name="entities"></param> /// <param name="camera"></param> public void Init(IEnumerable <Entity> entities, Camera2dv2 camera) { IconDict.Clear(); OrbitList.Clear(); TextIconList.Clear(); EntityList.Clear(); scale = new ScaleIcon(camera); foreach (var item in entities) { if (item.HasDataBlob <OrbitDB>() && item.GetDataBlob <OrbitDB>().Parent != null) { OrbitRing ring = new OrbitRing(item, camera); OrbitList.Add(ring); } if (item.HasDataBlob <NameDB>()) { TextIconList.Add(new TextIcon(item, camera)); } EntityIcon entIcon = new EntityIcon(item, camera); EntityList.Add(entIcon); IconDict.Add(item.Guid, entIcon); } }
private static int FindAlchemyResult(EntityList ingredients, EntityList ready, ref bool refExact) { for (int i = 1; i < dbRecipes.Length; i++) { RecipeRec recipe = dbRecipes[i]; int t_cnt = AuxUtils.GetTokensCount(recipe.Ingredients, "+"); int finded = 0; ready.Clear(); for (int t = 1; t <= t_cnt; t++) { string tok = AuxUtils.GetToken(recipe.Ingredients, "+", (sbyte)t); char f = tok[0]; if (f != '_' && f != '!') { f = '?'; } else { tok = tok.Substring(1, tok.Length - 1); } if (f == '_') { Item item = (Item)ingredients.FindByCLSID(GlobalVars.iid_DeadBody); NWCreature db = (NWCreature)item.Contents.GetItem(0); if (db.Entry.Sign.CompareTo(tok) == 0) { finded++; ready.Add(item); } } else { int id = GlobalVars.nwrDB.FindEntryBySign(tok).GUID; Item item = (Item)ingredients.FindByCLSID(id); if (item != null && (f == '?' || (f == '!' && item.State == ItemState.is_Blessed))) { finded++; ready.Add(item); } } } if (finded >= t_cnt) { refExact = (finded == t_cnt); return(i); } } refExact = false; return(-1); }
/* Resets all entity lists to empty */ private void ClearLists() { PlayerList.Clear(); PlanetList.Clear(); ProjectileList.Clear(); BlackHoleList.Clear(); BloodParticleList.Clear(); EntityList.Clear(); PhysicalObjectList.Clear(); GravityPointList.Clear(); }
/// <summary> /// Initializes the IconCollection /// Creates Orbitrings, TextIcons and Entityicons and adds them to Collection /// </summary> /// <param name="entities"></param> /// <param name="camera"></param> public void Init(IEnumerable <Entity> entities, Camera2dv2 camera) { IconDict.Clear(); OrbitList.Clear(); TextIconList.Clear(); EntityList.Clear(); _camera = camera; Scale = new ScaleIcon(_camera); foreach (var item in entities) { AddNewIcon(item); } }
///// <summary> ///// Method to unbuff any buffed characters at beginning of round before entity list is remade ///// </summary> //public void UnbuffCharacters() //{ // foreach (var entity in EntityList) // { // if (entity.FirstBuff) // { // entity.UnbuffCharacterStats(); // entity.FirstBuff = false; // } // } //} /// <summary> /// Populates the EntityList with the characters and monsters who are alive /// </summary> /// <returns></returns> public List <BattleEntityModel> MakeEntityList() { // Start from a clean list of players EntityList.Clear(); // Remember the Insert order, used for Sorting var ListOrder = 0; foreach (var data in CharacterList) { if (data.Alive) { EntityList.Add( new BattleEntityModel(data) { // Remember the order ListOrder = ListOrder }); ListOrder++; } } foreach (var data in MonsterList) { if (data.Alive) { EntityList.Add( new BattleEntityModel(data) { // Remember the order ListOrder = ListOrder }); ListOrder++; } } return(EntityList); }
public int ForgeItem(EntityList ingredients, int itemID) { float sum = 0F; MaterialKind i = MaterialKind.mk_None; int result = CheckForgeIngredients(ingredients, ref sum, ref i); if (result != RC_Ok) { if (result == RC_DifferentMetals) { // dummy } } else { int num = ingredients.Count; for (int j = 0; j < num; j++) { Item item = (Item)ingredients.GetItem(j); fPlayer.DeleteItem(item); } ingredients.Clear(); if (itemID == GlobalVars.iid_Ingot) { AddForgeItem(GlobalVars.iid_Ingot, sum, i); } else { ItemEntry iEntry = (ItemEntry)GlobalVars.nwrDB.GetEntry(itemID); AddForgeItem(itemID, iEntry.Weight, i); float rem = ((sum - iEntry.Weight)); if (rem > 0f) { AddForgeItem(GlobalVars.iid_Ingot, rem, i); } } } return(result); }
public void ClearEntityList() { EntityList?.Clear(); }
//-------------------------------------------------------------------------------------------------- public override void Remove() { EntityList.ForEach(e => e.Remove()); EntityList.Clear(); base.Remove(); }
/// <summary> /// 回收实例 /// </summary> /// <param name="instance">实例</param> public static void Recycle(EntityList instance) { instance.Clear(); s_InstancePool.Add(instance); }
private void BuildAssembly() { model1.AntiAliasing = (antiAliasingCheckBox.IsChecked == true) ? true : false; model1.Rendered.PlanarReflections = (planarCheckBox.IsChecked == true) ? true : false; model1.UseShaders = (shadersCheckBox.IsChecked == true) ? true : false; model1.WriteDepthForTransparents = (depthCheckBox.IsChecked == true) ? true : false; model1.Flat.ShowEdges = (edgesCheckBox.IsChecked == true) ? true : false; model1.HiddenLines.ShowEdges = (edgesCheckBox.IsChecked == true) ? true : false; model1.Rendered.ShowEdges = (edgesCheckBox.IsChecked == true) ? true : false; model1.Shaded.ShowEdges = (edgesCheckBox.IsChecked == true) ? true : false; model1.Wireframe.ShowEdges = (edgesCheckBox.IsChecked == true) ? true : false; _entityList.Clear(); model1.Entities.Clear(); model1.Blocks.Clear(); if (model1.Materials.Count > 0) { if (!transparencyCheckBox.IsChecked == true) { model1.Materials[_wallMatName].Diffuse = System.Drawing.Color.FromArgb(25, 150, 25); } else { model1.Materials[_wallMatName].Diffuse = System.Drawing.Color.FromArgb(100, 25, 150, 25); } } // Variables for unique Mesh (SingleMesh) List <Point3D> globalVerts = new List <Point3D>(); List <IndexTriangle> globalTris = new List <IndexTriangle>(); int offset = globalVerts.Count; // Pillar column block devDept.Eyeshot.Block column = new devDept.Eyeshot.Block("squareCol"); // creates a gray box Mesh m1 = Mesh.CreateBox(COLUMN_B, COLUMN_H, COLUMN_L); // apply texture if Texture is true if (textureCheckBox.IsChecked == true) { m1.ApplyMaterial("Bricks", textureMappingType.Cubic, 1, 1); } else { m1.ColorMethod = colorMethodType.byEntity; m1.Color = System.Drawing.Color.LightGray; m1.MaterialName = _concreteMatName; } for (int i = 0; i < m1.Vertices.Length; i++) { globalVerts.Add(m1.Vertices[i]); } for (int i = 0; i < m1.Triangles.Length; i++) { globalTris.Add(new ColorTriangle(offset + m1.Triangles[i].V1, offset + m1.Triangles[i].V2, offset + m1.Triangles[i].V3, System.Drawing.Color.Gray)); } Plane p = new Plane(new Vector3D(0, 1, 0)); devDept.Eyeshot.Entities.Attribute at = new devDept.Eyeshot.Entities.Attribute(p, new Point3D(-(TEXT_HEIGHT + TEXT_PAD), COLUMN_B / 2, COLUMN_L / 2), "Name", "Frame", TEXT_HEIGHT); at.Alignment = devDept.Eyeshot.Entities.Text.alignmentType.BaselineCenter; at.UpsideDown = true; column.Entities.Add(at); column.Entities.Add(m1); // adds the block to the master block dictionary model1.Blocks.Add(column); BlockReference reference; // Beam devDept.Eyeshot.Block beam = new devDept.Eyeshot.Block("beam"); // creates a gray box Mesh m2 = Mesh.CreateBox(BEAM_B, BEAM_L, BEAM_H); m2.ColorMethod = colorMethodType.byEntity; m2.Color = System.Drawing.Color.LightGray; m2.MaterialName = _concreteMatName; offset = globalVerts.Count; for (int i = 0; i < m2.Vertices.Length; i++) { globalVerts.Add(m2.Vertices[i]); } for (int i = 0; i < m2.Triangles.Length; i++) { globalTris.Add(new ColorTriangle(offset + m2.Triangles[i].V1, offset + m2.Triangles[i].V2, offset + m2.Triangles[i].V3, System.Drawing.Color.Gray)); } beam.Entities.Add(m2); p = new Plane(new Vector3D(1, 0, 0)); at = new devDept.Eyeshot.Entities.Attribute(p, new Point3D(BEAM_B / 2, BEAM_L / 2, BEAM_H + TEXT_PAD), "Name", "Frame", TEXT_HEIGHT); at.Alignment = devDept.Eyeshot.Entities.Text.alignmentType.BaselineCenter; at.Color = System.Drawing.Color.Green; at.ColorMethod = colorMethodType.byEntity; beam.Entities.Add(at); // adds the block to the master block dictionary model1.Blocks.Add(beam); // Shell devDept.Eyeshot.Block shell = new devDept.Eyeshot.Block("shell"); double shellB = BEAM_L / _shellSubValue; double shellH = COLUMN_L / _shellSubValue; // Mesh Mesh m3 = Mesh.CreateBox(shellB, SHELL_TICKNESS, shellH); m3.ColorMethod = colorMethodType.byEntity; m3.Color = System.Drawing.Color.LightGreen; m3.MaterialName = "wallMat"; shell.Entities.Add(m3); // adds the block to the master block dictionary model1.Blocks.Add(shell); for (int k = 0; k < _floorsValue; k++) { for (int j = 0; j <= _bayYValue; j++) { for (int i = 0; i <= _bayXValue; i++) { if (pillarsCheckBox.IsChecked == true) { reference = new BlockReference(i * BEAM_L - COLUMN_B / 2, j * BEAM_L - COLUMN_H / 2, k * COLUMN_L, "squareCol", 1, 1, 1, 0); if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh) { Mesh mm = (Mesh)model1.Blocks["squareCol"].Entities[1].Clone(); mm.Translate(i * BEAM_L - COLUMN_B / 2, j * BEAM_L - COLUMN_H / 2, k * COLUMN_L); offset = globalVerts.Count; globalVerts.AddRange(mm.Vertices); for (int n = 0; n < mm.Triangles.Length; n++) { globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1, offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.Gray)); } } if (labelCheckBox.IsChecked == true) { reference.Attributes.Add("Name", string.Format("Pillar_{0},{1},{2}", i, j, k)); } _entityList.Add(reference); } if (showBeamXCheckBox.IsChecked == true) { if (j <= _bayYValue && i < _bayXValue) { // Parallel beams to X Transformation t = new Transformation(); t.Rotation(-Math.PI / 2, Vector3D.AxisZ); Transformation t2 = new Transformation(); t2.Translation(i * BEAM_L, j * BEAM_L + BEAM_B / 2, (k + 1) * COLUMN_L - BEAM_H / 2); reference = new BlockReference(t2 * t, "beam"); if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh) { Mesh mm = (Mesh)model1.Blocks["beam"].Entities[0].Clone(); mm.TransformBy(t2 * t); offset = globalVerts.Count; globalVerts.AddRange(mm.Vertices); for (int n = 0; n < mm.Triangles.Length; n++) { globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1, offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.Gray)); } } if (labelCheckBox.IsChecked == true) { reference.Attributes.Add("Name", string.Format("Beam_{0},{1},{2}", i, j, k)); } _entityList.Add(reference); } } if (showBeamYCheckBox.IsChecked == true) { if (i <= _bayXValue && j < _bayYValue) { // Parallel beams to X Transformation t = new Transformation(); t.Translation(i * BEAM_L - BEAM_B / 2, j * BEAM_L, (k + 1) * COLUMN_L - BEAM_H / 2); reference = new BlockReference(t, "beam"); if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh) { Mesh mm = (Mesh)model1.Blocks["beam"].Entities[0].Clone(); mm.TransformBy(t); offset = globalVerts.Count; globalVerts.AddRange(mm.Vertices); for (int n = 0; n < mm.Triangles.Length; n++) { globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1, offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.Gray)); } } if (labelCheckBox.IsChecked == true) { reference.Attributes.Add("Name", string.Format("Beam_{0},{1},{2}", i, j, k)); } _entityList.Add(reference); } } if (shellCheckBox.IsChecked == true) { if ((j == 0 || j == _bayYValue) && i < _bayXValue) { for (int i1 = 0; i1 < _shellSubValue; i1++) { for (int j1 = 0; j1 < _shellSubValue; j1++) { Transformation t = new Transformation(); t.Translation(i * BEAM_L + i1 * shellB, j * BEAM_L - SHELL_TICKNESS / 2, k * COLUMN_L + j1 * shellH); reference = new BlockReference(t, "shell"); if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh) { Mesh mm = (Mesh)model1.Blocks["shell"].Entities[0].Clone(); mm.TransformBy(t); offset = globalVerts.Count; globalVerts.AddRange(mm.Vertices); for (int n = 0; n < mm.Triangles.Length; n++) { globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1, offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.FromArgb(123, System.Drawing.Color.LightGreen))); } } _entityList.Add(reference); } } } } if (nodesCheckBox.IsChecked == true) { Joint joint1 = new Joint(i * BEAM_L, j * BEAM_L, k * COLUMN_L, 40, 2); joint1.Color = System.Drawing.Color.Blue; joint1.ColorMethod = colorMethodType.byEntity; Joint joint2 = new Joint(i * BEAM_L, j * BEAM_L, (k + 1) * COLUMN_L, 40, 2); joint2.Color = System.Drawing.Color.Blue; joint2.ColorMethod = colorMethodType.byEntity; _entityList.Add(joint1); _entityList.Add(joint2); } } if (shellCheckBox.IsChecked == true) { if (j == 0) { for (int l = 0; l < _bayYValue; l++) { for (int i1 = 0; i1 < _shellSubValue; i1++) { for (int j1 = 0; j1 < _shellSubValue; j1++) { Transformation t = new Transformation(); t.Translation(l * BEAM_L + i1 * shellB, j * BEAM_L - SHELL_TICKNESS / 2, k * COLUMN_L + j1 * shellH); Transformation t2 = new Transformation(); t2.Rotation(Math.PI / 2, Vector3D.AxisZ); reference = new BlockReference(t2 * t, "shell"); if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh) { Mesh mm = (Mesh)model1.Blocks["shell"].Entities[0].Clone(); mm.TransformBy(t2 * t); offset = globalVerts.Count; globalVerts.AddRange(mm.Vertices); for (int n = 0; n < mm.Triangles.Length; n++) { globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1, offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.FromArgb(123, System.Drawing.Color.LightGreen))); } } _entityList.Add(reference); } } } } if (j == _bayYValue) { for (int l = 0; l < _bayYValue; l++) { for (int i1 = 0; i1 < _shellSubValue; i1++) { for (int j1 = 0; j1 < _shellSubValue; j1++) { Transformation t = new Transformation(); t.Translation(l * BEAM_L + i1 * shellB, -SHELL_TICKNESS / 2, k * COLUMN_L + j1 * shellH); Transformation t2 = new Transformation(); t2.Rotation(Math.PI / 2, Vector3D.AxisZ); Transformation t3 = new Transformation(); t3.Translation(_bayXValue * BEAM_L, 0, 0); reference = new BlockReference(t3 * t2 * t, "shell"); if ((structureType)structureModeEnumButton.Value == structureType.SingleMesh) { Mesh mm = (Mesh)model1.Blocks["shell"].Entities[0].Clone(); mm.TransformBy(t3 * t2 * t); offset = globalVerts.Count; globalVerts.AddRange(mm.Vertices); for (int n = 0; n < mm.Triangles.Length; n++) { globalTris.Add(new ColorTriangle(offset + mm.Triangles[n].V1, offset + mm.Triangles[n].V2, offset + mm.Triangles[n].V3, System.Drawing.Color.FromArgb(123, System.Drawing.Color.LightGreen))); } } _entityList.Add(reference); } } } } } } } _buildingMesh = new Mesh(globalVerts, globalTris); _buildingMesh.ColorMethod = colorMethodType.byEntity; model1.Entities.AddRange(_entityList); switch ((structureType)structureModeEnumButton.Value) { case structureType.Flattened: { Entity[] entList = model1.Entities.Explode(); model1.Entities.Clear(); model1.Entities.AddRange(entList); model1.Invalidate(); break; } case structureType.SingleMesh: { model1.Entities.Clear(); model1.Entities.Add(_buildingMesh); model1.Invalidate(); break; } case structureType.Assembly: { model1.Invalidate(); break; } } TreeViewUtility.PopulateTree(treeView1, model1.Entities.ToList(), model1.Blocks); }
/// <summary> /// 路径查找 /// </summary> /// <param name="list"></param> /// <param name="path"></param> /// <param name="name"></param> /// <returns></returns> public static TEntity FindByPath(EntityList <TEntity> list, String path, String name) { if (list == null || list.Count < 1) { return(null); } if (String.IsNullOrEmpty(path) || String.IsNullOrEmpty(name)) { return(null); } String[] ss = path.Split(new Char[] { '.', '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); if (ss == null || ss.Length < 1) { return(null); } // 尝试一次性查找 TEntity entity = list.Find(name, path); if (entity != null) { return(entity); } EntityList <TEntity> list3 = new EntityList <TEntity>(); for (int i = 0; i < ss.Length; i++) { // 找到符合当前级别的所有节点 EntityList <TEntity> list2 = list.FindAll(name, ss[i]); if (list2 == null || list2.Count < 1) { return(null); } // 是否到了最后 if (i == ss.Length - 1) { list3 = list2; break; } // 找到它们的子节点 list3.Clear(); foreach (TEntity item in list2) { if (item.Childs != null && item.Childs.Count > 0) { list3.AddRange(item.Childs); } } if (list3 == null || list3.Count < 1) { return(null); } } if (list3 != null && list3.Count > 0) { return(list[0]); } else { return(null); } }
/// <summary> /// 从原始表中移除聚合。 /// </summary> /// <param name="repository">表示当前 <see cref="EntityList" /> 对应的仓库。</param> /// <param name="entityList">表示一个领域对象的集合。</param> private void DeleteOriginalData(IRepository repository, EntityList entityList) { entityList.Clear(); this.SaveList(repository, entityList); }
/// <summary> /// Tells the EntityEngine that it is finished with the NodeLists it is using. /// </summary> public virtual void Destroy() { ReleaseHandler(RequiredAspects); EntityList.Clear(); }
/// <summary> /// A method used to perform startup logic, it is called before the first Update call. /// </summary> public virtual void Initialize() { EntityList.Clear(); EntityList = RequestHandler(RequiredAspects); }