Inheritance: MonoBehaviour
Esempio n. 1
0
        internal static void InvokeScp049RecallEvent(Player player, ref Ragdoll ragdoll, ref Player target,
                                                     ref bool allow, ref RoleType role, ref float lives)
        {
            if (Scp049RecallEvent == null)
            {
                return;
            }

            var ev = new Scp049RecallEvent
            {
                Allow        = allow,
                Ragdoll      = ragdoll,
                Target       = target,
                RespawnRole  = role,
                TargetHealth = lives,
                Player       = player
            };

            Scp049RecallEvent.Invoke(ev);

            ragdoll = ev.Ragdoll;
            target  = ev.Target;
            role    = ev.RespawnRole;
            lives   = ev.TargetHealth;
            allow   = ev.Allow;
        }
    public void Update()
    {
        if (!base.isLocalPlayer)
        {
            return;
        }
        string     text = string.Empty;
        RaycastHit raycastHit;

        if (Physics.Raycast(new Ray(this.cam.position, this.cam.forward), out raycastHit, 3f, this.inspectionMask))
        {
            Ragdoll componentInParent = raycastHit.transform.GetComponentInParent <Ragdoll>();
            if (componentInParent != null)
            {
                text = TranslationReader.Get("Death_Causes", 12);
                text = text.Replace("[user]", componentInParent.owner.steamClientName);
                text = text.Replace("[cause]", RagdollManager.GetCause(componentInParent.owner.deathCause, false));
                text = text.Replace("[class]", string.Concat(new string[]
                {
                    "<color=",
                    this.GetColor(this.ccm.klasy[componentInParent.owner.charclass].classColor),
                    ">",
                    this.ccm.klasy[componentInParent.owner.charclass].fullName,
                    "</color>"
                }));
            }
        }
        this.txt.text = text;
    }
Esempio n. 3
0
    private void onDamageCallback(int amount, RaycastHit?hit)
    {
        if (!Options.lowViolence)
        {
            if (this.bloodEffectPrefab != null)
            {
                if (hit != null)
                {
                    RaycastHit rayHit       = (RaycastHit)hit;
                    GameObject spawnedDecal = GameObject.Instantiate(this.bloodEffectPrefab, rayHit.point, Quaternion.LookRotation(rayHit.normal));
                    spawnedDecal.transform.SetParent(rayHit.collider.transform);
                }
            }
        }

        if (this.health.isDead())
        {
            // Make the ragdoll floppy
            Ragdoll doll = this.GetComponent <Ragdoll>();
            if (doll != null)
            {
                this.GetComponent <Ragdoll>().makeFloppy(true, true);
            }

            // Drop the held item
            if (this.getHeldItem() != null)
            {
                this.dropItem(0, this.getFootPos());
            }
        }
    }
Esempio n. 4
0
        private static IEnumerator DropNow(Ragdoll ragdoll, ZNetView nview, EffectList removeEffect)
        {
            if (dropDelay.Value < 0)
            {
                context.StartCoroutine(DestroyNow(ragdoll, nview, removeEffect));
                yield break;
            }

            Dbgl($"delaying dropping loot");
            yield return(new WaitForSeconds(dropDelay.Value));

            if (!modEnabled.Value)
            {
                yield break;
            }

            if (!nview.IsValid() || !nview.IsOwner())
            {
                context.StartCoroutine(DropNow(ragdoll, nview, removeEffect));
                yield break;
            }
            Dbgl($"dropping loot");
            Vector3 averageBodyPosition = ragdoll.GetAverageBodyPosition();

            Traverse.Create(ragdoll).Method("SpawnLoot", new object[] { averageBodyPosition }).GetValue();
            context.StartCoroutine(DestroyNow(ragdoll, nview, removeEffect));
        }
Esempio n. 5
0
 public void BindToRagdoll(Ragdoll ragdoll)
 {
     base.transform.SetParent(ragdoll.transform);
     texturedRenderers = GetComponentsInChildren <Renderer>();
     if (rigType == Rigging.AutoRig && GetComponentInChildren <RagdollModelSkinnedMesh>() == null)
     {
         MeshRenderer[] componentsInChildren = GetComponentsInChildren <MeshRenderer>();
         for (int i = 0; i < componentsInChildren.Length; i++)
         {
             if (componentsInChildren[i].enabled)
             {
                 componentsInChildren[i].gameObject.AddComponent <RagdollModelSkinnedMesh>();
             }
         }
         SkinnedMeshRenderer[] componentsInChildren2 = GetComponentsInChildren <SkinnedMeshRenderer>();
         for (int j = 0; j < componentsInChildren2.Length; j++)
         {
             if (componentsInChildren2[j].enabled)
             {
                 componentsInChildren2[j].gameObject.AddComponent <RagdollModelSkinnedMesh>();
             }
         }
     }
     RagdollModelSkinnedMesh[] componentsInChildren3 = GetComponentsInChildren <RagdollModelSkinnedMesh>();
     if (componentsInChildren3.Length > 0)
     {
         for (int k = 0; k < componentsInChildren3.Length; k++)
         {
             componentsInChildren3[k].Reskin2(ragdoll);
         }
     }
     BindBone(ragdoll.partHead, partHead);
     BindBone(ragdoll.partChest, partChest);
     BindBone(ragdoll.partWaist, partWaist);
     BindBone(ragdoll.partHips, partHips);
     BindBone(ragdoll.partLeftArm, partLeftArm);
     BindBone(ragdoll.partLeftForearm, partLeftForearm);
     BindBone(ragdoll.partLeftHand, partLeftHand);
     BindBone(ragdoll.partLeftThigh, partLeftThigh);
     BindBone(ragdoll.partLeftLeg, partLeftLeg);
     BindBone(ragdoll.partLeftFoot, partLeftFoot);
     BindBone(ragdoll.partRightArm, partRightArm);
     BindBone(ragdoll.partRightForearm, partRightForearm);
     BindBone(ragdoll.partRightHand, partRightHand);
     BindBone(ragdoll.partRightThigh, partRightThigh);
     BindBone(ragdoll.partRightLeg, partRightLeg);
     BindBone(ragdoll.partRightFoot, partRightFoot);
     for (int l = 0; l < componentsInChildren3.Length; l++)
     {
         for (int m = 0; m < texturedRenderers.Length; m++)
         {
             if (texturedRenderers[m] == componentsInChildren3[l].originalRenderer)
             {
                 texturedRenderers[m] = componentsInChildren3[l].reskinnedRenderer;
             }
         }
     }
     texture = base.gameObject.AddComponent <RagdollTexture>();
     texture.BindToModel(this);
 }
