public bool CreateGrid(GroupAction parent)
 {
     if (!_area.Valid)
     {
         return(false);
     }
     for (int y = 0; y < SubdivisionsY; y++)
     {
         for (int x = 0; x < SubdivisionsX; x++)
         {
             Zone  z = CreateNewZone(x, y);
             Layer l = CreateNewLayer(x, y);
             parent.Add(new AddZoneAction(z, false));
             l.AttachToZone(z);
             parent.Add(new AddLayerAction(l, false));
             if (_bCreateLoaded != z.Loaded)
             {
                 parent.Add(new SetZoneLoadedStatusAction(z, _bCreateLoaded));
             }
         }
     }
     return(true);
 }
 public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action)
 {
     base.Perform2DViewAction(view, parent, action);
     if (action == VA_UNLOCK_SECTORS)
     {
         // do something here...
     }
     if (action == VA_MAKE_VISIBLE)
     {
         parent.Add(new SetSectorPropertyAction(this, "SectorVisibleMask", FlagsInt32_e.All));
     }
     else if (action == VA_MAKE_INVISIBLE)
     {
         parent.Add(new SetSectorPropertyAction(this, "SectorVisibleMask", FlagsInt32_e.None));
     }
     else if (action == VA_ENABLE_COLLISION)
     {
         parent.Add(new SetSectorPropertyAction(this, "SectorCollisionMask", FlagsInt16_e.All));
     }
     else if (action == VA_DISABLE_COLLISION)
     {
         parent.Add(new SetSectorPropertyAction(this, "SectorCollisionMask", FlagsInt16_e.None));
     }
 }
        private void MigratePostprocessingShapes()
        {
            GetPostprossingShapesVisitor vis = new GetPostprossingShapesVisitor();
              EditorManager.Scene.RunShapeVisitor(vis);
              if (vis.Found.Count == 0)
            return;

              GroupAction action = new GroupAction("Remove postprocessing Shape(s)");
              foreach (ShapeBase shape in vis.Found)
              {
            action.Add(RemoveShapeAction.CreateRemoveShapeAction(shape));
              }

              // migrate the VPostProcessingHDRBloom effect
              if (vis.FirstActive != null && vis.FirstActive.EffectClass == "VPostProcessingHDRBloom")
              {
            if (RendererNodeClass == EditorManager.RendererNodeManager.DefaultRendererNodeClass)
              RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_FORWARD;

            DynamicPropertyCollection oldProp = vis.FirstActive.EffectProperties;
            int iGlowPasses = int.Parse(oldProp.GetPropertyValue("GlowPasses", false).ToString());
            float fGlowExponent = (float)oldProp.GetPropertyValue("GlowExponent", false);
            float fGlowScale = (float)oldProp.GetPropertyValue("GlowScale", false);
            float fGlowBias = (float)oldProp.GetPropertyValue("GlowBias", false);
            float fGlowOffset = (float)oldProp.GetPropertyValue("GlowOffset", false);
            string toneTechnique = oldProp.GetPropertyValue("ToneMappingTechnique", false).ToString();
            float fToneSaturation = (float)oldProp.GetPropertyValue("ToneSaturation", false);
            float fToneContrast = (float)oldProp.GetPropertyValue("ToneContrast", false);
            float fToneBrightness = (float)oldProp.GetPropertyValue("ToneBrightness", false);
            float fMotionBlurFeedback = (float)oldProp.GetPropertyValue("MotionBlurFeedback", false);

            ShapeComponent bloom = CreatePostprocessor("VPostProcessGlow");
            if (bloom != null)
            {
              //bloom.SetPropertyValue("DownscaleMode",  , false);
              bloom.SetPropertyValue("Bias", fGlowBias, false);
              bloom.SetPropertyValue("Exponent", fGlowExponent, false);
              bloom.SetPropertyValue("Scale", fGlowScale, false);
              bloom.SetPropertyValue("BlurPasses", iGlowPasses, false);
            }
            ShapeComponent tm = CreatePostprocessor("VPostProcessToneMapping");
            if (tm != null)
            {
              tm.SetPropertyValue("ToneMapType", NewToneMappingType(toneTechnique), false);
              tm.SetPropertyValue("Saturation", fToneSaturation, false);
              tm.SetPropertyValue("Contrast", fToneContrast, false);
              tm.SetPropertyValue("Brightness", fToneBrightness, false);
              tm.SetPropertyValue("MotionBlurFeedback", fMotionBlurFeedback, false);
            }
              }

              EditorManager.Actions.Add(action);
              Modified = true;
        }
        IEnumerable <GroupAction> GetNextDummyItems(GroupAction source, int count)
        {
            int start = source.Parent.IndexOf(source);

            return(source.Parent.Skip(start).Where(xga => xga.Name.StartsWith("Dummy item")).Take(count));
        }
Exemple #5
0
 public static GroupAction ToAzureFunctionsObject(GroupAction ga)
 {
     return(ga);
 }
Exemple #6
0
 public WeGroupProductAction(string productId, GroupAction modaction)
 {
     ModAction = modaction;
 }
 public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action)
 {
     base.Perform2DViewAction(view, parent, action);
       if (action == VA_UNLOCK_SECTORS)
       {
     // do something here...
       }
       if (action == VA_MAKE_VISIBLE)
       {
     parent.Add(new SetSectorPropertyAction(this, "SectorVisibleMask", FlagsInt32_e.All));
       }
       else if (action == VA_MAKE_INVISIBLE)
       {
     parent.Add(new SetSectorPropertyAction(this, "SectorVisibleMask", FlagsInt32_e.None));
       }
       else if (action == VA_ENABLE_COLLISION)
       {
     parent.Add(new SetSectorPropertyAction(this, "SectorCollisionMask", FlagsInt16_e.All));
       }
       else if (action == VA_DISABLE_COLLISION)
       {
     parent.Add(new SetSectorPropertyAction(this, "SectorCollisionMask", FlagsInt16_e.None));
       }
 }
        void RemoveBone(GroupAction actions, BoneProxyShape bone)
        {
            // attach to new parent
              if (bone.HasChildren())
            actions.Add(new SetShapesParentAction(bone.ChildCollection, bone.Parent));

              actions.Add(RemoveShapeAction.CreateRemoveShapeAction(bone));
        }
 public void removeUserGroupAction(User u, UserGroup ug)
 {
     GroupAction ga = new GroupAction(ug, u);
     GroupActions.Remove(ga);
 }
