/// <summary>
        /// Adds the child.
        /// </summary>
        /// <param name="child">The child.</param>
        /// <param name="preserveWorldPos">if set to <c>true</c> [preserve absolute position].</param>
        public void AddChild(IMyEntity child, bool preserveWorldPos = false, bool insertIntoSceneIfNeeded = true)
        {
            //MyEntities.Remove(child);  // if it's already in the world, remove it

            MyHierarchyComponentBase childHierarchy = child.Components.Get <MyHierarchyComponentBase>();

            childHierarchy.Parent = this;

            if (preserveWorldPos)
            {
                var tmpWorldMatrix = child.WorldMatrix;

                this.Children.Add(childHierarchy);

                child.WorldMatrix = tmpWorldMatrix;
            }
            else
            {
                this.Children.Add(childHierarchy);

                MyPositionComponentBase positionComponent      = Container.Get <MyPositionComponentBase>();
                MyPositionComponentBase childPositionComponent = child.Components.Get <MyPositionComponentBase>();

                var m = positionComponent.WorldMatrix;
                childPositionComponent.UpdateWorldMatrix(ref m);
            }

            if (Container.Entity.InScene && !child.InScene && insertIntoSceneIfNeeded)
            {
                child.OnAddedToScene(Container.Entity);
            }
        }
Ejemplo n.º 2
0
        protected void RaiseOnPositionChanged(MyPositionComponentBase component)
        {
            var handle = OnPositionChanged;

            if (handle != null)
            {
                handle(component);
            }
        }
 protected void RaiseOnPositionChanged(MyPositionComponentBase component)
 {
     var handle = OnPositionChanged;
     if (handle != null) handle(component);
 }
Ejemplo n.º 4
0
 void PositionComp_OnPositionChanged(MyPositionComponentBase obj)
 {
     if (m_collidingEntities.ContainsKey((MyEntity)obj.Container.Entity))
     {
         if (m_frameCounter - m_collidingEntities[(MyEntity)obj.Container.Entity].FrameTime > 20)
         { //Object not contacted with grid for 20 frames
             obj.OnPositionChanged -= PositionComp_OnPositionChanged;
             DynamicWeights.Remove(m_collidingEntities[(MyEntity)obj.Container.Entity].Position);
             m_collidingEntities.Remove((MyEntity)obj.Container.Entity);
             m_needsRecalc = true;
         }
     }
 }
 void PositionComp_OnPositionChanged(MyPositionComponentBase obj)
 {
     //if (m_collidingEntities.ContainsKey((MyEntity)obj.Entity))
     //{
     //    if (m_frameCounter - m_collidingEntities[(MyEntity)obj.Entity].FrameTime > 20)
     //    { //Object not contacted with grid for 20 frames
     //        obj.OnPositionChanged -= PositionComp_OnPositionChanged;
     //        DynamicWeights.Remove(m_collidingEntities[(MyEntity)obj.Entity].Position);
     //        m_collidingEntities.Remove((MyEntity)obj.Entity);
     //        ForceRecalc = true;
     //    }
     //}
 }
Ejemplo n.º 6
0
 public abstract void PositionChanged(MyPositionComponentBase obj);
Ejemplo n.º 7
0
 void entity_OnPositionChanged(MyPositionComponentBase entity)
 {
     DetectedEntityInfo info;
     if (m_detectedEntities.TryGetValue(entity.Container.Entity as MyEntity, out info))
     {
         info.Moved = true;
     }
 }