Esempio n. 6
0
    /// <summary>
    /// The grenade is exploding
    /// </summary>
    private void Explode()
    {
        // Get all the colliders that are within range of the grenades explosion
        Collider[] colliders = Physics.OverlapSphere(transform.position, radius);

        // For each collider
        foreach (Collider near in colliders)
        {
            // Get the rigidbody and Ragdoll script
            Rigidbody rig = near.GetComponent <Rigidbody>();
            Ragdoll   rag = near.GetComponent <Ragdoll>();

            // If there is a rigidbody, then apply an explosion force
            if (rig != null)
            {
                rig.AddExplosionForce(explosionForce, transform.position, radius, 1f, ForceMode.Impulse);
            }

            // If there is a ragdoll script, then activate the ragdoll and add 1 to the amount of bots killed
            if (rag != null)
            {
                rag.RagdollOn           = true;
                rifleScript.botsKilled += 1;
            }
        }

        // Instantiate the explosion particle effect
        Instantiate(explosionEffect, transform.position, transform.rotation);

        // Destroy the grenade
        Destroy(gameObject);
    }
    public void Damage(int damageValue)
    {
        _currentHealth -= damageValue;
        if (_currentHealth < 0)
        {
            _currentHealth = 0;
        }
        else
        {
            AudioSource audio = GetComponent <AudioSource> ();
            audio.clip = _onDamage;
            audio.Play();
        }

        if (_currentHealth == 0)
        {
            Animation anim = GetComponentInChildren <Animation> ();
            anim.Stop();
            Destroy(GetComponent <PlayerMovement> ());
            Destroy(GetComponent <PlayerAnimation> ());
            Destroy(GetComponentInChildren <LookX> ());
            Destroy(GetComponentInChildren <Rifle> ());

            Ragdoll r = GetComponent <Ragdoll> ();
            if (r != null)
            {
                r.onDeath();
            }
        }
    }
Esempio n. 8
0
    // Initialization
    void Start()
    {
        // Extract terrain information
        if (!terrain)
        {
            terrain = Terrain.activeTerrain;
        }
        terrain_collider        = terrain.GetComponent <Collider>();
        terrain_data            = terrain.terrainData;
        terrain_size            = terrain_data.size;
        heightmap_width         = terrain_data.heightmapResolution;
        heightmap_height        = terrain_data.heightmapResolution;
        heightmap_data          = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height);
        heightmap_data_constant = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height);
        heightmap_data_filtered = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height);
        current_brush           = null;

        // Get classes
        _feetPlacement = FindObjectOfType <IKFeetPlacement>();
        _ragdoll       = FindObjectOfType <Ragdoll>();

        // Retrieve mass from Ragdoll
        mass = _ragdoll.CalculateMass();

        // Time elapsed
        elapsed = 0f;
    }
Esempio n. 9
0
        public virtual void Init(Observer observer)
        {
            Manager.Add(this);

            this.Observer = observer;
            observer.Data.UpdateHealth(Health);

            rigidbody = GetComponent <Rigidbody>();

            Variants = Dependancy.Get <PlayerVariants>(gameObject);

            Movement = Dependancy.Get <PlayerMovement>(gameObject);
            Body     = Dependancy.Get <PlayerBody>(gameObject);
            Aim      = Dependancy.Get <PlayerAim>(gameObject);
            Weapons  = Dependancy.Get <PlayerWeapons>(gameObject);
            Score    = Dependancy.Get <PlayerScore>(gameObject);

            References.Init(this);

            Variants.Init(this);

            Ragdoll = Dependancy.Get <RagdollController>(gameObject);
            Ragdoll.Disable();

            Health.OnValueChanged += OnHealthChanged;
        }
Esempio n. 10
0
 private void OnEnable()
 {
     human       = GetComponent <Human>();
     ragdoll     = GetComponent <Ragdoll>();
     ballRadius  = GetComponent <SphereCollider>().radius;
     grabManager = GetComponent <GrabManager>();
 }