Exemple #10
0
        // When focus leaves a transform strip element, apply the modification to all selected shapes
        private void transformStrip_Leave(object sender, EventArgs e)
        {
            ToolStripTextBox textBox = sender as ToolStripTextBox;

              if (textBox != null)
              {
            try
            {
              // Fetch text from current text box and determine field based on textbox id
              float value = Single.Parse(textBox.Text);
              String property = "";
              if (textBox == transformStrip_TranslateX)
            property = "x";
              else if (textBox == transformStrip_TranslateY)
            property = "y";
              else if (textBox == transformStrip_TranslateZ)
            property = "z";
              else if (textBox == transformStrip_Yaw)
            property = "Yaw";
              else if (textBox == transformStrip_Pitch)
            property = "Pitch";
              else if (textBox == transformStrip_Roll)
            property = "Roll";
              else if (textBox == transformStrip_ScaleX)
            property = "ScaleX";
              else if (textBox == transformStrip_ScaleY)
            property = "ScaleY";
              else if (textBox == transformStrip_ScaleZ)
            property = "ScaleZ";
              else if (textBox == transformStrip_ScaleXYZ)
            property = "UniformScaling";

              // Create a group action to allow for group undo/redo
              GroupAction groupAction = new GroupAction("Transform Selected");

              // Create property actions for each selected shape
              foreach (ShapeBase shape in EditorManager.SelectedShapes)
              {
            Shape3D shape3D = shape as Shape3D;

            if (shape3D != null)
            {
              float newValue = value;
              float orgValue = 0;
              bool bAdd = true;

              if (textBox == transformStrip_TranslateX)
                orgValue = shape3D.Position.X;
              else if (textBox == transformStrip_TranslateY)
                orgValue = shape3D.Position.Y;
              else if (textBox == transformStrip_TranslateZ)
                orgValue = shape3D.Position.Z;
              else if (textBox == transformStrip_Yaw)
                orgValue = shape3D.Orientation.X;
              else if (textBox == transformStrip_Pitch)
                orgValue = shape3D.Orientation.Y;
              else if (textBox == transformStrip_Roll)
                orgValue = shape3D.Orientation.Z;
              else if (textBox == transformStrip_ScaleX)
              {
                bAdd = false;
                orgValue = shape3D.ScaleX;
              }
              else if (textBox == transformStrip_ScaleY)
              {
                bAdd = false;
                orgValue = shape3D.ScaleY;
              }
              else if (textBox == transformStrip_ScaleZ)
              {
                bAdd = false;
                orgValue = shape3D.ScaleZ;
              }
              else if (textBox == transformStrip_ScaleXYZ)
              {
                bAdd = false;
                orgValue = shape3D.UniformScaling;
              }

              // When using relative transforms, apply increment to current value
              if (relativeTransform)
              {
                if (bAdd)
                  newValue += orgValue;
                else
                  newValue *= orgValue;
              }

              // do not create an undo step, unless the property actually changed
              if (newValue != orgValue)
                groupAction.Add(SetPropertyAction.CreateSetPropertyAction(shape3D, property, newValue));
            }
              }

              EditorManager.Actions.Add(groupAction);
            }
            catch (System.FormatException)
            {
              updateTransformStrip();
              return;
            }
            catch (System.OverflowException)
            {
              updateTransformStrip();
              return;
            }
              }
        }
        /// <summary>
        /// CoreItem should always be the lowest item priority in the inventory, so we can assume 
        /// that there will be no more commands that could match after this method. Thus, if we can't
        /// match the string at the beginning of commands, GetAction will still skip the commands
        /// array anyway.
        /// </summary>
        /// <param name="player">
        /// The player trying to execute the action.</param>
        /// <param name="commands">A string of action commands to be parsed in order. This should contain quoted strings and
        /// core action handles (SAY, GIVE, IF, etc) only.</param>
        /// <returns>The action built from the commands array.</returns>
        public override bool DoAction(Player player, ref string[] commands, ref bool lastAction)
        {
            Action action = null;

            if (commands != null && commands.Length > 0)
            {
                int index = 0;
                switch (commands[0].ToUpper())
                {
                    case "SAY":
                        {
                            SayAction sayAction = new SayAction(player);
                            index++;
                            if (commands.Length > 1)
                            {
                                sayAction.Message = commands[1];
                                index++;
                            }
                            action = sayAction;
                        }
                        break;

                    case "IF":
                        {
                            IfElseAction ifAction = new IfElseAction(player);
                            index++;
                            if (commands.Length > 1)
                            {
                                index += ifAction.Parse(commands.Skip(1).ToArray());
                            }
                            action = ifAction;
                        }
                        break;

                    case "NOT":
                        {
                            NotAction notAction = new NotAction(player);
                            commands = commands.Skip(1).ToArray();  // skip to next action
                            player.Inventory.DoAction(ref commands, ref lastAction);
                            notAction.Op = lastAction;
                            // no index increment, the ref is our increment
                            action = notAction;
                        }
                        break;

                    case "AND":
                        {
                            AndAction andAction = new AndAction(player);
                            commands = commands.Skip(1).ToArray();
                            andAction.Op1 = lastAction;
                            player.Inventory.DoAction(ref commands, ref lastAction);
                            andAction.Op2 = lastAction;
                            // no index increment, the ref is our increment
                            action = andAction;
                        }
                        break;

                    case "OR":
                        {
                            OrAction orAction = new OrAction(player);
                            commands = commands.Skip(1).ToArray();
                            orAction.Op1 = lastAction;
                            player.Inventory.DoAction(ref commands, ref lastAction);
                            orAction.Op2 = lastAction;
                            // no index increment, the ref is our increment
                            action = orAction;
                        }
                        break;

                    case "GIVE":
                        {
                            GiveAction giveAction = new GiveAction(player);
                            index++;
                            if (commands.Length > 1)
                            {
                                giveAction.ItemName = commands[1];
                                index++;
                            }
                            if (commands.Length > 3 && commands[2].ToUpper() == "TO")
                            {
                                giveAction.ToItemName = commands[3];
                                index += 2;
                            }
                            action = giveAction;
                        }
                        break;

                    case "TAKE":
                        {
                            TakeAction takeAction = new TakeAction(player);
                            index++;
                            if (commands.Length > 1)
                            {
                                takeAction.ItemName = commands[1];
                                index++;
                            }
                            if (commands.Length > 3 && commands[2].ToUpper() == "FROM")
                            {
                                takeAction.FromItemName = commands[3];
                                index += 2;
                            }
                            action = takeAction;
                        }
                        break;

                    case "HAS":
                        {
                            HasAction hasAction = new HasAction(player);
                            index++;
                            if(commands.Length > 1)
                            {
                                hasAction.ItemName = commands[1];
                                index++;
                            }
                            if (commands.Length > 3 && commands[2].ToUpper() == "IN")
                            {
                                hasAction.InItemName = commands[3];
                                index += 2;
                            }
                            action = hasAction;
                        }
                        break;

                    case "GO":
                        {
                            GoAction goAction = new GoAction(player);
                            index++;
                            if (commands.Length > 1)
                            {
                                goAction.GiveItemName = commands[1];
                                goAction.TakeItemName = GoItemString;
                                index++;
                            }
                            if(goAction.ExecuteWhenCreated())
                            {
                                GoItemString = goAction.GiveItemName;
                            }
                            action = goAction;
                        }
                        break;

                    case "INV":
                            {
                                GroupAction groupAction = new GroupAction(player);
                                index++;
                                foreach(Item item in player.Inventory.Items
                                    .Where(item => !item.Hidden))
                                {
                                    SayAction sayAction = new SayAction(player);
                                    sayAction.Message = item.DisplayName;
                                    groupAction.Add(sayAction);
                                }
                                if(groupAction.Actions.Count < 1)
                                {
                                    SayAction sayAction = new SayAction(player);
                                    sayAction.Message = "You have no items.";
                                    groupAction.Add(sayAction);
                                }
                                action = groupAction;
                            }
                        break;

                    default:        // unrecognized? This is the base item, so there's no other items that could have matching actions.
                        index++;    // ignore it.
                        break;

                }

                commands = commands.Skip(index).ToArray();
            }

            if (action != null)
            {
                lastAction = action.Execute();
                return true;
            }
            else
            {
                return false;
            }
        }
 public GroupActionItem(GroupAction action, ElementNode elementNode)
 {
     Action = action;
     ElementNode = elementNode;
     Text = $"{Action.ActionType} ({ElementNode.GlobalStartTime + Action.Delay} - {ElementNode.GlobalStartTime + Action.Delay + Action.Duration})";
 }
        private async Task SendGroupActionAndWaitForAck(string connectionId, string groupName, GroupAction action)
        {
            var id = Interlocked.Increment(ref this.internalId);

            var ack = this.ackHandler.CreateAck(id);

            // Send Add/Remove Group to other servers and wait for an ack or timeout
            var message = this.protocol.WriteGroupCommand(new MsmqGroupCommand(id, Environment.MachineName, action, groupName, connectionId));

            await this.PublishGroupCommandAsync(message);

            await ack;
        }
        /// <summary>
        /// Generate the nice XML output for fusion charts
        /// </summary>
        /// <param name="chartTitle">Title of the chart</param>
        /// <param name="xValue">Column name to use as x value</param>
        /// <param name="xTitle">Title to give to x</param>
        /// <param name="yValue">Column name to use as y value</param>
        /// <param name="yTitle">Title to give to y</param>
        /// <param name="groupAction">Action to perform (sum, count, ...)</param>
        /// <param name="colors">List of colors to use (separated by ;)</param>
        /// <returns></returns>
        public string GenerateXml(string chartTitle, string xValue, string xTitle, string yValue, string yTitle, GroupAction groupAction, string colors)
        {
            // We first convert color (string) into a nice array
            string[] separator   = { ";" };
            string[] colorsArray = colors.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            StringBuilder sb = new StringBuilder();

            // We open the graph tag with a few parameters
            sb.AppendLine("<graph caption='" + chartTitle + "' xAxisName='" + xTitle + "' yAxisName='" + yTitle + "'>");

            // We prepare the data in a nice hashtable
            Plots plots = PrepareData(xValue, yValue, groupAction);

            for (int i = 0; i < plots.Count(); i++)
            {
                // We try to compute the color
                string color = "";
                try
                {
                    color = colorsArray[i % (colorsArray.Length)]; // computes to color to use
                }
                catch { } // if we fail we skip the error, default color will be used

                // We add a line to the XML
                sb.Append("<set name='" + plots.GetX(i) + "' value='" + plots.GetY(i).ToString() + "'");
                if (color != "")
                {
                    sb.Append(" color='" + color + "'");
                }
                sb.AppendLine(" />");
            }

            // We close the graph tag opened previously
            sb.AppendLine("</graph>");

            // We finally return the xml data
            return(sb.ToString());
        }
        /// <summary>
        /// Transforms the list of items into something easily usable (a Plots object).
        /// Performs also operations such as SUM, COUNT over GROUPBY
        /// </summary>
        /// <param name="xValue">The name of the column to use as xValue</param>
        /// <param name="yValue">The nam of the column to use as yValue</param>
        /// <param name="action">The action to perform, if any...</param>
        /// <returns></returns>
        public Plots PrepareData(string xValue, string yValue, GroupAction action)
        {
            // We first check that xValue and yValue are correct and throw an exception if needed
            if (!_items.List.Fields.ContainsField(xValue))
            {
                string message = "The column \"" + xValue + "\" does not exist in the list \"" + _items.List.Title + "\" or in the specified view \"" + _view.Title + "\".<br /><br />Check the view you specified and make sure that the column exists.";
                message += ListValidColumns();
                throw (new Exception(message));
            }
            if (yValue != String.Empty && !_items.List.Fields.ContainsField(yValue))
            {
                string message = "The column \"" + yValue + "\" does not exist in the list \"" + _items.List.Title + "\" or in the specified view \"" + _view.Title + "\".<br /><br />Check the view you specified and make sure that the column exists.";
                message += ListValidColumns();
                throw (new Exception(message));
            }

            // We prepare our output
            Plots plots = new Plots();

            // We loop through our SPList
            foreach (SPListItem item in _items)
            {
                // We get the X and Y from
                string x = "";
                try
                {
                    if (item[xValue] == null)
                    {
                        continue;
                    }

                    x = item[xValue].ToString();
                }
                catch
                {
                    throw (new Exception("The column \"" + xValue + "\" does not exist in the view"));
                }

                double y = 0;
                if (yValue != String.Empty)
                {
                    Double.TryParse(item[yValue].ToString(), out y);
                }

                // The value is already in our array
                if (plots.Contains(x))
                {
                    int pos = plots.XIndexOf(x);

                    if (action == GroupAction.COUNT)
                    {
                        // Count, we add +1 to the existing value
                        plots.SetY(pos, Double.Parse(plots.GetY(pos).ToString()) + 1);
                    }
                    if (action == GroupAction.SUM)
                    {
                        // Sum, we add the value to the existing value
                        plots.SetY(pos, Double.Parse(plots.GetY(pos).ToString()) + y);
                    }
                    if (action == GroupAction.NOTHING)
                    {
                        // No action, we simply add the value
                        plots.Add(x, y);
                    }
                }
                else // The value is a new one in our array
                {
                    if (action == GroupAction.COUNT)
                    {
                        // Count, the first yValue is 1.
                        plots.Add(x, 1);
                    }
                    else
                    {
                        // anything else than Count, we just add the plot
                        plots.Add(x, y);
                    }
                }
            }
            return(plots);
        }
        /// <summary>
        /// User selected the plugin, so execute it
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _menuItem_Click(object sender, EventArgs e)
        {
            //create new groupaction
              GroupAction actions = new GroupAction("Rename Textlabel");

              int i = 0;
              //search for shapes in layer (do not search recursively)
              foreach (Layer layer in EditorManager.Scene.Layers)
              {
            foreach (ShapeBase shape in layer.Root.ChildCollection)
            {
              Shape3D shape3d = shape as Shape3D;
              if (shape3d == null || !shape3d.Modifiable)
            continue;
              actions.Add(new SetPropertyAction(shape3d, "TextLabel", "Object" + i));
              i++;
            }
              }

              // spawn an undoable action. To trigger it silently, just call actions.Do();
              if (actions.Valid)
            EditorManager.Actions.Add(actions);
        }
        /// <summary>
        /// Deletes or adds the user "user" from/to UserGroup "group"
        /// </summary>
        /// <param name="user"></param>
        /// <param name="group"></param>
        /// <param name="AddDelete">true = AddUser, false = RemoveUser</param>
        public void UserGroupDelayedAction(User user, UserGroup group, bool AddDelete)
        {
            GroupAction ga = new GroupAction((UserGroup)group.GetCopy(), (User)user.GetCopy());
            ga.AddOrRemove = AddDelete;

            if (AddDelete)
            {
                //Add
                GroupActions.Add(ga);
            }
            else
            {
                //delete
                GroupActions.Remove(ga);
                GroupActions.Add(ga);
            }
        }
