Esempio n. 1
0
        private void StopStabilizingTargetedObject()
        {
            if (m_distanceJointObject != null)
            {
                m_distanceJointObject.Remove();
                m_distanceJoint.Remove();
                m_targetedObjectJoint.Remove();
            }

            var player = ScriptHelper.CastPlayer(TargetedObject);

            if (player != null)
            {
                player.AddCommand(new PlayerCommand(PlayerCommandType.StopStagger));
                player.SetInputEnabled(true);
            }

            m_pullJoint.SetTargetObject(null);

            if (TargetedObject != null)
            {
                if (Owner.IsBot)
                {
                    TargetedObject.SetCollisionFilter(m_oldCollisionFilter);
                }
                if (TargetedObject.GetCollisionFilter().CategoryBits == CategoryBits.DynamicG2)
                {
                    TargetedObject.TrackAsMissile(true); // must be called after updating CollisionFilter
                }
                TargetedObject.SetMass(m_oldMass);
                TargetedObject = null;
            }
            IsTargetedObjectStabilized = false;
        }
Esempio n. 2
0
        public bool PickupObject()
        {
            if (TargetedObject == null)
            {
                var results = RayCastTargetedObject(true);

                if (results.Count() > 0)
                {
                    var result = results.First();
                    TargetedObject = result.HitObject;
                    m_oldMass      = TargetedObject.GetMass();

                    // if is player, make them staggering
                    if (result.IsPlayer)
                    {
                        var player = (IPlayer)TargetedObject;
                        MakePlayer(player, PlayerCommandType.StaggerInfinite);
                    }

                    // destroy Joints so hanging stuff can be pulled
                    ScriptHelper.Unscrew(TargetedObject);

                    // some objects that are in dynamic collision group but is static (SurveillanceCamera)
                    if (TargetedObject.GetBodyType() == BodyType.Static)
                    {
                        TargetedObject.SetBodyType(BodyType.Dynamic);
                    }

                    // m_targetObjectJoint.Position is f****d up if key input event fires. idk why
                    m_magnetJoint.SetWorldPosition(GetHoldPosition(true));
                    m_pullJoint.Remove();
                    m_pullJoint = CreatePullJointObject();

                    // The AI when using GravityGun is not very good so I give the bots a little edge advantage
                    if (Owner.IsBot)
                    {
                        m_oldCollisionFilter = TargetedObject.GetCollisionFilter();
                        var noStaticCollision = TargetedObject.GetCollisionFilter();
                        // https://www.mythologicinteractiveforums.com/viewtopic.php?t=1012
                        noStaticCollision.CategoryBits = 0x1010; // marker or something
                        noStaticCollision.MaskBits     = (ushort)(noStaticCollision.MaskBits & 0x11);
                        TargetedObject.SetCollisionFilter(noStaticCollision);
                    }
                    return(true);
                }
            }
            return(false);
        }