Пример #1
0
        public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
        {
            MyPositionAndOrientation orientation = new MyPositionAndOrientation {
                Position = base.Container.Entity.PositionComp.GetPosition(),
                Up       = (SerializableVector3)base.Container.Entity.WorldMatrix.Up,
                Forward  = (SerializableVector3)base.Container.Entity.WorldMatrix.Forward
            };
            MyObjectBuilder_EntityBase base1 = MyEntityFactory.CreateObjectBuilder(base.Container.Entity as MyEntity);

            base1.PositionAndOrientation = new MyPositionAndOrientation?(orientation);
            base1.EntityId        = base.Container.Entity.EntityId;
            base1.Name            = base.Container.Entity.Name;
            base1.PersistentFlags = base.Container.Entity.Render.PersistentFlags;
            return(base1);
        }
Пример #2
0
        public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
        {
            var objBuilder = MyEntityFactory.CreateObjectBuilder(Container.Entity as MyEntity);

            objBuilder.PositionAndOrientation = new MyPositionAndOrientation()
            {
                Position = Container.Entity.PositionComp.GetPosition(),
                Up       = (Vector3)Container.Entity.WorldMatrix.Up,
                Forward  = (Vector3)Container.Entity.WorldMatrix.Forward
            };

            objBuilder.EntityId = Container.Entity.EntityId;
            Debug.Assert(objBuilder.EntityId != 0);

            objBuilder.Name            = Container.Entity.Name;
            objBuilder.PersistentFlags = Container.Entity.Render.PersistentFlags;

            return(objBuilder);
        }
Пример #3
0
        protected override void OnAnimationPlay(MyAnimationDefinition animDefinition, MyAnimationCommand command, ref string bonesArea, ref MyFrameOption frameOption, ref bool useFirstPersonVersion)
        {
            if (GetCurrentMovementState() != MyCharacterMovementEnum.Standing &&
                GetCurrentMovementState() != MyCharacterMovementEnum.RotatingLeft &&
                GetCurrentMovementState() != MyCharacterMovementEnum.RotatingRight &&
                command.ExcludeLegsWhenMoving)
            {
                //In this case, we must stop all upper animations correctly
                bonesArea   = TopBody;
                frameOption = MyFrameOption.None;
            }

            useFirstPersonVersion = IsInFirstPersonView;

            if (animDefinition.AllowWithWeapon)
            {
                if (!UseAnimationForWeapon)
                {
                    StoreWeaponRelativeMatrix();
                    UseAnimationForWeapon       = true;
                    m_resetWeaponAnimationState = true;
                }
            }

            if (!animDefinition.LeftHandItem.TypeId.IsNull)
            {
                if (m_leftHandItem != null)
                {
                    (m_leftHandItem as IMyHandheldGunObject <Sandbox.Game.Weapons.MyDeviceBase>).OnControlReleased();
                    m_leftHandItem.Close();
                }

                m_leftHandItem = MyEntityFactory.CreateEntity(animDefinition.LeftHandItem.TypeId);
                var ob = MyEntityFactory.CreateObjectBuilder(m_leftHandItem);
                m_leftHandItem.Init(ob);

                (m_leftHandItem as IMyHandheldGunObject <Sandbox.Game.Weapons.MyDeviceBase>).OnControlAcquired(this);
                UpdateLeftHandItemPosition();

                MyEntities.Add(m_leftHandItem);
            }
        }
Пример #4
0
        protected override void OnAnimationPlay(MyAnimationDefinition animDefinition, MyAnimationCommand command, ref string bonesArea, ref MyFrameOption frameOption, ref bool useFirstPersonVersion)
        {
            var currentMovementState = GetCurrentMovementState();

            if (DefinitionId.Value.SubtypeId == medievelMaleSubtypeId)
            {
                if (command.ExcludeLegsWhenMoving)
                {
                    //In this case, we must stop all upper animations correctly

                    if (currentMovementState == MyCharacterMovementEnum.RotatingLeft ||
                        currentMovementState == MyCharacterMovementEnum.RotatingRight ||
                        currentMovementState == MyCharacterMovementEnum.Standing)
                    {
                        bonesArea = TopBody + " LowerBody";
                    }
                    else
                    {
                        bonesArea = TopBody;
                    }
                    frameOption = frameOption != MyFrameOption.JustFirstFrame ? MyFrameOption.PlayOnce : frameOption;
                }
                else if (m_lastBonesArea == TopBody + " LowerBody")
                {
                    StopLowerCharacterAnimation(0.2f);
                }

                m_lastBonesArea = bonesArea;
            }
            else
            {
                if (currentMovementState != MyCharacterMovementEnum.Standing &&
                    currentMovementState != MyCharacterMovementEnum.RotatingLeft &&
                    currentMovementState != MyCharacterMovementEnum.RotatingRight &&
                    command.ExcludeLegsWhenMoving)
                {
                    //In this case, we must stop all upper animations correctly
                    bonesArea   = TopBody;
                    frameOption = frameOption != MyFrameOption.JustFirstFrame ? MyFrameOption.PlayOnce : frameOption;
                }
            }


            useFirstPersonVersion = IsInFirstPersonView;

            if (animDefinition.AllowWithWeapon)
            {
                if (!UseAnimationForWeapon)
                {
                    StoreWeaponRelativeMatrix();
                    UseAnimationForWeapon       = true;
                    m_resetWeaponAnimationState = true;
                }
            }

            if (!animDefinition.LeftHandItem.TypeId.IsNull)
            {
                if (m_leftHandItem != null)
                {
                    (m_leftHandItem as IMyHandheldGunObject <Sandbox.Game.Weapons.MyDeviceBase>).OnControlReleased();
                    m_leftHandItem.Close();
                }

                m_leftHandItem = MyEntityFactory.CreateEntity(animDefinition.LeftHandItem.TypeId);
                var ob = MyEntityFactory.CreateObjectBuilder(m_leftHandItem);
                m_leftHandItem.Init(ob);

                var leftHandTool = m_leftHandItem as IMyHandheldGunObject <Sandbox.Game.Weapons.MyDeviceBase>;
                if (leftHandTool != null)
                {
                    leftHandTool.OnControlAcquired(this);
                }

                (m_leftHandItem as IMyHandheldGunObject <Sandbox.Game.Weapons.MyDeviceBase>).OnControlAcquired(this);
                UpdateLeftHandItemPosition();

                MyEntities.Add(m_leftHandItem);
            }
        }