Exemple #18
0
        // Sets the absolute rotation of all selected shapes to the value of the rotation clipboard
        private void pasteRotationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            transformStrip_Yaw.Text = rotationClipboard.X.ToString();
              transformStrip_Pitch.Text = rotationClipboard.Y.ToString();
              transformStrip_Roll.Text = rotationClipboard.Z.ToString();

              GroupAction groupAction = new GroupAction("Transform Selected");
              foreach (ShapeBase shape in EditorManager.SelectedShapes)
              {
            Shape3D shape3D = shape as Shape3D;
            if (shape3D != null)
            {
              groupAction.Add(SetPropertyAction.CreateSetPropertyAction(shape3D, "Yaw", rotationClipboard.X));
              groupAction.Add(SetPropertyAction.CreateSetPropertyAction(shape3D, "Pitch", rotationClipboard.Y));
              groupAction.Add(SetPropertyAction.CreateSetPropertyAction(shape3D, "Roll", rotationClipboard.Z));
            }
              }
              EditorManager.Actions.Add(groupAction);
        }
		public override void DoImport(SCObjectSet objectSet, IImportContext context)
		{
			if (objectSet.HasRelations && objectSet.HasObjects)
			{
				context.SetStatus(0, 1, "正在分析数据。");

				// 查找组织关系
				var pendingOperations = new List<Action<object>>();

				var objects = objectSet.Objects;
				Dictionary<string, IList<PC.SCOrganization>> orgToOrgRelations = new Dictionary<string, IList<PC.SCOrganization>>();
				Dictionary<string, IList<PC.SCUser>> orgToUserRelations = new Dictionary<string, IList<PC.SCUser>>();
				Dictionary<string, IList<PC.SCGroup>> orgToGroupRelations = new Dictionary<string, IList<PC.SCGroup>>();
				Dictionary<string, PC.SchemaObjectBase> knownObjects = new Dictionary<string, PC.SchemaObjectBase>(); // 缓存已知对象,避免多次往返

				context.SetStatus(0, 1, "正在统计需要导入的对象");
				Stat stat = new Stat(); // 统计信息

				FindFullOURelations(objectSet, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, new PC.SCOrganization[] { this.Parent }, stat); // 爬出所有组织关系

				Dictionary<PC.SCOrganization, IList<PC.SCRelationObject>> userToOrgRelations = new Dictionary<PC.SCOrganization, IList<PC.SCRelationObject>>();

				this.allSteps = this.CalculateSteps(stat);
				this.currentSteps = 0;
				bool orgValid = false; // 必须校验组织
				context.SetStatus(0, this.allSteps, "正在导入数据。");

				// 递归导入组织,并剔除错误的数据
				orgValid = this.PrepareOrganizations(objectSet, context, knownObjects, orgToOrgRelations, this.Parent, this.IncludeOrganizations == false);

				if (this.IncludeAcl)
				{
					// 递归导入Acl
					var action = new AclAction(this);
					action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
					this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action);
					action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
				}

				if (this.IncludeUser)
				{
					var action = new UserAction(this);
					action.ImportSecretaries = this.IncludeSecretaries;
					action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
					this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action);
					action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
				}

				if (this.IncludeGroup)
				{
					var action = new GroupAction(this);
					action.ImportMembers = this.IncludeGroupMembers;
					action.ImportConditions = this.IncludeGroupConditions;
					action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
					this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action);
					action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
				}
			}
		}
        private async Task SendGroupActionAndWaitForAck(string connectionId, string groupName, GroupAction action)
        {
            var id  = Interlocked.Increment(ref _internalId);
            var ack = _ackHandler.CreateAck(id);

            // Send Add/Remove Group to other servers and wait for an ack or timeout
            await PublishAsync(_channelNamePrefix + ".internal.group", new RedisGroupMessage
            {
                Action       = action,
                ConnectionId = connectionId,
                Group        = groupName,
                Id           = id,
                Server       = _serverName
            });

            await ack;
        }
        public void MultiAction(List <BaseAction> actions)
        {
            var action = new GroupAction(actions);

            HandlePushAction(action);
        }
        public IAction GetSetPropertyAction(string propertyName, object newValue)
        {
            if (propertyName == "ModelFile")
              {
            if (!HasExposedBones)
              return null;

            GroupAction actions = new GroupAction("Change Model");

            CollectModelChangedActions(newValue as string, actions);

            // add the change model action itself
            actions.Add(SetPropertyAction.CreateSetPropertyAction(this,propertyName,newValue));

            return actions;
              }

              if (propertyName == "ExposedBones")
              {
            GroupAction actions = new GroupAction("Change Exposed Bones");

            _cachedBoneList = newValue as List<BoneProxyShape>;
            foreach (ShapeBase child in ChildCollection)
              if ((child is BoneProxyShape) && (_cachedBoneList==null || !_cachedBoneList.Contains((BoneProxyShape)child)))
            RemoveBone(actions,(BoneProxyShape)child);

            _cachedBoneList = null; // re-evaluate

            return actions;
              }

              return null;
        }
