public void TestShapeSerialization() { const string TEST_SCENENAME = "TestShapeSerialization.scene"; // setup new test project/scene TestManager.Helpers.CreateTestScene(TEST_SCENENAME); EditorProject project = EditorApp.Project; try { // create all registered shapes foreach (IShapeCreatorPlugin plugin in EditorManager.ShapeCreatorPlugins) { plugin.ExecutePlugin(); } string projectFile = project.PathName; int numCreatedShapes = CountShapeInstances(project.Scene); // cause engine view to refresh (to see that rendering the shapes doesn't cause a crash) TestManager.Helpers.ProcessEvents(); // close map project.Save(); ShapeCollection c1 = project.Scene.ActiveLayer.Root.ChildCollection; EditorManager.Scene.Close(); project.Close(); // reload map project = EditorManager.ProjectFactory.CreateInstance(null) as EditorProject; Assert.IsNotNull(project); project.Load(projectFile); EditorManager.Project = project; bool bResult = project.OpenScene(TEST_SCENENAME); Assert.IsTrue(bResult); // verify that shape instances exist int numLoadedShapes = CountShapeInstances(project.Scene); ShapeCollection c2 = project.Scene.ActiveLayer.Root.ChildCollection; for (int i = 0; i < c1.Count; i++) { ShapeBase s1 = c1[i]; ShapeBase s2 = c2[i]; Assert.AreEqual(s1.GetType(), s2.GetType()); } Assert.AreEqual(numCreatedShapes, numLoadedShapes); TestManager.Helpers.CloseTestProject(); } catch (Exception ex) { EditorManager.DumpException(ex, true); } }
private void UpdateTextboxValues() { ShapeBase shape = dialogProcessor.MultiSelection.FirstOrDefault(); if (shape is null) { propertyDict.ToList( ).ForEach(tb => tb.Key.Text = string.Empty); } else { foreach (PropertyInfo prop in shape.GetType( ).GetProperties( )) { if (propertyDict.Any(p => p.Value == prop.Name)) { KeyValuePair <TextBox, string> dictItem = propertyDict.FirstOrDefault(p => p.Value == prop.Name); dictItem.Key.Text = prop.GetValue(shape).ToString( ); } } } }
void AddSoundShapesRecursive(ShapeCollection shapeList, ShapeBase parent) { if (parent.ShapeVirtualCounter > 0 || !parent.Modifiable) { return; } ShapeBase soundShape = parent as ShapeObject3D; if (soundShape != null && (soundShape.GetType().FullName == "SoundEditorPlugin.SoundShape" || soundShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape")) { shapeList.Add(soundShape); } if (parent.HasChildren()) { foreach (ShapeBase shape in parent.ChildCollection) { AddSoundShapesRecursive(shapeList, shape); } } }
private void setColor(GalleryItemClickEventArgs e) { if (ActiveMdiChild != null && ActiveMdiChild is frmDrawBoard) { if ((bool)grpSkinMode.EditValue) //General { ThongSo.EntityColor = (Color)e.Item.Tag; ThongSo.AttributeColor = (Color)e.Item.Tag; ThongSo.RelationshipColor = (Color)e.Item.Tag; ThongSo.GeneralModeColor = (Color)e.Item.Tag; } else if (((frmDrawBoard)ActiveMdiChild).pnlDrawBoard.AffectingShape != null) { ShapeBase shape = ((frmDrawBoard)ActiveMdiChild).pnlDrawBoard.AffectingShape; switch (shape.GetType().Name) { case "EntityShape": ThongSo.EntityColor = ThongSo.EntitySeparateModeColor = (Color)e.Item.Tag; break; case "AttributeShape": ThongSo.AttributeColor = ThongSo.AttributeSeparateModeColor = (Color)e.Item.Tag; break; case "RelationshipShape": ThongSo.RelationshipColor = ThongSo.RelationshipSeparateModeColor = (Color)e.Item.Tag; break; case "SubtypeConnector": ThongSo.RelationshipColor = ThongSo.RelationshipSeparateModeColor = (Color)e.Item.Tag; break; } } ActiveMdiChild.Refresh(); } }
public override void onInventory(ShapeBase user, int value) { //Player can be either a player object or a aiturret... GameConnection client = user["client"]; for (int i = 0; i < 8; i++) { if (user.GetType() == typeof(Player)) { ShapeBaseImageData image = (user).getMountedImage(i); if (image <= 0) { continue; } if (!image["ammo"].isObject()) { continue; } if (((SimObject)image["ammo"]).getId() != this.getId()) { continue; } (user).setImageAmmo(i, value != 0); } else if (user.GetType() == typeof(AITurretShape)) { ShapeBaseImageData image = (user).getMountedImage(i); if (image <= 0) { continue; } if (!image["ammo"].isObject()) { continue; } if (((SimObject)image["ammo"]).getId() != getId()) { continue; } (user).setImageAmmo(i, value != 0); } int currentammo = user.getInventory(this); // ShapeBaseShapeBaseGetInventory(player, thisobj); if (user.getClassName() != "Player") { continue; } int amountInClips; if (this["clip"].isObject()) { amountInClips = user.getInventory(this["clip"]); // ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]); amountInClips *= this["maxInventory"].AsInt(); amountInClips += user["remaining" + getName()].AsInt(); } else { amountInClips = currentammo; currentammo = 1; } if (user["client"] != string.Empty && !user["isAiControlled"].AsBool()) { client.setAmmoAmountHud(currentammo, amountInClips); } } }
void CheckSceneStatistics() { if (EditorManager.Scene == null || _isSDKScene) { return; } bool physicsUsed = false; bool aiUsed = false; bool behaviorUsed = false; int scriptedObjectCount = 0; Stack <ShapeBase> TempStack = new Stack <ShapeBase>(); foreach (Layer layer in EditorManager.Scene.Layers) { TempStack.Push(layer.Root); } while (TempStack.Count > 0) { ShapeBase current = TempStack.Pop(); foreach (ShapeBase shape in current.ChildCollection) { TempStack.Push(shape); } if (!physicsUsed && current.Components != null) { if (current.Components.GetComponentByEngineName("vHavokRigidBody") != null) { physicsUsed = true; } if (current.Components.GetComponentByEngineName("vHavokCharacterController") != null) { physicsUsed = true; } if (current.Components.GetComponentByEngineName("vHavokTriggerVolume") != null) { physicsUsed = true; } if (current.Components.GetComponentByEngineName("vHavokRagdoll") != null) { physicsUsed = true; } } if (!aiUsed) { if (current.GetType().Name == "HavokNavMeshShape") { aiUsed = true; } } if (!behaviorUsed && current.Components != null) { if (current.Components.GetComponentByEngineName("vHavokBehaviorComponent") != null) { behaviorUsed = true; } } if (current.Components != null && current.Components.GetComponentByEngineName("VScriptComponent") != null) { scriptedObjectCount++; } } VisionGoogleAnalytics.RecordEvent("Usage", "Havok Products", "Physics", physicsUsed ? 1 : 0); VisionGoogleAnalytics.RecordEvent("Usage", "Havok Products", "Behavior", behaviorUsed ? 1 : 0); VisionGoogleAnalytics.RecordEvent("Usage", "Havok Products", "AI", aiUsed ? 1 : 0); VisionGoogleAnalytics.RecordEvent("Usage", "Builtin", "Scripted Objects", scriptedObjectCount); }
public void TestEntityPropertySerialization() { try { const string TEST_SCENENAME = "TestEntityPropertySerialization"; // setup new test project/scene TestManager.Helpers.CreateTestScene(TEST_SCENENAME); EditorProject project = EditorApp.Project; // create an entity shape EditorManager.GetShapeCreatorPluginByName("Entity").ExecutePlugin(); ShapeBase entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0]; string projectFile = project.PathName; int numCreatedShapes = CountShapeInstances(project.Scene); // cause engine view to refresh (to see that rendering the shapes doesn't cause a crash) TestManager.Helpers.ProcessEvents(); // close map project.Save(); project.Close(); // reload map project = EditorManager.ProjectFactory.CreateInstance(null) as EditorProject; Assert.IsNotNull(project); project.Load(projectFile); EditorManager.Project = project; bool bResult = project.OpenScene(TEST_SCENENAME); Assert.IsTrue(bResult); // verify that EntityProperty type is part of the active EntityClassManager assembly entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0]; DynamicPropertyCollection entityProperties = (DynamicPropertyCollection)entityShape.GetType().InvokeMember("EntityProperties", BindingFlags.GetProperty, null, entityShape, new object[] {}); Assert.IsTrue(EditorManager.EngineManager.EntityClassManager.Exists(entityProperties.CollectionType.UniqueName)); TestManager.Helpers.CloseTestProject(); } catch (Exception ex) { EditorManager.DumpException(ex, true); throw ex; } }
/// <summary> /// Updates the list with the recently selected objects (shape, layer, zone). /// </summary> private void UpdateRecentSelection() { // Clean up (remove event handlers foreach (ToolStripMenuItem item in ToolStripButtonRecentSelection.DropDownItems) { item.Click -= new EventHandler(recentItem_Click); } this.ToolStripButtonRecentSelection.DropDownItems.Clear(); foreach (object obj in _recentSelectionList) { ToolStripMenuItem item = new ToolStripMenuItem(); // Layers Layer layer = obj as Layer; if (layer != null && EditorManager.Scene.Layers.Contains(layer)) { item.Text = "Layer: " + layer.LayerName; item.Tag = obj; item.Click += new EventHandler(recentItem_Click); this.ToolStripButtonRecentSelection.DropDownItems.Add(item); int index = LayerTreeViewNodeBase.GetLayerIcon(layer); if (index >= 0) { item.Image = LayerTreeViewNodeBase.ImageList.ImageList.Images[index]; } continue; } // Zones Zone zone = obj as Zone; if (zone != null && EditorManager.Scene.Zones.Contains(zone)) { item.Text = "Zone: " + zone.ZoneName; item.Tag = obj; item.Click += new EventHandler(recentItem_Click); this.ToolStripButtonRecentSelection.DropDownItems.Add(item); int index = LayerTreeViewNodeBase.GetZoneIcon(zone); if (index >= 0) { item.Image = LayerTreeViewNodeBase.ImageList.ImageList.Images[index]; } continue; } // Shapes ShapeBase shape = obj as ShapeBase; if (shape != null && shape.IsAddedToScene) { item.Text = "Shape: " + shape.ShapeName + " (" + shape.GetType().Name + ")"; item.Tag = obj; item.Click += new EventHandler(recentItem_Click); this.ToolStripButtonRecentSelection.DropDownItems.Add(item); if (shape.IconIndex >= 0) { item.Image = EditorManager.GUI.ShapeTreeImages.ImageList.Images[shape.IconIndex]; } continue; } } }