Exemplo n.º 1
0
    public Transform metgoragdoll(Vector3 varpvelocity = default(Vector3))
    {
        Transform transform = UnityEngine.Object.Instantiate <Transform>(this.vargamragdoll, base.transform.position, base.transform.rotation);

        if (!this.ignoreScale)
        {
            transform.localScale = base.transform.localScale;
        }
        this.metcopytransforms(base.transform, transform, varpvelocity * 1f);
        if (this.doCreepySkin && this.enemyHealth)
        {
            transform.gameObject.SendMessage("setSkin", this.enemyHealth.MySkin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            this.enemyHealth.MySkin.GetPropertyBlock(this.bloodPropertyBlock);
            transform.gameObject.SendMessage("setSkinDamageProperty", this.bloodPropertyBlock, SendMessageOptions.DontRequireReceiver);
            if (this.enemyHealth.Fire.Length > 0)
            {
                mutantTransferFire component = base.transform.parent.GetComponent <mutantTransferFire>();
                foreach (GameObject gameObject in this.enemyHealth.Fire)
                {
                    if (gameObject.activeSelf && component)
                    {
                        component.transferFireToTarget(gameObject, transform.gameObject);
                    }
                }
            }
            if (BoltNetwork.isServer)
            {
                BoltEntity component2 = base.transform.parent.GetComponent <BoltEntity>();
                if (component2)
                {
                    IMutantState         state = component2.GetState <IMutantState>();
                    CoopMutantDummyToken coopMutantDummyToken = new CoopMutantDummyToken();
                    coopMutantDummyToken.Scale       = base.transform.localScale;
                    coopMutantDummyToken.skinDamage1 = this.bloodPropertyBlock.GetFloat("_Damage1");
                    coopMutantDummyToken.skinDamage2 = this.bloodPropertyBlock.GetFloat("_Damage2");
                    coopMutantDummyToken.skinDamage3 = this.bloodPropertyBlock.GetFloat("_Damage3");
                    coopMutantDummyToken.skinDamage4 = this.bloodPropertyBlock.GetFloat("_Damage4");
                    coopMutantDummyToken.skinColor   = this.enemyHealth.MySkin.sharedMaterial.GetColor("_Color");
                    mutantTypeSetup component3 = base.transform.parent.GetComponent <mutantTypeSetup>();
                    if (component3)
                    {
                    }
                    BoltNetwork.Attach(transform.gameObject, coopMutantDummyToken);
                }
            }
        }
        if (this.animalHealth && this.animalHealth.mySkin)
        {
            this.animalHealth.mySkin.GetPropertyBlock(this.bloodPropertyBlock);
            float @float = this.bloodPropertyBlock.GetFloat("_Damage1");
            transform.gameObject.SendMessage("setSkinDamageProperty", this.bloodPropertyBlock, SendMessageOptions.DontRequireReceiver);
        }
        if (this.animalHealth && this.animalHealth.Fire)
        {
            mutantTransferFire component4;
            if (base.transform.parent)
            {
                component4 = base.transform.parent.GetComponent <mutantTransferFire>();
            }
            else
            {
                component4 = base.transform.GetComponent <mutantTransferFire>();
            }
            if (this.animalHealth.Fire.activeSelf && component4)
            {
                component4.transferFireToTarget(this.animalHealth.Fire, transform.gameObject);
            }
        }
        if (this.bat && this.burning)
        {
            transform.gameObject.SendMessage("enableFire", SendMessageOptions.DontRequireReceiver);
        }
        if (this.animal)
        {
            animalSpawnFunctions component5 = base.transform.root.GetComponent <animalSpawnFunctions>();
            if (component5)
            {
                transform.gameObject.SendMessage("setSkin", component5.meshRenderer.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            }
            if (this.ca && this.ca.isSnow)
            {
                transform.gameObject.SendMessage("setupSnowRabbitTypeTrigger", SendMessageOptions.DontRequireReceiver);
            }
        }
        if (this.bird)
        {
            if (this.burning)
            {
                transform.gameObject.SendMessage("enableFire", SendMessageOptions.DontRequireReceiver);
            }
            lb_Bird component6 = base.transform.GetComponent <lb_Bird>();
            transform.gameObject.SendMessage("setSkin", component6.skin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
        }
        if (this.fish)
        {
            transform.gameObject.SendMessage("doSkinSetup", this.fishScript.fishTypeInt, SendMessageOptions.DontRequireReceiver);
            transform.gameObject.SendMessage("setupFishType", this.fishScript.fishNatureGuideValue, SendMessageOptions.DontRequireReceiver);
        }
        if (this.alreadyBurnt)
        {
            transform.gameObject.SendMessage("enableBurntSkin", SendMessageOptions.DontRequireReceiver);
        }
        if (this.ast)
        {
            arrowStickToTarget component7 = transform.GetComponent <arrowStickToTarget>();
            if (component7)
            {
                int num = 0;
                foreach (KeyValuePair <Transform, int> keyValuePair in this.ast.stuckArrows)
                {
                    if (keyValuePair.Key)
                    {
                        component7.CreatureType(this.ast.IsAnimal, this.ast.IsBird, this.ast.IsFish);
                        int arrowType = 0;
                        if (num < this.ast.stuckArrowsTypeList.Count)
                        {
                            arrowType = this.ast.stuckArrowsTypeList[num];
                        }
                        component7.applyStuckArrowToDummy(keyValuePair.Key, keyValuePair.Key.localPosition, keyValuePair.Key.localRotation, keyValuePair.Value, arrowType);
                        num++;
                    }
                }
            }
        }
        this.burning      = false;
        this.alreadyBurnt = false;
        return(transform);
    }
Exemplo n.º 2
0
    public IEnumerator spawnDummy(getAnimatorParams.DummyParams p)
    {
        Quaternion angle = p.Angle;

        if (BoltNetwork.isClient)
        {
            yield break;
        }
        Vector3 bodyPosition    = base.transform.position;
        bool    useBodyPosition = false;

        if (this.setup && this.setup.ai && this.setup.ai.pale && !p.IsDummyLoad && this.health.trapGo)
        {
            trapTrigger componentInChildren = this.health.trapGo.GetComponentInChildren <trapTrigger>();
            if (componentInChildren)
            {
                componentInChildren.FixPalePosition(this.setup, false);
                bodyPosition   += -0.15f * Vector3.up;
                useBodyPosition = true;
            }
        }
        GameObject dummy = UnityEngine.Object.Instantiate <GameObject>(this.dummyMutant, bodyPosition, base.transform.rotation);

        dummy.transform.rotation = angle;
        if (p.IsDummyLoad || (this.animator.GetBool("trapBool") && this.animator.GetInteger("trapTypeInt1") == 2))
        {
            dummy.transform.localEulerAngles = new Vector3(0f, dummy.transform.localEulerAngles.y, 0f);
        }
        dummy.transform.localScale = this.mutantBase.localScale;
        dummy.SendMessage("setCalledFromDeath", SendMessageOptions.DontRequireReceiver);
        SkinnedMeshRenderer[] sk = dummy.GetComponentsInChildren <SkinnedMeshRenderer>();
        foreach (SkinnedMeshRenderer skinnedMeshRenderer in sk)
        {
            skinnedMeshRenderer.enabled = false;
        }
        Animator          dummyAnim = dummy.GetComponent <Animator>();
        AnimatorStateInfo state     = this.animator.GetCurrentAnimatorStateInfo(0);

        dummyAnim.CrossFade(state.nameHash, 0f, 0, state.normalizedTime);
        dummyAnim.CopyParamsFrom(this.animator);
        if (p.IsDummyLoad)
        {
            if (this.animator.GetInteger("trapTypeInt1") != 3)
            {
                dummyAnim.SetBoolReflected("trapBool", true);
                if (this.animator.GetInteger("trapTypeInt1") == 2)
                {
                    dummyAnim.SetBoolReflected("enterTrapBool", true);
                    dummyAnim.SetBoolReflected("deathBOOL", true);
                }
                else
                {
                    dummyAnim.SetTriggerReflected("deathTrigger");
                }
            }
        }
        this.dummyHips.rotation    = this.hips.rotation;
        this.dummyHips.position    = bodyPosition;
        dummy.transform.position   = bodyPosition;
        dummy.transform.localScale = this.mutantBase.localScale;
        if (this.setup.health.Fire.Length > 0)
        {
            mutantTransferFire component = base.transform.GetComponent <mutantTransferFire>();
            foreach (GameObject gameObject in this.setup.health.Fire)
            {
                if (gameObject.activeSelf)
                {
                    component.transferFireToTarget(gameObject, dummy);
                }
            }
        }
        if (p.IsDummyLoad || this.animator.GetBool("trapBool"))
        {
            if (this.animator.GetInteger("trapTypeInt1") == 2 && this.health.trapParent)
            {
                dummy.transform.parent = this.health.trapParent.transform;
                dummy.SendMessageUpwards("setTrapDummy", dummy);
                CoopMutantDummy componentInChildren2 = dummy.GetComponentInChildren <CoopMutantDummy>();
                if (componentInChildren2 && this.health.trapGo)
                {
                    this.health.trapGo.SendMessage("SetNooseRope", componentInChildren2, SendMessageOptions.DontRequireReceiver);
                }
            }
            if ((p.IsDummyLoad || this.animator.GetInteger("trapTypeInt1") == 0) && this.health.trapGo)
            {
                this.health.trapGo.SendMessage("addTrappedMutant", new object[]
                {
                    dummy,
                    this.setup
                }, SendMessageOptions.DontRequireReceiver);
                dummy.SendMessage("setTrapGo", this.health.trapGo, SendMessageOptions.DontRequireReceiver);
            }
        }
        string TYPE   = string.Empty;
        bool   skinny = false;

        dummy.SendMessage("invokePickupSpawn", SendMessageOptions.DontRequireReceiver);
        if (this.setup.ai.femaleSkinny)
        {
            skinny = true;
            dummy.SendMessage(TYPE = "setFemaleSkinny", base.transform);
        }
        if (this.setup.ai.maleSkinny)
        {
            skinny = true;
            if (this.setup.ai.pale)
            {
                dummy.SendMessage(TYPE = "enableMaleSkinnyPaleProps");
                dummy.SendMessage(TYPE = "setMaleSkinnyPale", base.transform);
                if (this.setup.ai.skinned)
                {
                    dummy.SendMessage(TYPE = "setSkinnedMutant", this.setup.ai.skinned);
                }
            }
            else
            {
                dummy.SendMessage(TYPE = "enableMaleSkinnyProps");
                dummy.SendMessage(TYPE = "setMaleSkinny", base.transform);
            }
        }
        if (this.setup.ai.pale && !this.setup.ai.maleSkinny)
        {
            dummy.SendMessage(TYPE = "enablePaleProps");
            dummy.SendMessage(TYPE = "setPaleMale");
            if (this.setup.ai.skinned)
            {
                dummy.SendMessage(TYPE = "setSkinnedMutant", this.setup.ai.skinned);
            }
        }
        if (this.setup.ai.leader && !this.setup.ai.maleSkinny && !this.setup.ai.pale && !this.setup.ai.female)
        {
            dummy.SendMessage(TYPE = "setRegularMale", this.setup.propManager ? this.setup.propManager.regularMaleDice : 0);
            dummy.SendMessage(TYPE = "enableLeaderProps", this.setup.propManager ? this.setup.propManager.LeaderDice : 0);
            if (this.setup.ai.painted)
            {
                dummy.SendMessage(TYPE = "setPaintedLeader");
            }
            dummy.SendMessage(TYPE = "setRegularMaleLeader");
        }
        if (this.setup.ai.fireman)
        {
            if (this.setup.ai.fireman_dynamite)
            {
                dummy.SendMessage(TYPE = "setDynamiteMan");
            }
            dummy.SendMessage(TYPE = "enableFiremanProps");
            dummy.SendMessage(TYPE = "setRegularMaleFireman");
        }
        if (this.setup.ai.female && !this.setup.ai.femaleSkinny)
        {
            if (this.setup.ai.painted)
            {
                dummy.SendMessage(TYPE = "setFemalePainted", this.setup.bodyVariation ? this.setup.bodyVariation.femaleDice : 0);
            }
            else
            {
                dummy.SendMessage(TYPE = "setFemaleRegular", this.setup.bodyVariation ? this.setup.bodyVariation.femaleDice : 0);
            }
            if (this.bodyVar && this.bodyVar.Hair && this.bodyVar.Hair.activeSelf)
            {
                dummy.SendMessage(TYPE = "setFemaleHair");
            }
            if (this.bodyVar && this.bodyVar.Clothing && this.bodyVar.Clothing.activeSelf)
            {
                dummy.SendMessage(TYPE = "setFemaleClothes");
            }
            if (this.bodyVar && this.bodyVar.FireDice == 2)
            {
                dummy.SendMessage(TYPE = "setFemaleFire");
            }
        }
        if (this.setup.ai.male && !this.setup.ai.maleSkinny && !this.setup.ai.pale && !this.setup.ai.fireman && !this.setup.ai.leader)
        {
            if (this.setup.ai.painted)
            {
                dummy.SendMessage(TYPE = "setPaintedMale", this.setup.propManager ? this.setup.propManager.regularMaleDice : 0);
            }
            else
            {
                dummy.SendMessage(TYPE = "setRegularMale", this.setup.propManager ? this.setup.propManager.regularMaleDice : 0);
            }
        }
        if (this.setup.health.alreadyBurnt)
        {
            dummy.SendMessage("setBurntSkin", SendMessageOptions.DontRequireReceiver);
        }
        dummy.SendMessage("setPoisoned", this.health.poisoned, SendMessageOptions.DontRequireReceiver);
        if (this.setup.arrowSticker)
        {
            arrowStickToTarget componentInChildren3 = dummy.GetComponentInChildren <arrowStickToTarget>();
            foreach (KeyValuePair <Transform, int> keyValuePair in this.setup.arrowSticker.stuckArrows)
            {
                if (keyValuePair.Key)
                {
                    componentInChildren3.applyStuckArrowToDummy(keyValuePair.Key, keyValuePair.Key.localPosition, keyValuePair.Key.localRotation, keyValuePair.Value);
                }
            }
        }
        this.setup.health.MySkin.GetPropertyBlock(this.bloodPropertyBlock);
        dummy.SendMessage("setSkinDamageProperty", this.bloodPropertyBlock, SendMessageOptions.DontRequireReceiver);
        dummy.SendMessage("setSkinMaterialProperties", this.health.MySkin.material, SendMessageOptions.DontRequireReceiver);
        if (BoltNetwork.isServer)
        {
            CoopMutantDummyToken coopMutantDummyToken = new CoopMutantDummyToken();
            coopMutantDummyToken.Skinny         = skinny;
            coopMutantDummyToken.HipPosition    = bodyPosition;
            coopMutantDummyToken.HipRotation    = this.hips.rotation;
            coopMutantDummyToken.OriginalMutant = base.GetComponent <BoltEntity>();
            coopMutantDummyToken.Scale          = this.mutantBase.localScale;
            coopMutantDummyToken.skinDamage1    = this.bloodPropertyBlock.GetFloat("_Damage1");
            coopMutantDummyToken.skinDamage2    = this.bloodPropertyBlock.GetFloat("_Damage2");
            coopMutantDummyToken.skinDamage3    = this.bloodPropertyBlock.GetFloat("_Damage3");
            coopMutantDummyToken.skinDamage4    = this.bloodPropertyBlock.GetFloat("_Damage4");
            if (p.IsDummyLoad)
            {
                foreach (SkinnedMeshRenderer skinnedMeshRenderer2 in sk)
                {
                    skinnedMeshRenderer2.enabled = true;
                }
                CoopMutantMaterialSync component2 = dummy.GetComponent <CoopMutantMaterialSync>();
                component2.ForceStart();
                coopMutantDummyToken.MaterialIndex = component2.GetMaterialIndex();
                CoopMutantPropSync component3 = dummy.GetComponent <CoopMutantPropSync>();
                coopMutantDummyToken.Props = component3.GetPropMask();
            }
            else
            {
                IMutantState state2 = base.GetComponent <BoltEntity>().GetState <IMutantState>();
                coopMutantDummyToken.MaterialIndex = state2.MainMaterialIndex;
                coopMutantDummyToken.Props         = state2.prop_mask;
            }
            if (this.health.poisoned)
            {
                coopMutantDummyToken.skinColor = new Color(0.670588255f, 0.796078444f, 0.5529412f, 1f);
            }
            else if (this.setup.ai.pale && !this.setup.ai.skinned)
            {
                coopMutantDummyToken.skinColor = new Color(0.8039216f, 0.870588243f, 0.9137255f, 1f);
            }
            else
            {
                coopMutantDummyToken.skinColor = new Color(0.698039234f, 0.698039234f, 0.698039234f, 1f);
            }
            BoltNetwork.Attach(dummy, coopMutantDummyToken);
        }
        if (BoltNetwork.isServer)
        {
            IMutantFemaleDummyState mutantFemaleDummyState;
            if (dummy.GetComponent <BoltEntity>().TryFindState <IMutantFemaleDummyState>(out mutantFemaleDummyState))
            {
                mutantFemaleDummyState.Type          = TYPE;
                mutantFemaleDummyState.CrossFadeHash = state.nameHash;
                mutantFemaleDummyState.CrossFadeTime = state.normalizedTime;
            }
            IMutantMaleDummyState mutantMaleDummyState;
            if (dummy.GetComponent <BoltEntity>().TryFindState <IMutantMaleDummyState>(out mutantMaleDummyState))
            {
                mutantMaleDummyState.Type          = TYPE;
                mutantMaleDummyState.CrossFadeHash = state.nameHash;
                mutantMaleDummyState.CrossFadeTime = state.normalizedTime;
            }
        }
        List <Quaternion> jointRotations = new List <Quaternion>();

        for (int l = 0; l < this.mrs.jointsToSync.Length; l++)
        {
            jointRotations.Add(this.mrs.jointsToSync[l].localRotation);
        }
        if (!p.IsDummyLoad && !this.animator.GetBool("trapBool"))
        {
            dummy.SendMessage("syncRagDollJoints", jointRotations, SendMessageOptions.DontRequireReceiver);
        }
        yield return(new WaitForFixedUpdate());

        yield return(new WaitForFixedUpdate());

        yield return(new WaitForFixedUpdate());

        yield return(new WaitForFixedUpdate());

        yield return(new WaitForFixedUpdate());

        dummy.transform.localScale = this.mutantBase.localScale;
        dummy.transform.position   = ((!useBodyPosition) ? this.DeadPosition : bodyPosition);
        if (this.animator.GetBool("trapBool") && this.animator.GetInteger("trapTypeInt1") == 2)
        {
            this.setup.rootTr.parent = null;
        }
        foreach (SkinnedMeshRenderer skinnedMeshRenderer3 in sk)
        {
            skinnedMeshRenderer3.enabled = true;
        }
        if (PoolManager.Pools["enemies"].IsSpawned(base.transform))
        {
            PoolManager.Pools["enemies"].Despawn(base.transform);
        }
        else if (BoltNetwork.isServer)
        {
            dummy.GetComponent <BoltEntity>().DestroyDelayed(0.1f);
        }
        else
        {
            UnityEngine.Object.Destroy(base.transform.gameObject);
        }
        yield return(null);

        yield break;
    }