Exemple #23
0
 public ActionItemModel(IdeCollection <IdeBaseItem> source) : base(source) //new item
 {
     CanBeDefault = true;
     _action      = new GroupAction();
     Name         = "New Action";
 }
        /// <summary>
        /// This function converts all shapes from the old SoundPlugin to the corresponding shapes of the new FmodPlugin
        /// </summary>
        void MigrateToFmodShapes()
        {
            // If old Sound plugin is not loaded, don't do anything
              IEditorPluginModule soundPlugin = EditorManager.GetPluginByName("SoundEditorPlugin.EditorPlugin");
              if (soundPlugin == null || !soundPlugin.Initialized)
            return;

              // collect all sound specific shapes
              ShapeCollection soundShapes = new ShapeCollection();
              foreach (Layer layer in EditorManager.Scene.Layers)
            if (layer.Modifiable && layer.Loaded)
              AddSoundShapesRecursive(soundShapes, layer.Root);

              if (soundShapes.Count == 0)
            return;

              // prompt a dialog
              DialogResult res = EditorManager.ShowMessageBox("Shapes from old Sound Plugin have been found in loaded layers.\n\nShould these be permanently converted to the corresponding shapes of the Fmod Plugin?", "Old Sound Plugin and Fmod Plugin are both loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
              if (res != DialogResult.Yes)
            return;

              ShapeCollection newShapes = new ShapeCollection();
              int iConvertedCount = 0;
              if (soundShapes.Count > 0)
              {
            GroupAction actions = new GroupAction("Migrate Sound shapes");
            foreach (ShapeObject3D oldShape in soundShapes)
            {
              ShapeObject3D newShape = null;
              if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundShape")
              {
            newShape = new FmodSoundShape(oldShape.ShapeName);
            MigrateSoundShapeProperties(oldShape, (FmodSoundShape)newShape);

            actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));

            actions.Add(new MigrateSoundLinksAction(oldShape, (FmodSoundShape)newShape));
            actions.Add(new MigrateChildrenAction(oldShape, newShape));
            actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
            newShapes.Add(newShape);
              }
              else if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape")
              {
            newShape = new FmodCollisionMeshShape(oldShape.ShapeName);
            MigrateSoundCollisionShapeProperties(oldShape, (FmodCollisionMeshShape)newShape);

            actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));
            actions.Add(new MigrateChildrenAction(oldShape, newShape));
            actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
            newShapes.Add(newShape);
              }
              if (newShape == null)
            continue;

              iConvertedCount++;
            }

            // EditorManager.Actions.Add() is not used, in order to prevent a undo of the conversion
            actions.Do();
              }

              // ensure, that all migrated childs have valid engine instances
              foreach (ShapeBase shape in newShapes)
            foreach (ShapeBase child in shape.ChildCollection)
              child.ReCreateEngineInstance(true);

              EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Shape(s) have been successfully converted.", "Sound to Fmod shapes conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
            public override void OnClicked(VisionViewBase view)
            {
                base.OnClicked(view);
                if (TerrainEditor.CurrentSelection == null)
                  return;
                ITerrainClipboardObject data = (EditorManager.ActiveComponent.Clipboard == null) ? null
                  : EditorManager.ActiveComponent.Clipboard.Data as ITerrainClipboardObject;

                if (data == null)
                  return;

                TerrainSelectionShape selShape = (TerrainSelectionShape)this.Owner;
                float fRadX = data.OriginalExtent.GetSizeX() * 0.5f;
                float fRadY = data.OriginalExtent.GetSizeY() * 0.5f;

                GroupAction action = new GroupAction("adjust selection size");
                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MinX", fRadX)); // min values are also positive
                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MinY", fRadY));
                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MaxX", fRadX));
                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MaxY", fRadY));
                EditorManager.Actions.Add(action);
            }
        /// <summary>
        /// Build nav mesh button
        /// </summary>
        private void BuildNavMesh_Click(object sender, EventArgs e)
        {
            CSharpFramework.Scene.ZoneCollection zones = EditorManager.Scene.Zones.ShallowClone();
            GroupAction groupLoadAction = new GroupAction("Load all zones");


            foreach (CSharpFramework.Scene.Zone zone in zones)
            {
                groupLoadAction.Add(new CSharpFramework.Actions.SetZoneLoadedStatusAction(zone, true));
            }
            groupLoadAction.Do();

            {
                // for printing out stats
                BuildStatisticsRichTextBox.ScrollBars = RichTextBoxScrollBars.ForcedVertical;
                Font oldFont      = BuildStatisticsRichTextBox.SelectionFont;
                Font newFontPlain = new Font(oldFont, oldFont.Style & ~FontStyle.Bold);
                Font newFontBold  = new Font(oldFont, oldFont.Style | FontStyle.Bold);

                ShapeCollection navMeshShapes = EditorManager.Scene.AllShapesOfType(typeof(HavokNavMeshShape));

                // gather all geometry once (divide by zone later)
                ShapeCollection staticGeometries = new ShapeCollection();
                {
                    int numEntities = 0, numStaticMeshes = 0, numTerrains = 0;
                    int numCarvers = 0, numSeedPoints = 0, numLocalSettings = 0;
                    gatherGeometricShapes(ref staticGeometries, ref numEntities, ref numStaticMeshes, ref numTerrains, ref numCarvers, ref numSeedPoints, ref numLocalSettings);

                    //
                    // print out some debug info
                    //
                    BuildStatisticsRichTextBox.SelectionStart = BuildStatisticsRichTextBox.Text.Length;
                    {
                        String inputGeometryLabel = "Input Geometry";
                        BuildStatisticsRichTextBox.Text = inputGeometryLabel;
                    }
                    BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
                    BuildStatisticsRichTextBox.SelectionFont   = newFontBold;

                    {
                        String inputGlobalGeometryInfo = "\n\nStatic meshes\t: " + numStaticMeshes + "\nTerrains\t\t: " + numTerrains + "\nEntities\t\t: " + numEntities +
                                                         "\n\nCarvers\t\t: " + numCarvers + "\nSeed points\t: " + numSeedPoints + "\nLocal settings\t: " + numLocalSettings + "\n\n";
                        BuildStatisticsRichTextBox.Text += inputGlobalGeometryInfo;
                    }
                    BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
                    BuildStatisticsRichTextBox.SelectionFont   = newFontPlain;

                    //
                    // debug info end
                    //
                }

                // actually build the navmeshes here
                int  numBuiltNavMeshShapes = 0;
                bool allCompleted          = true;
                foreach (HavokNavMeshShape shape in navMeshShapes)
                {
                    int numGeometryVertices = 0, numGeometryTriangles = 0;

                    // note that the build function only uses static geometries that lie in the same zone!
                    bool built = shape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles);

                    if (built)
                    {
                        numBuiltNavMeshShapes++;

                        //
                        // print out some debug info
                        //
                        BuildStatisticsRichTextBox.SelectionStart = BuildStatisticsRichTextBox.Text.Length;
                        {
                            String navMeshLabel = "\n\nNav Mesh #" + numBuiltNavMeshShapes;
                            BuildStatisticsRichTextBox.Text += navMeshLabel;
                        }
                        BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
                        BuildStatisticsRichTextBox.SelectionFont   = newFontBold;

                        BuildStatisticsRichTextBox.SelectionStart = BuildStatisticsRichTextBox.Text.Length;
                        {
                            String inputPerNavMeshGeometryInfo = "\nTotal input triangles\t: " + numGeometryTriangles + "\nTotal input vertices\t: " + numGeometryVertices + "\n\n";
                            int    facesSize    = shape.GetNavMeshFaceSize() * shape.GetNumNavMeshFaces();
                            int    edgesSize    = shape.GetNavMeshEdgeSize() * shape.GetNumNavMeshEdges();
                            int    verticesSize = shape.GetNavMeshVertexSize() * shape.GetNumNavMeshVertices();
                            int    totalSize    = shape.GetNavMeshStructSize() + facesSize + edgesSize + verticesSize;

                            String navMeshInfo = "\nTotal size\t\t: " + totalSize +
                                                 " bytes\nFaces ( " + shape.GetNumNavMeshFaces() + " )\t: " + facesSize +
                                                 "\nEdges ( " + shape.GetNumNavMeshEdges() + " )\t: " + edgesSize +
                                                 "\nVertices ( " + shape.GetNumNavMeshVertices() + " )\t: " + verticesSize;
                            BuildStatisticsRichTextBox.Text += navMeshInfo;
                        }
                        BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
                        BuildStatisticsRichTextBox.SelectionFont   = newFontPlain;

                        //
                        // debug info end
                        //
                    }
                    else
                    {
                        allCompleted = false;
                        break;
                    }
                }

                if (allCompleted)
                {
                    // stitch the navmeshes together
                    using (HavokAiManaged.EngineInstanceHavokNavMeshLinker linker = new HavokAiManaged.EngineInstanceHavokNavMeshLinker())
                    {
                        // collect all navmeshes at once
                        foreach (HavokNavMeshShape shape in navMeshShapes)
                        {
                            if (shape.HasEngineInstance())
                            {
                                linker.AddNavMeshShape(shape._engineInstance.GetNativeObject());

                                HavokNavMeshGlobalSettings globalSettings = GetGlobalSettings(shape.NavMeshGlobalSettingsKey);
                                if (globalSettings != null)
                                {
                                    linker.m_linkEdgeMatchTolerance = globalSettings.LinkEdgeMatchTolerance;
                                    linker.m_linkMaxStepHeight      = globalSettings.LinkMaxStepHeight;
                                    linker.m_linkMaxSeparation      = globalSettings.LinkMaxSeparation;
                                    linker.m_linkMaxOverhang        = globalSettings.LinkMaxOverhang;

                                    linker.m_linkCosPlanarAlignmentAngle   = (float)Math.Cos(globalSettings.LinkPlanarAlignmentAngle / 180.0f * 3.14159f);
                                    linker.m_linkCosVerticalAlignmentAngle = (float)Math.Cos(globalSettings.LinkVerticalAlignmentAngle / 180.0f * 3.14159f);
                                    linker.m_linkMinEdgeOverlap            = globalSettings.LinkMinEdgeOverlap;
                                }
                            }
                        }

                        // link them together
                        linker.LinkNavMeshes();
                    }

                    // save it to disk (separate from next loop because we want to guarantee that we don't serialize out some runtime only data)
                    foreach (HavokNavMeshShape shape in navMeshShapes)
                    {
                        shape.SaveNavMeshesToFile();
                    }

                    // finally load it into the havok ai world
                    foreach (HavokNavMeshShape shape in navMeshShapes)
                    {
                        shape.AddNavMeshToWorld();
                    }

                    if (EditorManager.InPlayingMode && WantPhysicsConnection())
                    {
                        HavokAiManaged.ManagedModule.SetConnectToPhysicsWorld(true);
                    }
                }

                EnableBuildButtonAsterisk(false);
                //EnableStreamingDependentControls(shape.GetNumNavMeshes()>1);
            }

            groupLoadAction.Undo();

            EditorManager.ActiveView.UpdateView(true);
        }
