Exemplo n.º 1
0
    internal override void OnParentRemoved()
    {
        Rigidbody component = (Rigidbody)((Component)this).GetComponent <Rigidbody>();

        if (Object.op_Equality((Object)component, (Object)null))
        {
            base.OnParentRemoved();
        }
        else
        {
            Vector3    vector3  = ((Component)this).get_transform().get_position();
            Quaternion rotation = ((Component)this).get_transform().get_rotation();
            this.SetParent((BaseEntity)null, false, false);
            RaycastHit raycastHit;
            if (Physics.Raycast(Vector3.op_Addition(vector3, Vector3.op_Multiply(Vector3.get_up(), 2f)), Vector3.get_down(), ref raycastHit, 2f, 27328512) && vector3.y < ((RaycastHit) ref raycastHit).get_point().y)
            {
                vector3 = Vector3.op_Addition(vector3, Vector3.op_Multiply(Vector3.get_up(), 1.5f));
            }
            ((Component)this).get_transform().set_position(vector3);
            ((Component)this).get_transform().set_rotation(rotation);
            Physics.ApplyDropped(component);
            component.set_isKinematic(false);
            component.set_useGravity(true);
            component.WakeUp();
            if ((double)this.GetDespawnDuration() >= double.PositiveInfinity)
            {
                return;
            }
            this.Invoke(new Action(this.IdleDestroy), this.GetDespawnDuration());
        }
    }
Exemplo n.º 2
0
    private Rigidbody SetupRigidBody()
    {
        if (this.isServer)
        {
            GameObject prefab = this.gameManager.FindPrefab(this.prefabRagdoll.resourcePath);
            if (Object.op_Equality((Object)prefab, (Object)null))
            {
                return((Rigidbody)null);
            }
            Ragdoll component1 = (Ragdoll)prefab.GetComponent <Ragdoll>();
            if (Object.op_Equality((Object)component1, (Object)null))
            {
                return((Rigidbody)null);
            }
            if (Object.op_Equality((Object)component1.primaryBody, (Object)null))
            {
                Debug.LogError((object)("[BaseCorpse] ragdoll.primaryBody isn't set!" + ((Object)((Component)component1).get_gameObject()).get_name()));
                return((Rigidbody)null);
            }
            BoxCollider component2 = (BoxCollider)((Component)component1.primaryBody).GetComponent <BoxCollider>();
            if (Object.op_Equality((Object)component2, (Object)null))
            {
                Debug.LogError((object)"Ragdoll has unsupported primary collider (make it supported) ", (Object)component1);
                return((Rigidbody)null);
            }
            M0 m0 = ((Component)this).get_gameObject().AddComponent <BoxCollider>();
            ((BoxCollider)m0).set_size(Vector3.op_Multiply(component2.get_size(), 2f));
            ((BoxCollider)m0).set_center(component2.get_center());
            ((Collider)m0).set_sharedMaterial(((Collider)component2).get_sharedMaterial());
        }
        Rigidbody rigidBody = (Rigidbody)((Component)this).get_gameObject().GetComponent <Rigidbody>();

        if (Object.op_Equality((Object)rigidBody, (Object)null))
        {
            rigidBody = (Rigidbody)((Component)this).get_gameObject().AddComponent <Rigidbody>();
        }
        rigidBody.set_mass(10f);
        rigidBody.set_useGravity(true);
        rigidBody.set_drag(0.5f);
        rigidBody.set_collisionDetectionMode((CollisionDetectionMode)0);
        if (this.isServer)
        {
            Buoyancy component = (Buoyancy)((Component)this).GetComponent <Buoyancy>();
            if (Object.op_Inequality((Object)component, (Object)null))
            {
                component.rigidBody = rigidBody;
            }
            Physics.ApplyDropped(rigidBody);
            Vector3    vector3 = Vector3Ex.Range(-1f, 1f);
            ref __Null local   = ref vector3.y;
Exemplo n.º 3
0
    public override void PostInitShared()
    {
        base.PostInitShared();
        GameObject go = this.item == null || !this.item.info.worldModelPrefab.isValid ? (GameObject)Object.Instantiate <GameObject>((M0)this.itemModel) : this.item.info.worldModelPrefab.Instantiate((Transform)null);

        go.get_transform().SetParent(((Component)this).get_transform(), false);
        go.get_transform().set_localPosition(Vector3.get_zero());
        go.get_transform().set_localRotation(Quaternion.get_identity());
        go.SetLayerRecursive(((Component)this).get_gameObject().get_layer());
        Collider component1 = (Collider)go.GetComponent <Collider>();

        if (Object.op_Implicit((Object)component1))
        {
            component1.set_enabled(false);
            component1.set_enabled(true);
        }
        if (this.isServer)
        {
            WorldModel component2 = (WorldModel)go.GetComponent <WorldModel>();
            float      num1       = Object.op_Implicit((Object)component2) ? component2.mass : 1f;
            float      num2       = 0.1f;
            float      num3       = 0.1f;
            M0         m0         = ((Component)this).get_gameObject().AddComponent <Rigidbody>();
            ((Rigidbody)m0).set_mass(num1);
            ((Rigidbody)m0).set_drag(num2);
            ((Rigidbody)m0).set_angularDrag(num3);
            ((Rigidbody)m0).set_interpolation((RigidbodyInterpolation)0);
            Physics.ApplyDropped((Rigidbody)m0);
            foreach (Renderer componentsInChild in (Renderer[])go.GetComponentsInChildren <Renderer>(true))
            {
                componentsInChild.set_enabled(false);
            }
        }
        if (this.item != null)
        {
            PhysicsEffects component2 = (PhysicsEffects)((Component)this).get_gameObject().GetComponent <PhysicsEffects>();
            if (Object.op_Inequality((Object)component2, (Object)null))
            {
                component2.entity = (BaseEntity)this;
                if (Object.op_Inequality((Object)this.item.info.physImpactSoundDef, (Object)null))
                {
                    component2.physImpactSoundDef = this.item.info.physImpactSoundDef;
                }
            }
        }
        go.SetActive(true);
    }