Esempio n. 11
0
 private bool CreateRagdoll()
 {
     if (this.ragdollPrefab != null)
     {
         ArmorModelRenderer local = this.ragdollPrefab.GetLocal <ArmorModelRenderer>();
         if (local != null)
         {
             AnimationClip clip;
             float         num;
             ActorRig      actorRig = local.actorRig;
             if ((actorRig != null) && actorRig.FindPoseClip("sleep", out clip, out num))
             {
                 this.ragdollInstance            = Object.Instantiate(this.ragdollPrefab, base.transform.position, base.transform.rotation) as Ragdoll;
                 this.ragdollInstance.sourceMain = this;
                 GameObject gameObject = this.ragdollInstance.gameObject;
                 Object.Destroy(gameObject, 80f);
                 gameObject.SampleAnimation(clip, num);
                 local = this.ragdollInstance.GetLocal <ArmorModelRenderer>();
                 ArmorModelMemberMap map = new ArmorModelMemberMap();
                 bool flag = false;
                 flag |= BindArmorMap <ArmorModelFeet>(this.footArmor, ref map);
                 flag |= BindArmorMap <ArmorModelLegs>(this.legArmor, ref map);
                 flag |= BindArmorMap <ArmorModelTorso>(this.torsoArmor, ref map);
                 if (flag | BindArmorMap <ArmorModelHead>(this.headArmor, ref map))
                 {
                     local.BindArmorModels(map);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 12
0
    // Start is called before the first frame update
    void Start()
    {
        // Extract terrain information
        if (!terrain)
        {
            terrain = Terrain.activeTerrain;
        }
        terrain_collider        = terrain.GetComponent <Collider>();
        terrain_data            = terrain.terrainData;
        terrain_size            = terrain_data.size;
        heightmap_width         = terrain_data.heightmapResolution;
        heightmap_height        = terrain_data.heightmapResolution;
        heightmap_data          = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height);
        heightmap_data_constant = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height);
        heightmap_data_filtered = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height);
        brushPhysicalFootprint  = null;

        // Get classes
        _feetPlacement = FindObjectOfType <IKFeetPlacement>();
        _ragdoll       = FindObjectOfType <Ragdoll>();

        // Retrieve mass from Ragdoll
        mass = _ragdoll.CalculateMass();

        // Time elapsed
        elapsed = 0f;

        // Old Feet Y Position
        oldIKLeftPosition  = _anim.GetBoneTransform(HumanBodyBones.LeftFoot).position;
        oldIKRightPosition = _anim.GetBoneTransform(HumanBodyBones.RightFoot).position;
        oldIsMoving        = _anim.GetBool("isWalking");
    }
Esempio n. 13
0
    private bool CreateRagdoll()
    {
        AnimationClip animationClip;
        float         single;

        if (this.ragdollPrefab)
        {
            ArmorModelRenderer local = this.ragdollPrefab.GetLocal <ArmorModelRenderer>();
            if (local)
            {
                ActorRig actorRig = local.actorRig;
                if (actorRig)
                {
                    if (actorRig.FindPoseClip("sleep", out animationClip, out single))
                    {
                        this.ragdollInstance            = UnityEngine.Object.Instantiate(this.ragdollPrefab, base.transform.position, base.transform.rotation) as Ragdoll;
                        this.ragdollInstance.sourceMain = this;
                        GameObject gameObject = this.ragdollInstance.gameObject;
                        UnityEngine.Object.Destroy(gameObject, 80f);
                        gameObject.SampleAnimation(animationClip, single);
                        local = this.ragdollInstance.GetLocal <ArmorModelRenderer>();
                        ArmorModelMemberMap armorModelMemberMaps = new ArmorModelMemberMap();
                        if (false | SleepingAvatar.BindArmorMap <ArmorModelFeet>(this.footArmor, ref armorModelMemberMaps) | SleepingAvatar.BindArmorMap <ArmorModelLegs>(this.legArmor, ref armorModelMemberMaps) | SleepingAvatar.BindArmorMap <ArmorModelTorso>(this.torsoArmor, ref armorModelMemberMaps) | SleepingAvatar.BindArmorMap <ArmorModelHead>(this.headArmor, ref armorModelMemberMaps))
                        {
                            local.BindArmorModels(armorModelMemberMaps);
                        }
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Esempio n. 14
0
    private void fireGun()
    {
        Ray ray = Camera.main.ViewportPointToRay(Vector3.one * 0.5f);


        m_gunShot.Play();

        Debug.DrawRay(ray.origin, ray.direction * 100, Color.red, 2f);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, 200f, ~m_layersToIgnore))
        {
            EnemyHealth health = hitInfo.transform.gameObject.GetComponentInParent <EnemyHealth>();

            if (health != null)
            {
                if (hitInfo.transform.gameObject.name == "Head")
                {
                    Ragdoll ragdoll = hitInfo.transform.gameObject.GetComponentInParent <Ragdoll>();

                    ragdoll.m_rigidbodies.RemoveAt(ragdoll.m_rigidbodies.Count - 1);
                    Destroy(hitInfo.transform.gameObject.GetComponent <CharacterJoint>());
                    hitInfo.transform.gameObject.GetComponent <Rigidbody>().isKinematic = false;
                    health.TakeDamage(50);
                }

                health.TakeDamage(m_damage);
            }
            if (hitInfo.rigidbody != null)
            {
                hitInfo.rigidbody.AddForce(-hitInfo.normal * m_hitForce);
            }
        }
    }
    public Explosion(float force, Vector3 position, float radius, float michaelBay)
    {
        // Récupérer les colliders à proximité
        Collider[] colliders = Physics.OverlapSphere(position, radius);

        // Regarde pour trouver les objets physiques
        foreach (Collider item in colliders)
        {
            //Regarder pour le ragdoll
            Ragdoll ragdoll = item.GetComponentInParent <Ragdoll>();

            if (ragdoll != null)
            {
                ragdoll.Die();
            }
            Rigidbody rb = item.GetComponent <Rigidbody>();

            if (rb != null)
            {
                // leur donner une vélocité

                rb.AddExplosionForce(force, position, radius, michaelBay, ForceMode.Impulse);
            }
        }
    }
Esempio n. 16
0
 public static void SaveLootListPrefix(Ragdoll __instance, CharacterDrop characterDrop)
 {
     if (characterDrop.m_character.GetSEMan().HaveStatusEffect("ChainExplosionListener"))
     {
         explosionList.Add(__instance.GetInstanceID(), characterDrop.m_character.GetMaxHealth() * (float)balance["AxeFire"]["effectVal"]);
     }
 }
    public void Initialize(CameraController3 cameraController, Ragdoll ragdoll)
    {
        this.cameraController = cameraController;
        ClearMaterials();
        Dictionary <Material, Material> dictionary = new Dictionary <Material, Material>();

        Renderer[] componentsInChildren = ragdoll.GetComponentsInChildren <Renderer>();
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            Material[] sharedMaterials = componentsInChildren[i].sharedMaterials;
            for (int j = 0; j < sharedMaterials.Length; j++)
            {
                if ("Standard".Equals(sharedMaterials[j].shader.name) && sharedMaterials[j].GetFloat("_Mode") != 3f)
                {
                    Material value = null;
                    if (!dictionary.TryGetValue(sharedMaterials[j], out value))
                    {
                        value = new Material(sharedMaterials[j]);
                        dictionary[sharedMaterials[j]] = value;
                        materials.Add(value);
                    }
                    sharedMaterials[j] = value;
                }
            }
            componentsInChildren[i].sharedMaterials = sharedMaterials;
        }
    }
Esempio n. 18
0
        void DoPull()
        {
            // pull enemies in
            float   pullForce          = -300f;
            float   floorY             = 2.65f;
            Vector3 earthSpawnPosition = new Vector3(playerHead.position.x, floorY, playerHead.position.z);

            GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
            foreach (GameObject enemy in enemies)
            {
                // if it's a ragdoll make non-kinematic
                if (enemy.GetComponent <Ragdoll>() != null)
                {
                    Ragdoll ragdoll = enemy.GetComponent <Ragdoll>();
                    ragdoll.TriggerWarning();
                    foreach (Rigidbody rb in ragdoll.myParts)
                    {
                        rb.AddExplosionForce(pullForce, earthSpawnPosition, 100000f);
                    }
                }

                else if (enemy.GetComponent <Rigidbody>() != null)
                {
                    Rigidbody rb = enemy.GetComponent <Rigidbody>();
                    rb.AddExplosionForce(pullForce, earthSpawnPosition, 100000f);
                }
            }
        }
Esempio n. 19
0
 // Token: 0x06000028 RID: 40 RVA: 0x00002D14 File Offset: 0x00000F14
 public static void Prefix(Ragdoll __instance)
 {
     if (SameThings.RagdollAutoCleanup > 0)
     {
         State.Ragdolls.Add(__instance, State.CleanupTime + SameThings.RagdollAutoCleanup);
     }
 }
Esempio n. 20
0
        protected override void ReadData(BinaryReader r)
        {
            if (Type != CurrentType)
            {
                throw new Exception(
                          "Resource have wrong type [" + TypeToString(Type) + "]. [" +
                          TypeToString(CurrentType) + "] required.");
            }
            if (Version != CurrentVersion)
            {
                throw new Exception(
                          "Resource have wrong version [" + Version +
                          "]. [" + CurrentVersion + "] required.");
            }

            Nodes = new List <Node>(r.ReadInt32());
            for (int i = 0; i < Nodes.Capacity; i++)
            {
                Nodes.Add(new Node(r));
            }


            BackColor    = r.ReadInt32();
            PointBoundsX = r.ReadSingle();
            PointBoundsY = r.ReadSingle();
            PixelPerfect = r.ReadBoolean();
            GridEnabled  = r.ReadBoolean();
            Transparency = r.ReadBoolean();
            Ragdoll.Read(r);
        }
Esempio n. 21
0
        public override void LoadContent()
        {
            base.LoadContent();

            World.Gravity = new Vector2(0f, 20f);

            _border = new Border(World, Lines, Framework.GraphicsDevice);

            _ragdoll = new Ragdoll(World, new Vector2(-20f, -10f));

            _obstacles = new Body[9];
            Vector2 stairStart = new Vector2(-23f, 0f);
            Vector2 stairDelta = new Vector2(2.5f, 1.65f);

            for (int i = 0; i < 9; i++)
            {
                _obstacles[i]          = BodyFactory.CreateRectangle(World, 5f, 1.5f, 1f, stairStart + stairDelta * i);
                _obstacles[i].BodyType = BodyType.Static;
            }

            // create sprite based on body
            _obstacle = new Sprite(ContentWrapper.TextureFromShape(_obstacles[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Red, ContentWrapper.Black, ContentWrapper.Black, 1.5f));

            SetUserAgent(_ragdoll.Body, 1000f, 400f);
        }
Esempio n. 22
0
        /// <summary>
        /// Adds a BallJoint between the specified bones.
        /// </summary>
        /// <param name="skeletonPose">The skeleton pose.</param>
        /// <param name="ragdoll">The ragdoll.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="child">The child.</param>
        private static void AddJoint(SkeletonPose skeletonPose, Ragdoll ragdoll, int parent, int child)
        {
            // Get bodies and offsets for the bones.
            var skeleton     = skeletonPose.Skeleton;
            var childBody    = ragdoll.Bodies[child];
            var childOffset  = ragdoll.BodyOffsets[child];
            var parentBody   = ragdoll.Bodies[parent];
            var parentOffset = ragdoll.BodyOffsets[parent];

            // Get bind poses of the bones in model space.
            var parentBindPoseAbsolute = (Pose)skeleton.GetBindPoseAbsoluteInverse(parent).Inverse;
            var childBindPoseAbsolute  = (Pose)skeleton.GetBindPoseAbsoluteInverse(child).Inverse;

            // The child pose relative to the parent bone.
            var bindPoseRelative = parentBindPoseAbsolute.Inverse * childBindPoseAbsolute;

            // Add BallJoint that connects the two bones. The position of the joint is the
            // origin of the child bone.
            BallJoint joint = new BallJoint
            {
                BodyA                = parentBody,
                BodyB                = childBody,
                CollisionEnabled     = false,
                AnchorPositionALocal = (parentOffset.Inverse * bindPoseRelative).Position,
                AnchorPositionBLocal = childOffset.Inverse.Position,
                ErrorReduction       = 0.2f,
                Softness             = 0.0001f,
            };

            ragdoll.Joints.Add(joint);
        }
Esempio n. 23
0
        /// <summary>
        /// Adds an AngularLimit between the specified bones.
        /// </summary>
        /// <param name="skeletonPose">The skeleton pose.</param>
        /// <param name="ragdoll">The ragdoll.</param>
        /// <param name="parent">The parent bone.</param>
        /// <param name="child">The child bone.</param>
        /// <param name="minimum">The minimum limits for each constraint axis (x/y/z).</param>
        /// <param name="maximum">The maximum limits for each constraint axis (x/y/z).</param>
        /// <remarks>
        /// The constraint anchor orientation is the orientation of the child bone.
        /// </remarks>
        private static void AddAngularLimit(SkeletonPose skeletonPose, Ragdoll ragdoll, int parent, int child, Vector3F minimum, Vector3F maximum)
        {
            var skeleton     = skeletonPose.Skeleton;
            var childBody    = ragdoll.Bodies[child];
            var childOffset  = ragdoll.BodyOffsets[child];
            var parentBody   = ragdoll.Bodies[parent];
            var parentOffset = ragdoll.BodyOffsets[parent];

            var parentBindPoseAbsolute = (Pose)skeleton.GetBindPoseAbsoluteInverse(parent).Inverse;
            var childBindPoseAbsolute  = (Pose)skeleton.GetBindPoseAbsoluteInverse(child).Inverse;
            var bindPoseRelative       = parentBindPoseAbsolute.Inverse * childBindPoseAbsolute;

            var limit = new AngularLimit
            {
                BodyA = parentBody,
                BodyB = childBody,
                AnchorOrientationALocal = parentOffset.Orientation.Transposed * bindPoseRelative.Orientation,
                AnchorOrientationBLocal = childOffset.Orientation.Transposed,
                Minimum        = minimum,
                Maximum        = maximum,
                ErrorReduction = new Vector3F(0.2f),
                Softness       = new Vector3F(0.001f)
            };

            ragdoll.Limits.Add(limit);
        }
Esempio n. 24
0
        public override void Update()
        {
            if (_overrider || _stunTime <= 0 || _stunTarget == null)
            {
                if (!_overrider && _stunTarget != null)
                {
                    _stunTarget.immobilized = false;
                }
                Level.Remove(this);
                return;
            }

            _stunTarget.immobilized = true;

            Ragdoll rag = _stunTarget.ragdoll;

            rag._part1.vSpeed  += NetRand.Float(-2f, 2f);
            rag._part3.vSpeed  += NetRand.Float(-2f, 2f);
            rag._part2.vSpeed  -= NetRand.Float(1.5f, 2f);
            rag._part2.position = ipos + new Vec2(10f * mover.value);
            rag._timeSinceNudge = 0f;

            _stunTime--;

            base.Update();
        }
Esempio n. 25
0
            protected override void WriteData(BinaryWriter w)
            {
                Ragdoll.Write(w);
                w.Write(Holders.Count);
                for (int i = 0; i < Holders.Count; i++)
                {
                    Holders[i].Write(w);
                }
                w.Write(Triggers.Count);
                for (int i = 0; i < Triggers.Count; i++)
                {
                    Triggers[i].Write(w);
                }

                w.Write(MaxHealth);
                w.Write(MaxEnergy);
                w.Write(Mass);
                w.Write(GravityAcceleration);
                w.Write(JumpVelocity);
                w.Write(DragX);
                w.Write(DragY);
                w.Write(SqrDragX);
                w.Write(SqrDragY);
                w.Write(MoveForceX);
                w.Write(MoveForceY);

                w.Write(BackColor.ToArgb());
                w.Write(PointBounds);
                w.Write(GridEnabled);
                w.Write(Transparency);
            }
Esempio n. 26
0
    // Update is called once per frame
    void Update()
    {
        // Do this when the left mouse button is clicked.
        if (Input.GetMouseButtonDown(0))
        {
            // Ray cast at the centre of the window.
            Ray raycast = Camera.main.ScreenPointToRay(new Vector3(Camera.main.scaledPixelWidth * 0.5f, Camera.main.scaledPixelHeight * 0.5f, 0));

            // Get the info of what the ray hit.
            RaycastHit hitInfo;

            // Creating a new layer mask for ragdolls.
            LayerMask layerMask =
                ~(LayerMask.NameToLayer("Ragdoll"));

            // If the raycasst hit a ragdoll, do this.
            if (Physics.Raycast(raycast, out hitInfo, 100.0f, layerMask.value))
            {
                // Turn into a ragdoll.
                Ragdoll ragdoll = hitInfo.transform.gameObject.GetComponentInParent <Ragdoll>();
                if (ragdoll != null)
                {
                    ragdoll.RagdollOn = true;
                }
            }
        }
    }
Esempio n. 27
0
    void Update()
    {
        // Si je fais feu
        if (Input.GetMouseButtonDown(0))
        {
            particule.Play();
            // je fais un rayon à partir du BarrelEnd
            Ray        bulletRay = new Ray(barrelEnd.position, barrelEnd.forward);
            RaycastHit hit;

            // PointA du LineRenderer
            //bulletLine.SetPosition(0, barrelEnd.position);
            // Si le rayon impacte sur un objet, on le propulse
            if (Physics.Raycast(bulletRay, out hit))
            {
                // PointB du LineRenderer (tir réussi)
                //bulletLine.SetPosition(1, hit.point);

                Explode(hit.point);


                // Ragdoll?
                Ragdoll ragdoll = hit.collider.GetComponentInParent <Ragdoll>();
                if (ragdoll != null)
                {
                    ragdoll.die = true;
                }
            }
        }
    }
Esempio n. 28
0
    public void Die()
    {
        Ragdoll r = (Instantiate(ragdoll, transform.position, transform.rotation) as GameObject).GetComponent <Ragdoll>();

        r.CopyPose(transform);
        Destroy(this.gameObject);
    }
Esempio n. 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FinishingRecallEventArgs"/> class.
 /// </summary>
 /// <param name="target"><inheritdoc cref="Target"/></param>
 /// <param name="scp049"><inheritdoc cref="Scp049"/></param>
 /// <param name="ragdoll"><inheritdoc cref="Ragdoll"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public FinishingRecallEventArgs(Player target, Player scp049, global::Ragdoll ragdoll, bool isAllowed = true)
 {
     Target    = target;
     Scp049    = scp049;
     Ragdoll   = Ragdoll.Get(ragdoll);
     IsAllowed = isAllowed;
 }
Esempio n. 30
0
        void DoEarth()
        {
            float explosionForce = 300f;

            Quaternion rotation           = Quaternion.LookRotation(Vector3.forward, Vector3.up);
            float      floorY             = 2.65f;
            Vector3    earthSpawnPosition = new Vector3(playerHandR.position.x, floorY, playerHandR.position.z);

            GameObject.Instantiate(earth, earthSpawnPosition, rotation);

            GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
            foreach (GameObject enemy in enemies)
            {
                // if it's a ragdoll make non-kinematic
                if (enemy.GetComponent <Ragdoll>() != null)
                {
                    Ragdoll ragdoll = enemy.GetComponent <Ragdoll>();
                    ragdoll.TriggerWarning();
                    foreach (Rigidbody rb in ragdoll.myParts)
                    {
                        rb.AddExplosionForce(explosionForce, earthSpawnPosition, 100000f);
                    }
                }

                else if (enemy.GetComponent <Rigidbody>() != null)
                {
                    Rigidbody rb = enemy.GetComponent <Rigidbody>();
                    rb.AddExplosionForce(explosionForce, earthSpawnPosition, 10f);
                }
            }
        }
Esempio n. 31
0
    /// <summary>
    /// Copies the RagdollJoint data, EffectData from to.
    /// </summary>
    public static void CopyRagdollData(Ragdoll _from, Ragdoll to)
    {
        IList<RagdollJointData> jointDataList = new List<RagdollJointData> ();
        foreach(RagdollJointData jointData in _from.RagdollJointDataArray)
        {
           RagdollJointData cloned = jointData.GetClone();
           jointDataList.Add(cloned);
        }
        to.RagdollJointDataArray = jointDataList.ToArray();

        IList<EffectData> effectDataList = new List<EffectData> ();
        foreach(EffectData effectData in _from.EffectData)
        {
           EffectData cloned = effectData.GetClone();
           effectDataList.Add(cloned);
        }
        to.EffectData = effectDataList.ToArray();
    }
Esempio n. 32
0
    void OnGUI()
    {
        MainWindowWidth = position.width;
        MainWindowHeight = position.height;
        GameObject selectedGameObject = Selection.activeGameObject;
        if (selectedGameObject == null) {
            Debug.LogWarning ("No gameObject is selected.");
            return;
        }

        if(Selection.activeObject != null &&
            Selection.activeGameObject.GetComponent<Ragdoll>() != null && GUILayout.Button("Use selected gameobject"))
        {
            ragdollToEdited = Selection.activeGameObject.GetComponent<Ragdoll>();
        }
        ragdollToEdited = (Ragdoll)EditorGUILayout.ObjectField(ragdollToEdited, typeof (Ragdoll));

        if(ragdollToEdited == null)
            return;

        if (GUILayout.Button ("Save object")) {
            EditorUtility.SetDirty (ragdollToEdited);
            EditorUtility.SetDirty (ragdollToEdited.gameObject);
        }

        selectedRagdoll = ragdollToEdited;
        ScrollPosition = EditorGUILayout.BeginScrollView (ScrollPosition, false, true, null);
        EditRagdollBase();
        //EditEffectData();
        if (EnableEditEffectData = EditorGUILayout.BeginToggleGroup ("---Edit Effect Data---", EnableEditEffectData)) {
            selectedRagdoll.EffectData = EditorCommon.EditEffectData(selectedRagdoll.EffectData);
        }
        EditorGUILayout.EndToggleGroup();
        EditDecalData();
        EditRagdollJointData();
        EditorGUILayout.EndScrollView();
    }
Esempio n. 33
0
    void OnGUI()
    {
        #region measure distance between two objects
        measureTwoObjects = EditorGUILayout.BeginToggleGroup ("Measure two characters", measureTwoObjects);
        if (measureTwoObjects) {
            MeasureObjectA = (GameObject)EditorGUILayout.ObjectField (MeasureObjectA, typeof(GameObject));
            MeasureObjectB = (GameObject)EditorGUILayout.ObjectField (MeasureObjectB, typeof(GameObject));
            if (GUILayout.Button ("Measure the distance of two game object")) {
                float distanceOfCharacter = Util.DistanceOfCharacters (MeasureObjectA, MeasureObjectB);
        //			float distanceOfCharacter_XZ = Util.DistanceOfCharactersXZ(MeasureObjectA, MeasureObjectB);
                float distanceOfTransform = Vector3.Distance (MeasureObjectA.transform.position, MeasureObjectB.transform.position);
                Debug.Log (string.Format ("Distance of character:{0}; Distance of transform:{1};", distanceOfCharacter, distanceOfTransform));
            }
        }
        EditorGUILayout.EndToggleGroup ();
        #endregion

        #region print position and rotation

        if (GUILayout.Button ("Print selection active position + rotation, and audio source status.")) {
            string msg = string.Format ("Position:{0}, Rotation:{1}, AudioSource:{2}",
                                       Selection.activeGameObject.transform.position,
                                       Selection.activeGameObject.transform.rotation,
                                       Selection.activeGameObject.GetComponent<AudioSource> () != null ? Selection.activeGameObject.GetComponent<AudioSource> ().isPlaying.ToString () : "no audio"
                                      );
            Debug.Log (msg);
        }
        #endregion

        #region measure two objects relative position
        MeasureTwoObjectRelativePosition = EditorGUILayout.BeginToggleGroup ("Measure two object relative position", MeasureTwoObjectRelativePosition);
        if (MeasureTwoObjectRelativePosition) {
            MeasureTransformA = (Transform)EditorGUILayout.ObjectField ("Measured A:",MeasureTransformA, typeof(Transform));
            MeasureTransformB = (Transform)EditorGUILayout.ObjectField ("Measured B:",MeasureTransformB, typeof(Transform));
            MeasureTransformC = (Transform)EditorGUILayout.ObjectField (new GUIContent("Measured C:", "C can be null, then world space"),MeasureTransformC, typeof(Transform));
            if (GUILayout.Button ("Measure object A relative position to Object B,in relative space of C")) {
                Vector3 posA = MeasureTransformA.transform.position - (MeasureTransformC != null ? MeasureTransformC.position : Vector3.zero);
                Vector3 posB = MeasureTransformB.transform.position - (MeasureTransformC != null ? MeasureTransformC.position : Vector3.zero);
                Debug.Log("PositionB - PositionA = " + (posB - posA).ToString());
            }
        }
        EditorGUILayout.EndToggleGroup ();
        #endregion

        #region copy animation events from one aniamtion asset to another animation asset
        copyAnimation = EditorGUILayout.BeginToggleGroup ("Copy animation event", copyAnimation);
        if (copyAnimation) {
            CopyFromClipA = (AnimationClip)EditorGUILayout.ObjectField (CopyFromClipA, typeof(AnimationClip));
            CopyFromClipB = (AnimationClip)EditorGUILayout.ObjectField (CopyFromClipB, typeof(AnimationClip));
            if (GUILayout.Button ("Copy animation event from A to B")) {
                EditorCommon.CopyAnimationEvents (CopyFromClipA, CopyFromClipB);
            }
        }
        EditorGUILayout.EndToggleGroup ();
        #endregion

        #region add animation event
        AddAnimationEvent = EditorGUILayout.BeginToggleGroup ("Add animation event", AddAnimationEvent);
        if (AddAnimationEvent) {
            if (Selection.activeGameObject != null) {
                int index = 0;
                string[] array = EditorCommon.GetAnimationNames (Selection.activeGameObject, AnimationNameToEdit, out index);
                if (index == -1) {
                    index = 0;
                }
                index = EditorGUILayout.Popup ("Animation:", index, array);

                AnimationNameToEdit = array [index];
                AnimationFunctionName = EditorGUILayout.TextField ("Function name:", AnimationFunctionName);
                EditorGUILayout.BeginHorizontal ();
                animationParameterType = (AnimationParameterType)EditorGUILayout.EnumPopup ("Evnet param:", animationParameterType);
                AnimationParam = EditorGUILayout.TextField ("Animation param:", AnimationParam);
                EditorGUILayout.EndHorizontal ();
                if (GUILayout.Button ("Add animation")) {
                    AnimationClip clip = Selection.activeGameObject.animation.GetClip (AnimationNameToEdit);
                    EditorCommon.AddAnimationEvent (clip, AnimationFunctionName, AnimationParam, animationParameterType);
                }
            }
        }
        EditorGUILayout.EndToggleGroup ();
        #endregion

        #region print playing animation
        string logStr_animation = "Playing animation:";
        if (GUILayout.Button ("Print selection active animation status")) {
            foreach (AnimationState ani in Selection.activeGameObject.animation) {
                bool isplaying = Selection.activeGameObject.animation.IsPlaying (ani.name);
                if (isplaying)
                    logStr_animation += ani.name + "; ";
            }
            Debug.Log (logStr_animation);
        }
        #endregion

        #region Copy ragdollJoint from one unit to another
        if (EnableCopyRagdollJointData = EditorGUILayout.BeginToggleGroup ("Copy ragdoll joint data", EnableCopyRagdollJointData)) {
            copyRagdollFrom = (Ragdoll)EditorGUILayout.ObjectField ("Copy ragdoll from:", copyRagdollFrom, typeof(Ragdoll));
            copyRagdollTo = (Ragdoll)EditorGUILayout.ObjectField ("Copy ragdoll to:", copyRagdollTo, typeof(Ragdoll));
            if (GUILayout.Button ("Copy ragdoll from-to")) {
                RagdollEditor.CopyRagdollData (copyRagdollFrom, copyRagdollTo);
            }
        }
        EditorGUILayout.EndToggleGroup ();
        #endregion

        #region print child transform path
        if (GUILayout.Button ("Print child path")) {
            string path = Util.GetChildPath (Selection.activeGameObject.transform.root, Selection.activeGameObject.transform);
            Transform s = Selection.activeGameObject.transform.root.Find (path);
            Debug.Log (s);
            Debug.Log (path);
        }
        #endregion

        #region copy ragdoll
        if (EnableCreateRagdollFromTemplate = EditorGUILayout.BeginToggleGroup ("Create ragdoll from template", EnableCreateRagdollFromTemplate)) {
            EditorGUILayout.BeginHorizontal ();
            ragdollTemplate = (GameObject)EditorGUILayout.ObjectField ("Ragdoll template:", ragdollTemplate, typeof(GameObject));
            newRagdollObject = (GameObject)EditorGUILayout.ObjectField ("New ragdoll:", newRagdollObject, typeof(GameObject));
            if (GUILayout.Button ("Create ragdoll from template")) {
                EditorCommon.CreateRagdollFromTemplate (ragdollTemplate, newRagdollObject);
            }
            EditorGUILayout.EndHorizontal ();
        }
        EditorGUILayout.EndToggleGroup ();
        #endregion

        #region edit level checkpoint
        if (EnableEditLevelCheckpoint = EditorGUILayout.BeginToggleGroup ("Edit level checkpoint", EnableEditLevelCheckpoint)) {
            string _level = "";
            string _checkpoint = "";
            bool hasCheckPoint = Persistence.GetLastCheckPoint (out _level, out _checkpoint);
            if (hasCheckPoint) {
                checkPointLevel = _level;
                checkPointName = _checkpoint;
                checkPointLevel = EditorGUILayout.TextField ("check point level", checkPointLevel);
                checkPointName = EditorGUILayout.TextField ("check point name", checkPointName);
                if (GUILayout.Button ("Delete checkpoint")) {
                    Persistence.ClearCheckPoint ();
                }
            } else {
                checkPointLevel = EditorGUILayout.TextField ("check point level", checkPointLevel);
                checkPointName = EditorGUILayout.TextField ("check point name", checkPointName);
                if (GUILayout.Button ("Save checkpoint")) {
                    Persistence.SaveCheckPoint (checkPointLevel, checkPointName);
                }
            }
        }
        EditorGUILayout.EndToggleGroup ();
        #endregion

        #region copy character pose by animation clip frame
        EnableCopyPoseByAnimationFrame = EditorGUILayout.BeginToggleGroup ("Copy pose by animation clip", EnableCopyPoseByAnimationFrame);
        if (EnableCopyPoseByAnimationFrame) {
            PoseSourceClip = (AnimationClip)EditorGUILayout.ObjectField ("Animation clip source:", PoseSourceClip, typeof(AnimationClip));
            PoseToCharacter = (GameObject)EditorGUILayout.ObjectField ("Pose to object:", PoseToCharacter, typeof(GameObject));
            if (PoseSourceClip != null && PoseToCharacter != null) {
                copyPoseOfTime = EditorGUILayout.FloatField ("Copy pose at time of the curve:", copyPoseOfTime);
                if (GUILayout.Button ("Copy pose at time")) {
                    AnimationClipCurveData[] curveDatas = AnimationUtility.GetAllCurves (PoseSourceClip, true);
                    string logMsg = "";
                    for (int i=curveDatas.Length-1; i>=0; i--) {
                        AnimationClipCurveData curveData = curveDatas[i];
        //						logMsg += string.Format("Path:" + curveData.path + " property:" + curveData.propertyName + " value:" + curveData.curve.Evaluate(copyPoseOfTime) + "\r\n");
                        EditorCommon.CopyCurveDataIntoTransform(PoseToCharacter.transform, curveData, copyPoseOfTime);
                    }
        //					Debug.Log(logMsg);
                }
            }
        }

        #endregion
    }