Exemple #27
0
        /// <summary>
        /// CoreItem should always be the lowest item priority in the inventory, so we can assume
        /// that there will be no more commands that could match after this method. Thus, if we can't
        /// match the string at the beginning of commands, GetAction will still skip the commands
        /// array anyway.
        /// </summary>
        /// <param name="player">
        /// The player trying to execute the action.</param>
        /// <param name="commands">A string of action commands to be parsed in order. This should contain quoted strings and
        /// core action handles (SAY, GIVE, IF, etc) only.</param>
        /// <returns>The action built from the commands array.</returns>
        override public bool DoAction(Player player, ref string[] commands, ref bool lastAction)
        {
            Action action = null;

            if (commands != null && commands.Length > 0)
            {
                int index = 0;
                switch (commands[0].ToUpper())
                {
                case "SAY":
                {
                    SayAction sayAction = new SayAction(player);
                    index++;
                    if (commands.Length > 1)
                    {
                        sayAction.Message = commands[1];
                        index++;
                    }
                    action = sayAction;
                }
                break;

                case "IF":
                {
                    IfElseAction ifAction = new IfElseAction(player);
                    index++;
                    if (commands.Length > 1)
                    {
                        index += ifAction.Parse(commands.Skip(1).ToArray());
                    }
                    action = ifAction;
                }
                break;

                case "NOT":
                {
                    NotAction notAction = new NotAction(player);
                    commands = commands.Skip(1).ToArray();          // skip to next action
                    player.Inventory.DoAction(ref commands, ref lastAction);
                    notAction.Op = lastAction;
                    // no index increment, the ref is our increment
                    action = notAction;
                }
                break;

                case "AND":
                {
                    AndAction andAction = new AndAction(player);
                    commands      = commands.Skip(1).ToArray();
                    andAction.Op1 = lastAction;
                    player.Inventory.DoAction(ref commands, ref lastAction);
                    andAction.Op2 = lastAction;
                    // no index increment, the ref is our increment
                    action = andAction;
                }
                break;

                case "OR":
                {
                    OrAction orAction = new OrAction(player);
                    commands     = commands.Skip(1).ToArray();
                    orAction.Op1 = lastAction;
                    player.Inventory.DoAction(ref commands, ref lastAction);
                    orAction.Op2 = lastAction;
                    // no index increment, the ref is our increment
                    action = orAction;
                }
                break;

                case "GIVE":
                {
                    GiveAction giveAction = new GiveAction(player);
                    index++;
                    if (commands.Length > 1)
                    {
                        giveAction.ItemName = commands[1];
                        index++;
                    }
                    if (commands.Length > 3 && commands[2].ToUpper() == "TO")
                    {
                        giveAction.ToItemName = commands[3];
                        index += 2;
                    }
                    action = giveAction;
                }
                break;

                case "TAKE":
                {
                    TakeAction takeAction = new TakeAction(player);
                    index++;
                    if (commands.Length > 1)
                    {
                        takeAction.ItemName = commands[1];
                        index++;
                    }
                    if (commands.Length > 3 && commands[2].ToUpper() == "FROM")
                    {
                        takeAction.FromItemName = commands[3];
                        index += 2;
                    }
                    action = takeAction;
                }
                break;

                case "HAS":
                {
                    HasAction hasAction = new HasAction(player);
                    index++;
                    if (commands.Length > 1)
                    {
                        hasAction.ItemName = commands[1];
                        index++;
                    }
                    if (commands.Length > 3 && commands[2].ToUpper() == "IN")
                    {
                        hasAction.InItemName = commands[3];
                        index += 2;
                    }
                    action = hasAction;
                }
                break;

                case "GO":
                {
                    GoAction goAction = new GoAction(player);
                    index++;
                    if (commands.Length > 1)
                    {
                        goAction.GiveItemName = commands[1];
                        goAction.TakeItemName = GoItemString;
                        index++;
                    }
                    if (goAction.ExecuteWhenCreated())
                    {
                        GoItemString = goAction.GiveItemName;
                    }
                    action = goAction;
                }
                break;

                case "INV":
                {
                    GroupAction groupAction = new GroupAction(player);
                    index++;
                    foreach (Item item in player.Inventory.Items
                             .Where(item => !item.Hidden))
                    {
                        SayAction sayAction = new SayAction(player);
                        sayAction.Message = item.DisplayName;
                        groupAction.Add(sayAction);
                    }
                    if (groupAction.Actions.Count < 1)
                    {
                        SayAction sayAction = new SayAction(player);
                        sayAction.Message = "You have no items.";
                        groupAction.Add(sayAction);
                    }
                    action = groupAction;
                }
                break;

                default:            // unrecognized? This is the base item, so there's no other items that could have matching actions.
                    index++;        // ignore it.
                    break;
                }

                commands = commands.Skip(index).ToArray();
            }

            if (action != null)
            {
                lastAction = action.Execute();
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action)
 {
     base.Perform2DViewAction(view, parent, action);
       BoundingBox box = view.SelectionMarqueeWorldBox;
       if (action == VA_AS_SELECTION && box.Valid)
       {
     Vector3F center = box.Center;
     float fRadX = box.SizeX * 0.5f;
     float fRadY = box.SizeY * 0.5f;
     parent.Add(new MoveShapeAction(this, this.Position, center));
     parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinX", fRadX)); // min values are also positive
     parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinY", fRadY));
     parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxX", fRadX));
     parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxY", fRadY));
       }
 }
        /// <summary>
        /// Takes all the items from the parent by action and removes them from the parent.
        /// This means that all items are available on that node, and from there on we take the
        /// items that we need to the next node. so if we want to create a timeline with grouping Creators => Technique => Material
        /// then we start taking all the items from creators which has a technique, and returns this list
        /// </summary>
        /// <param name="parentList">The list with items i.e. Creators</param>
        /// <param name="action">The action what it should take from the list i.e Technique</param>
        /// <returns></returns>
        private List <AdlibApi.AdlibRecord> GetItemsByCommandAndRemoveFromList(List <AdlibApi.AdlibRecord> parentList, GroupAction action)
        {
            var items = new List <AdlibApi.AdlibRecord>();

            foreach (var record in parentList)
            {
                var list = record.GetNodes();
                if (list.Any(r => r.Name == action.GroupBy))
                {
                    items.Add(record);
                }
            }
            foreach (var record in items)
            {
                parentList.Remove(record);
            }
            return(items);
        }
Exemple #30
0
 public void EnqueueWarbandAction(GroupAction action)
 {
     lock (_warbandActions)
         _warbandActions.Add(action);
 }
Exemple #31
0
        /// <summary>
        /// This function converts all physX related entities/components to new Havok plugin
        /// </summary>
        void MigrateToHavokComponents()
        {
            // PhysX plugin is still loaded? Then don't do anything
            IEditorPluginModule physXPlugin = EditorManager.GetPluginByName("PhysXEditorPlugin.EditorPlugin");

            if (physXPlugin != null && physXPlugin.Initialized)
            {
                return;
            }

            // collect all physX specific components
            ShapeComponentCollection physXComponents = new ShapeComponentCollection();
            ShapeCollection          physXEntities   = new ShapeCollection();

            foreach (Layer layer in EditorManager.Scene.Layers)
            {
                if (layer.Modifiable && layer.Loaded)
                {
                    AddPhysXComponentsRecursive(physXComponents, physXEntities, layer.Root);
                }
            }

            if (physXComponents.Count == 0 && physXEntities.Count == 0)
            {
                return;
            }

            // prompt a dialog
            DialogResult res = EditorManager.ShowMessageBox("nVidia PhysX binding specific components/entities have been found in loaded layers.\n\nShould these be permanently converted to Havok components?", "nVidia PhysX plugin not loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res != DialogResult.Yes)
            {
                return;
            }

            int iConvertedCount = 0;

            // build a list of actions for the component replacement
            if (physXComponents.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate to Havok components");
                foreach (ShapeComponent oldComp in physXComponents)
                {
                    ShapeComponent newComp = null;
                    if (oldComp.DisplayName == "vPhysXRigidBody")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
                        MigrateRigidBodyProperties(oldComp, newComp);
                    }
                    else if (oldComp.DisplayName == "vPhysXCharacterController")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokCharacterController");
                        MigrateCharacterControllerProperties(oldComp, newComp);
                    }
                    if (newComp == null)
                    {
                        continue;
                    }
                    // action to remove the old component and add the new one
                    actions.Add(new RemoveShapeComponentAction((ShapeBase)oldComp.Owner, oldComp));
                    actions.Add(new AddShapeComponentAction((ShapeBase)oldComp.Owner, newComp));
                    iConvertedCount++;
                }
                // trigger the conversion action
                EditorManager.Actions.Add(actions);
            }

            if (physXEntities.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate entities classes");
                foreach (EntityShape entity in physXEntities)
                {
                    ShapeComponent newComp = null;
                    if (entity.EntityClass == "vPhysXEntity")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
                        MigratePhysXEntityProperties(entity.EntityProperties, newComp);
                    }
                    else if (entity.EntityClass == "LineFollowerEntity_cl")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "VLineFollowerComponent");
                        MigrateLineFollowerEntityProperties(entity.EntityProperties, newComp);
                    }
                    if (newComp == null)
                    {
                        continue;
                    }
                    // we convert to base entity class and attach a component instead
                    actions.Add(SetPropertyAction.CreateSetPropertyAction(entity, "EntityClass", "VisBaseEntity_cl"));
                    actions.Add(new AddShapeComponentAction(entity, newComp));
                    iConvertedCount++;
                }
                // trigger the conversion action
                EditorManager.Actions.Add(actions);
            }

            EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Component(s) have been successfully converted.\n\nSince physics engine have quite different behavior, the parameters might have to be tweaked to match old behavior.", "PhysX to Havok component conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        int GetIndexOfDummy(GroupAction source, int count = 1)
        {
            var dummies = GetNextDummyItems(source, count);

            return(source.Parent.IndexOf(dummies.First()));
        }
 public WeGroupProductAction(string productId, GroupAction modaction)
 {
     ModAction = modaction;
 }
        /// <summary>
        /// This function converts all shapes from the old SoundPlugin to the corresponding shapes of the new FmodPlugin
        /// </summary>
        void MigrateToFmodShapes()
        {
            // If old Sound plugin is not loaded, don't do anything
            IEditorPluginModule soundPlugin = EditorManager.GetPluginByName("SoundEditorPlugin.EditorPlugin");

            if (soundPlugin == null || !soundPlugin.Initialized)
            {
                return;
            }

            // collect all sound specific shapes
            ShapeCollection soundShapes = new ShapeCollection();

            foreach (Layer layer in EditorManager.Scene.Layers)
            {
                if (layer.Modifiable && layer.Loaded)
                {
                    AddSoundShapesRecursive(soundShapes, layer.Root);
                }
            }

            if (soundShapes.Count == 0)
            {
                return;
            }

            // prompt a dialog
            DialogResult res = EditorManager.ShowMessageBox("Shapes from old Sound Plugin have been found in loaded layers.\n\nShould these be permanently converted to the corresponding shapes of the Fmod Plugin?", "Old Sound Plugin and Fmod Plugin are both loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res != DialogResult.Yes)
            {
                return;
            }

            ShapeCollection newShapes       = new ShapeCollection();
            int             iConvertedCount = 0;

            if (soundShapes.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate Sound shapes");
                foreach (ShapeObject3D oldShape in soundShapes)
                {
                    ShapeObject3D newShape = null;
                    if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundShape")
                    {
                        newShape = new FmodSoundShape(oldShape.ShapeName);
                        MigrateSoundShapeProperties(oldShape, (FmodSoundShape)newShape);

                        actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));

                        actions.Add(new MigrateSoundLinksAction(oldShape, (FmodSoundShape)newShape));
                        actions.Add(new MigrateChildrenAction(oldShape, newShape));
                        actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
                        newShapes.Add(newShape);
                    }
                    else if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape")
                    {
                        newShape = new FmodCollisionMeshShape(oldShape.ShapeName);
                        MigrateSoundCollisionShapeProperties(oldShape, (FmodCollisionMeshShape)newShape);

                        actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));
                        actions.Add(new MigrateChildrenAction(oldShape, newShape));
                        actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
                        newShapes.Add(newShape);
                    }
                    if (newShape == null)
                    {
                        continue;
                    }

                    iConvertedCount++;
                }

                // EditorManager.Actions.Add() is not used, in order to prevent a undo of the conversion
                actions.Do();
            }

            // ensure, that all migrated childs have valid engine instances
            foreach (ShapeBase shape in newShapes)
            {
                foreach (ShapeBase child in shape.ChildCollection)
                {
                    child.ReCreateEngineInstance(true);
                }
            }

            EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Shape(s) have been successfully converted.", "Sound to Fmod shapes conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void FlagEntityRecursive(ShapeCollection siblings, GroupAction actions, int iGroupID)
        {
            EditorManager.Actions.StartGroup("EnumerateEntities");

              int iSibling = 0;
              foreach (ShapeBase shape in siblings)
              {
            EntityShape entity = shape as EntityShape;
            if (entity == null || !entity.Modifiable)
              continue;

            // Simply change the name to communicate a change to the user
            EditorManager.Actions.Add(new SetShapeNameAction(entity, string.Format("Group_{0}_Sibling_{1}", iGroupID, iSibling)));

            // When editing properties of custom entity classes use a SetPropertyAction
            // e.g.:
            // DynamicPropertyCollection properties = entity.EntityProperties;
            // actions.Add(new SetPropertyAction(properties, "PropertyName", string.Format("PropertyValue")));

            // Recurse through children
            FlagEntityRecursive(shape.ChildCollection, actions, iGroupID + 1);

            iSibling++; // Increase sibling index for neighboring entities
              }

              EditorManager.Actions.EndGroup();
        }
Exemple #36
0
 void LoadZonesAtCameraPosition(bool bInsideCachedRadius)
 {
     ZoneCollection zones = GetRelevantZones(EditorManager.ActiveView.CameraPosition, bInsideCachedRadius);
       GroupAction action = new GroupAction("Reload zones");
       foreach (Zone zone in zones)
     if (!zone.Loaded)
       action.Add(new SetZoneLoadedStatusAction(zone, true));
       EditorManager.Actions.Add(action);
 }
        /// <summary>
        /// User selected the plugin, so execute it
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _menuItem_Click(object sender, EventArgs e)
        {
            // Execute the plugin recursively on all shapes in the scene
              GroupAction actions = new GroupAction("Enumerate entities");
              int iGroupID = 0;
              foreach (Layer layer in EditorManager.Scene.Layers)
            if (layer.Modifiable)
              FlagEntityRecursive(layer.Root.ChildCollection, actions, iGroupID);

              // Spawn an undoable action. To trigger it silently, just call actions.Do();
              if (actions.Valid)
            EditorManager.Actions.Add(actions);
        }
Exemple #38
0
        // Sets the absolute translation of all selected shapes to the value of the translation clipboard
        private void pasteTranslationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            transformStrip_TranslateX.Text = translationClipboard.X.ToString();
              transformStrip_TranslateY.Text = translationClipboard.Y.ToString();
              transformStrip_TranslateZ.Text = translationClipboard.Z.ToString();

              GroupAction groupAction = new GroupAction("Transform Selected");
              foreach (ShapeBase shape in EditorManager.SelectedShapes)
              {
            Shape3D shape3D = shape as Shape3D;
            if (shape3D != null)
            {
              groupAction.Add(SetPropertyAction.CreateSetPropertyAction(shape3D, "x", translationClipboard.X));
              groupAction.Add(SetPropertyAction.CreateSetPropertyAction(shape3D, "y", translationClipboard.Y));
              groupAction.Add(SetPropertyAction.CreateSetPropertyAction(shape3D, "z", translationClipboard.Z));
            }
              }
              EditorManager.Actions.Add(groupAction);
        }
        /// <summary>
        /// This function converts all physX related entities/components to new Havok plugin
        /// </summary>
        void MigrateToHavokComponents()
        {
            // PhysX plugin is still loaded? Then don't do anything
              IEditorPluginModule physXPlugin = EditorManager.GetPluginByName("PhysXEditorPlugin.EditorPlugin");
              if (physXPlugin != null && physXPlugin.Initialized)
            return;

              // collect all physX specific components
              ShapeComponentCollection physXComponents = new ShapeComponentCollection();
              ShapeCollection physXEntities = new ShapeCollection();
              foreach (Layer layer in EditorManager.Scene.Layers)
            if (layer.Modifiable && layer.Loaded)
              AddPhysXComponentsRecursive(physXComponents, physXEntities, layer.Root);

              if (physXComponents.Count == 0 && physXEntities.Count == 0)
            return;

              // prompt a dialog
              DialogResult res = EditorManager.ShowMessageBox("nVidia PhysX binding specific components/entities have been found in loaded layers.\n\nShould these be permanently converted to Havok components?", "nVidia PhysX plugin not loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
              if (res != DialogResult.Yes)
            return;

              int iConvertedCount = 0;

              // build a list of actions for the component replacement
              if (physXComponents.Count > 0)
              {
            GroupAction actions = new GroupAction("Migrate to Havok components");
            foreach (ShapeComponent oldComp in physXComponents)
            {

              ShapeComponent newComp = null;
              if (oldComp.DisplayName == "vPhysXRigidBody")
              {
            newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
            MigrateRigidBodyProperties(oldComp, newComp);
              }
              else if (oldComp.DisplayName == "vPhysXCharacterController")
              {
            newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokCharacterController");
            MigrateCharacterControllerProperties(oldComp, newComp);
              }
              if (newComp == null)
            continue;
              // action to remove the old component and add the new one
              actions.Add(new RemoveShapeComponentAction((ShapeBase)oldComp.Owner, oldComp));
              actions.Add(new AddShapeComponentAction((ShapeBase)oldComp.Owner, newComp));
              iConvertedCount++;
            }
            // trigger the conversion action
            EditorManager.Actions.Add(actions);
              }

              if (physXEntities.Count > 0)
              {
            GroupAction actions = new GroupAction("Migrate entities classes");
            foreach (EntityShape entity in physXEntities)
            {
              ShapeComponent newComp = null;
              if (entity.EntityClass == "vPhysXEntity")
              {
            newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
            MigratePhysXEntityProperties(entity.EntityProperties, newComp);
              }
              else if (entity.EntityClass == "LineFollowerEntity_cl")
              {
            newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "VLineFollowerComponent");
            MigrateLineFollowerEntityProperties(entity.EntityProperties, newComp);
              }
              if (newComp == null)
            continue;
              // we convert to base entity class and attach a component instead
              actions.Add(SetPropertyAction.CreateSetPropertyAction(entity, "EntityClass", "VisBaseEntity_cl"));
              actions.Add(new AddShapeComponentAction(entity, newComp));
              iConvertedCount++;
            }
            // trigger the conversion action
            EditorManager.Actions.Add(actions);
            }

              EditorManager.ShowMessageBox(iConvertedCount.ToString()+" Component(s) have been successfully converted.\n\nSince physics engine have quite different behavior, the parameters might have to be tweaked to match old behavior.", "PhysX to Havok component conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private async Task SendGroupActionAndWaitForAck(string connectionId, string groupName, GroupAction action)
        {
            var id  = Interlocked.Increment(ref _internalId);
            var ack = _ackHandler.CreateAck(id);
            // Send Add/Remove Group to other servers and wait for an ack or timeout
            var message = _protocol.WriteGroupCommand(new RedisGroupCommand(id, _serverName, action, groupName, connectionId));

            await PublishAsync(_channels.GroupManagement, message);

            await ack;
        }
        public void Perform2DViewAction(CSharpFramework.Controls.Scene2DView view, GroupAction parent, string action)
        {
            if (action == RO_CREATEZONEGRID)
              {
            ZoneGridProperties properties = new ZoneGridProperties();
            properties.Area = view.SelectionMarqueeWorldBox;

            using (PropertyGridDlg dlg = new PropertyGridDlg("Create a grid of zones", "Procedurally generate a grid of m times n streaming zones"))
            {
              dlg.DataObjectNoClone = properties;
              if (dlg.ShowDialog() != DialogResult.OK)
            return;
              CreateZoneGridAction createaction = new CreateZoneGridAction(properties);
              EditorManager.Actions.Add(createaction);
            }
              }
        }
        public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action)
        {
            base.Perform2DViewAction(view, parent, action);

              // sector range - used by all actions
              BoundingBox selBox = view.SelectionMarqueeWorldBox;
              int x1, y1, x2, y2;
              Config.GetSectorIndicesAtWorldPos(selBox.vMin, out x1, out y1);
              Config.GetSectorIndicesAtWorldPos(selBox.vMax, out x2, out y2);
              Config.ClampSectorRange(ref x1, ref y1, ref x2, ref y2);

              if (action == VA_EDIT_SECTOR_PROPERTIES)
              {
             ShapeCollection shapes = new ShapeCollection();
             for (int sy = y1; sy <= y2; sy++)
               for (int sx = x1; sx <= x2; sx++)
             shapes.Add(GetZone(sx, sy));
             EditorManager.SelectedShapes = shapes;
              }
              else if (action == VA_IMPORT_HEIGHTMAP)
              {
            ImportHeightmapDDS import = new ImportHeightmapDDS();
            x1 *= Config.SamplesPerSectorX;
            y1 *= Config.SamplesPerSectorY;
            x2 = (x2 + 1) * Config.SamplesPerSectorX;
            y2 = (y2 + 1) * Config.SamplesPerSectorY;
            ApplyHeightmapFilterDlg.RunFilter(import, x1, y1, x2, y2);
              }
              else if (action == VA_REPAIR_SECTORS)
              {
            EditorManager.Progress.ShowProgressDialog("Repair Sectors");
            EngineTerrain.EnsureSectorRangeLoaded(x1, y1, x2, y2, (int)SectorEditorFlags_e.AnythingDirty, true, true, EditorManager.Progress);
            EditorManager.Progress.HideProgressDialog();
              }
              else if (action == VA_RELOAD_SECTORS)
              {
            EditorManager.Progress.ShowProgressDialog("Reload Sectors");
            EngineTerrain.ReloadSectorRange(x1, y1, x2, y2, false, EditorManager.Progress);
            EditorManager.Progress.HideProgressDialog();
            EditorManager.ActiveView.UpdateView(false);
              }
        }
 public bool CreateGrid(GroupAction parent)
 {
     if (!_area.Valid)
     return false;
       for (int y = 0; y < SubdivisionsY; y++)
       {
     for (int x = 0; x < SubdivisionsX; x++)
     {
       Zone z = CreateNewZone(x, y);
       Layer l = CreateNewLayer(x, y);
       parent.Add(new AddZoneAction(z, false));
       l.AttachToZone(z);
       parent.Add(new AddLayerAction(l, false));
       if (_bCreateLoaded != z.Loaded)
     parent.Add(new SetZoneLoadedStatusAction(z, _bCreateLoaded));
     }
       }
       return true;
 }
Exemple #44
0
        internal Group DeserialiseGroup(group grp, int id)
        {
            var ret = new Group
            {
                Id              = (byte)id,
                Name            = grp.name,
                Background      = grp.background == null ? null : Path.Combine(directory, grp.background),
                BackgroundStyle = grp.backgroundStyle.ToString(),
                Board           = grp.board == null ? null : Path.Combine(directory, grp.board),
                BoardPosition   = grp.boardPosition == null ? new DataRectangle {
                    X = 0, Y = 0, Height = 0, Width = 0
                } :
                new DataRectangle
                {
                    X      = double.Parse(grp.boardPosition.Split(',')[0]),
                    Y      = double.Parse(grp.boardPosition.Split(',')[1]),
                    Width  = double.Parse(grp.boardPosition.Split(',')[2]),
                    Height = double.Parse(grp.boardPosition.Split(',')[3])
                },
                Collapsed    = bool.Parse(grp.collapsed.ToString()),
                Height       = Int32.Parse(grp.height),
                Width        = Int32.Parse(grp.width),
                Icon         = grp.icon == null ? null : Path.Combine(directory, grp.icon),
                Ordered      = bool.Parse(grp.ordered.ToString()),
                Shortcut     = grp.shortcut,
                CardActions  = new List <IGroupAction>(),
                GroupActions = new List <IGroupAction>()
            };

            if (grp.Items != null)
            {
                foreach (var item in grp.Items)
                {
                    if (item is action)
                    {
                        var i  = item as action;
                        var to = new GroupAction
                        {
                            Name          = i.menu,
                            Shortcut      = i.shortcut,
                            BatchExecute  = i.batchExecute,
                            Execute       = i.execute,
                            DefaultAction = bool.Parse([email protected]())
                        };
                        if (item is cardAction)
                        {
                            (ret.CardActions as List <IGroupAction>).Add(to);
                        }
                        else if (item is groupAction)
                        {
                            (ret.GroupActions as List <IGroupAction>).Add(to);
                        }
                    }
                    else if (item is actionSubmenu)
                    {
                        var i  = item as actionSubmenu;
                        var to = new GroupActionGroup {
                            Children = new List <IGroupAction>(), Name = i.menu
                        };
                        to.Children = this.DeserializeGroupActionGroup(i);
                        if (item is cardActionSubmenu)
                        {
                            (ret.CardActions as List <IGroupAction>).Add(to);
                        }
                        else if (item is groupActionSubmenu)
                        {
                            (ret.GroupActions as List <IGroupAction>).Add(to);
                        }
                    }
                }
            }
            switch (grp.visibility)
            {
            case groupVisibility.none:
                ret.Visibility = GroupVisibility.Nobody;
                break;

            case groupVisibility.me:
                ret.Visibility = GroupVisibility.Owner;
                break;

            case groupVisibility.all:
                ret.Visibility = GroupVisibility.Everybody;
                break;

            case groupVisibility.undefined:
                ret.Visibility = GroupVisibility.Undefined;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(ret);
        }
        private async Task SendGroupActionAndWaitForAck(string connectionId, string groupName, GroupAction action)
        {
            var id  = Interlocked.Increment(ref _InternalId);
            var ack = _ackHandler.CreateAck(id);

            RabbitMQGroupCommand command = new RabbitMQGroupCommand(id, action, this._QueueName, groupName, connectionId);

            await SendGroupManagement(command);

            await ack;
        }
        void CollectModelChangedActions(string newModelFile, GroupAction actions)
        {
            tempBones.Clear();
              EngineInstanceEntity.GetBones(newModelFile, tempBones);

              List<BoneProxyShape> list = this.ExposedBones;

              if (list != null)
            foreach (BoneProxyShape bone in list)
              if (FindBoneDescByName(tempBones,bone.BoneName)==null) // remove bone shape
            RemoveBone(actions, bone);
              else
            bone.SetEngineInstanceBaseProperties();
        }
        /// <summary>
        /// Transforms the list of items into something easily usable (a Plots object).
        /// Performs also operations such as SUM, COUNT over GROUPBY
        /// </summary>
        /// <param name="xValue">The name of the column to use as xValue</param>
        /// <param name="yValue">The nam of the column to use as yValue</param>
        /// <param name="action">The action to perform, if any...</param>
        /// <returns></returns>
        public Plots PrepareData(string xValue, string yValue, GroupAction action)
        {
            // We first check that xValue and yValue are correct and throw an exception if needed
            if (!_items.List.Fields.ContainsField(xValue))
            {
                string message = "The column \"" + xValue + "\" does not exist in the list \"" + _items.List.Title + "\" or in the specified view \"" + _view.Title + "\".<br /><br />Check the view you specified and make sure that the column exists.";
                message += ListValidColumns();
                throw (new Exception(message));
            }
            if (yValue != String.Empty && !_items.List.Fields.ContainsField(yValue))
            {
                string message = "The column \"" + yValue + "\" does not exist in the list \"" + _items.List.Title + "\" or in the specified view \"" + _view.Title + "\".<br /><br />Check the view you specified and make sure that the column exists.";
                message += ListValidColumns();
                throw (new Exception(message));
            }

            // We prepare our output
            Plots plots = new Plots();

            // We loop through our SPList
            foreach (SPListItem item in _items)
            {
                // We get the X and Y from
                string x = "";
                try
                {
                    if (item[xValue] == null)
                        continue;

                    x = item[xValue].ToString();
                }
                catch
                {
                    throw (new Exception("The column \"" + xValue + "\" does not exist in the view"));
                }

                double y = 0;
                if (yValue != String.Empty) Double.TryParse(item[yValue].ToString(), out y);

                // The value is already in our array
                if (plots.Contains(x))
                {
                    int pos = plots.XIndexOf(x);

                    if (action == GroupAction.COUNT)
                    {
                        // Count, we add +1 to the existing value
                        plots.SetY(pos, Double.Parse(plots.GetY(pos).ToString()) + 1);
                    }
                    if (action == GroupAction.SUM)
                    {
                        // Sum, we add the value to the existing value
                        plots.SetY(pos, Double.Parse(plots.GetY(pos).ToString()) + y);
                    }
                    if (action == GroupAction.NOTHING)
                    {
                        // No action, we simply add the value
                        plots.Add(x, y);
                    }
                }
                else // The value is a new one in our array
                {
                    if (action == GroupAction.COUNT)
                    {
                        // Count, the first yValue is 1.
                        plots.Add(x, 1);
                    }
                    else
                    {
                        // anything else than Count, we just add the plot
                        plots.Add(x, y);
                    }
                }
            }
            return plots;
        }
        /// <summary>
        /// Build nav mesh button
        /// </summary>
        private void BuildNavMesh_Click(object sender, EventArgs e)
        {
            CSharpFramework.Scene.ZoneCollection zones = EditorManager.Scene.Zones.ShallowClone();
              GroupAction groupLoadAction = new GroupAction("Load all zones");

              foreach (CSharpFramework.Scene.Zone zone in zones)
            groupLoadAction.Add(new CSharpFramework.Actions.SetZoneLoadedStatusAction(zone, true));
              groupLoadAction.Do();

              {
            // for printing out stats
            BuildStatisticsRichTextBox.ScrollBars = RichTextBoxScrollBars.ForcedVertical;
            Font oldFont = BuildStatisticsRichTextBox.SelectionFont;
            Font newFontPlain = new Font(oldFont, oldFont.Style & ~FontStyle.Bold);
            Font newFontBold = new Font(oldFont, oldFont.Style | FontStyle.Bold);

            ShapeCollection navMeshShapes = EditorManager.Scene.AllShapesOfType(typeof(HavokNavMeshShape));

            // gather all geometry once (divide by zone later)
            ShapeCollection staticGeometries = new ShapeCollection();
            {
              int numEntities = 0, numStaticMeshes = 0, numTerrains = 0;
              int numCarvers = 0, numSeedPoints = 0, numLocalSettings = 0;
              gatherGeometricShapes(ref staticGeometries, ref numEntities, ref numStaticMeshes, ref numTerrains, ref numCarvers, ref numSeedPoints, ref numLocalSettings);

              //
              // print out some debug info
              //
              BuildStatisticsRichTextBox.SelectionStart = BuildStatisticsRichTextBox.Text.Length;
              {
            String inputGeometryLabel = "Input Geometry";
            BuildStatisticsRichTextBox.Text = inputGeometryLabel;
              }
              BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
              BuildStatisticsRichTextBox.SelectionFont = newFontBold;

              {
            String inputGlobalGeometryInfo = "\n\nStatic meshes\t: " + numStaticMeshes + "\nTerrains\t\t: " + numTerrains + "\nEntities\t\t: " + numEntities +
                "\n\nCarvers\t\t: " + numCarvers + "\nSeed points\t: " + numSeedPoints + "\nLocal settings\t: " + numLocalSettings + "\n\n";
            BuildStatisticsRichTextBox.Text += inputGlobalGeometryInfo;
              }
              BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
              BuildStatisticsRichTextBox.SelectionFont = newFontPlain;

              //
              // debug info end
              //
            }

            // actually build the navmeshes here
            int numBuiltNavMeshShapes = 0;
            bool allCompleted = true;
            foreach (HavokNavMeshShape shape in navMeshShapes)
            {
              int numGeometryVertices = 0, numGeometryTriangles = 0;

              // note that the build function only uses static geometries that lie in the same zone!
              bool built = shape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles);

              if (built)
              {
            numBuiltNavMeshShapes++;

            //
            // print out some debug info
            //
            BuildStatisticsRichTextBox.SelectionStart = BuildStatisticsRichTextBox.Text.Length;
            {
              String navMeshLabel = "\n\nNav Mesh #" + numBuiltNavMeshShapes;
              BuildStatisticsRichTextBox.Text += navMeshLabel;
            }
            BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
            BuildStatisticsRichTextBox.SelectionFont = newFontBold;

            BuildStatisticsRichTextBox.SelectionStart = BuildStatisticsRichTextBox.Text.Length;
            {
              String inputPerNavMeshGeometryInfo = "\nTotal input triangles\t: " + numGeometryTriangles + "\nTotal input vertices\t: " + numGeometryVertices + "\n\n";
              int facesSize = shape.GetNavMeshFaceSize() * shape.GetNumNavMeshFaces();
              int edgesSize = shape.GetNavMeshEdgeSize() * shape.GetNumNavMeshEdges();
              int verticesSize = shape.GetNavMeshVertexSize() * shape.GetNumNavMeshVertices();
              int totalSize = shape.GetNavMeshStructSize() + facesSize + edgesSize + verticesSize;

              String navMeshInfo = "\nTotal size\t\t: " + totalSize +
                  " bytes\nFaces ( " + shape.GetNumNavMeshFaces() + " )\t: " + facesSize +
                  "\nEdges ( " + shape.GetNumNavMeshEdges() + " )\t: " + edgesSize +
                  "\nVertices ( " + shape.GetNumNavMeshVertices() + " )\t: " + verticesSize;
              BuildStatisticsRichTextBox.Text += navMeshInfo;
            }
            BuildStatisticsRichTextBox.SelectionLength = BuildStatisticsRichTextBox.Text.Length - BuildStatisticsRichTextBox.SelectionStart;
            BuildStatisticsRichTextBox.SelectionFont = newFontPlain;

            //
            // debug info end
            //
              }
              else
              {
              allCompleted = false;
              break;
              }
            }

            if (allCompleted)
            {
            // stitch the navmeshes together
            using (HavokAiManaged.EngineInstanceHavokNavMeshLinker linker = new HavokAiManaged.EngineInstanceHavokNavMeshLinker())
            {
                // collect all navmeshes at once
                foreach (HavokNavMeshShape shape in navMeshShapes)
                {
                    if (shape.HasEngineInstance())
                    {
                        linker.AddNavMeshShape(shape._engineInstance.GetNativeObject());

                        HavokNavMeshGlobalSettings globalSettings = GetGlobalSettings(shape.NavMeshGlobalSettingsKey);
                        if (globalSettings != null)
                        {
                          linker.m_linkEdgeMatchTolerance = globalSettings.LinkEdgeMatchTolerance;
                          linker.m_linkMaxStepHeight = globalSettings.LinkMaxStepHeight;
                          linker.m_linkMaxSeparation = globalSettings.LinkMaxSeparation;
                          linker.m_linkMaxOverhang = globalSettings.LinkMaxOverhang;

                          linker.m_linkCosPlanarAlignmentAngle = (float)Math.Cos(globalSettings.LinkPlanarAlignmentAngle / 180.0f * 3.14159f);
                          linker.m_linkCosVerticalAlignmentAngle = (float)Math.Cos(globalSettings.LinkVerticalAlignmentAngle / 180.0f * 3.14159f);
                          linker.m_linkMinEdgeOverlap = globalSettings.LinkMinEdgeOverlap;
                        }
                    }
                }

                // link them together
                linker.LinkNavMeshes();
            }

            // save it to disk (separate from next loop because we want to guarantee that we don't serialize out some runtime only data)
            foreach (HavokNavMeshShape shape in navMeshShapes)
            {
                shape.SaveNavMeshesToFile();
            }

            // finally load it into the havok ai world
            foreach (HavokNavMeshShape shape in navMeshShapes)
            {
                shape.AddNavMeshToWorld();
            }

            if (EditorManager.InPlayingMode && WantPhysicsConnection())
            {
                HavokAiManaged.ManagedModule.SetConnectToPhysicsWorld(true, false);
            }
            }

            EnableBuildButtonAsterisk(false);
            //EnableStreamingDependentControls(shape.GetNumNavMeshes()>1);
              }

              groupLoadAction.Undo();

              EditorManager.ActiveView.UpdateView(true);
        }
        /// <summary>
        /// Generate the nice XML output for fusion charts
        /// </summary>
        /// <param name="chartTitle">Title of the chart</param>
        /// <param name="xValue">Column name to use as x value</param>
        /// <param name="xTitle">Title to give to x</param>
        /// <param name="yValue">Column name to use as y value</param>
        /// <param name="yTitle">Title to give to y</param>
        /// <param name="groupAction">Action to perform (sum, count, ...)</param>
        /// <param name="colors">List of colors to use (separated by ;)</param>
        /// <returns></returns>
        public string GenerateXml(string chartTitle, string xValue, string xTitle, string yValue, string yTitle, GroupAction groupAction, string colors)
        {
            // We first convert color (string) into a nice array
            string[] separator = {";"};
            string[] colorsArray = colors.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            StringBuilder sb = new StringBuilder();
            // We open the graph tag with a few parameters
            sb.AppendLine("<graph caption='" + chartTitle + "' xAxisName='" + xTitle + "' yAxisName='" + yTitle + "'>");

            // We prepare the data in a nice hashtable
            Plots plots = PrepareData(xValue, yValue, groupAction);
            for (int i = 0; i < plots.Count(); i++)
            {
                // We try to compute the color
                string color = "";
                try
                {
                    color = colorsArray[i % (colorsArray.Length)]; // computes to color to use
                }
                catch { } // if we fail we skip the error, default color will be used

                // We add a line to the XML
                sb.Append("<set name='" + plots.GetX(i) + "' value='" + plots.GetY(i).ToString() + "'");
                if (color != "") sb.Append(" color='" + color + "'");
                sb.AppendLine(" />");
            }

            // We close the graph tag opened previously
            sb.AppendLine("</graph>");

            // We finally return the xml data
            return sb.ToString();
        }
            public override void Do()
            {
                GroupAction actions = new GroupAction("Migrate sounds links");
                foreach (LinkTarget oldLinkTarget in _oldShape.LinkTargets)
                {
                  if ((oldLinkTarget.Name == "Pause") || (oldLinkTarget.Name == "Resume"))
                  {
                // The _newShape.LinkTargets collection is empty unless the engine instance has been created.
                // This is the case because the AddShape action has been executed prior to this.
                foreach (LinkTarget newLinkTarget in _newShape.LinkTargets)
                {
                  if (newLinkTarget.Name == oldLinkTarget.Name)
                  {
                foreach (ShapeLink oldShapeLink in oldLinkTarget.Links)
                {
                  // create links for new shape
                  actions.Add(new LinkAction(newLinkTarget, oldShapeLink));

                  foreach (ShapeLink ownerShapeLink in oldShapeLink.Links)
                  {
                    if (ownerShapeLink.OwnerShape.GetType().FullName == "SoundEditorPlugin.SoundShape") // old shape class?
                    {
                      if ((ownerShapeLink.Name == "Pause") || (ownerShapeLink.Name == "Resume"))
                      {
                        // delete links for owner of link (e.g. a Triggerbox) to old shape
                        actions.Add(new UnlinkAction(oldShapeLink, ownerShapeLink));

                        // create links for owner of link (e.g. a Triggerbox) to new shape
                        actions.Add(new LinkAction(oldShapeLink, newLinkTarget));
                      }
                    }
                  }
                }
                  }
                }
                  }
                }
                // batch actions and execute in the end so we do not modify collections inside loops
                actions.Do();
            }
Exemple #51
0
 public UserSource()
 {
     groupAction = new GroupAction();
 }