private void Start()
 {
     if (!BoltNetwork.isClient || this._replaceIfClient)
     {
         Vector3    position;
         Quaternion rotation;
         if (this._newPrefabPositionTarget)
         {
             position = this._newPrefabPositionTarget.position;
             rotation = this._newPrefabPositionTarget.rotation;
         }
         else
         {
             position = this._replaceTarget.transform.position;
             rotation = this._replaceTarget.transform.rotation;
         }
         Transform transform = (Transform)UnityEngine.Object.Instantiate(this._newPrefab, position, rotation);
         if (BoltNetwork.isServer && !this._doLocalOnlyCheck)
         {
             BoltNetwork.Attach(transform.gameObject);
         }
         coopDeadSharkCutHead component = base.transform.GetComponent <coopDeadSharkCutHead>();
         if (component)
         {
             component.syncRagDollForServer(transform.gameObject);
         }
         if (this._newPrefab2)
         {
             Transform transform2 = (Transform)UnityEngine.Object.Instantiate(this._newPrefab2, position, rotation);
             if (BoltNetwork.isServer && !this._doLocalOnlyCheck)
             {
                 BoltNetwork.Attach(transform.gameObject);
             }
             transform2.parent = this._replaceTarget.transform.parent;
         }
         transform.parent = this._replaceTarget.transform.parent;
         this._replaceTarget.transform.parent = null;
         if (!this._dontDisableReplaceTarget)
         {
             this._replaceTarget.SetActive(false);
         }
         UnityEngine.Object.Destroy(this._replaceTarget, this._destroyTime);
     }
     else if (this._destroyIfClient)
     {
         BoltEntity component2 = this._replaceTarget.GetComponent <BoltEntity>();
         if (!this._doLocalOnlyCheck || !component2 || !component2.isAttached)
         {
             UnityEngine.Object.Destroy(this._replaceTarget, this._destroyTime);
         }
     }
 }
示例#2
0
 private void Start()
 {
     if (this._destroyIfNotEndGame && base.transform.position.y > -200f)
     {
         UnityEngine.Object.Destroy(base.gameObject);
         return;
     }
     if (!BoltNetwork.isClient || this._replaceIfClient)
     {
         if (!this._replaceTarget)
         {
             this._replaceTarget = base.gameObject;
         }
         Vector3    position;
         Quaternion rotation;
         if (this._newPrefabPositionTarget)
         {
             position = this._newPrefabPositionTarget.position;
             rotation = this._newPrefabPositionTarget.rotation;
         }
         else
         {
             position = this._replaceTarget.transform.position;
             rotation = this._replaceTarget.transform.rotation;
         }
         Transform transform = UnityEngine.Object.Instantiate <Transform>(this._newPrefab, position, rotation);
         if (BoltNetwork.isServer && !this._doLocalOnlyCheck)
         {
             BoltNetwork.Attach(transform.gameObject);
         }
         if (this._transfertChildrenPrefabs)
         {
             IEnumerator enumerator = this._replaceTarget.transform.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     object    obj        = enumerator.Current;
                     Transform transform2 = (Transform)obj;
                     if (transform2.GetComponent <PrefabIdentifier>())
                     {
                         transform2.parent = transform.transform;
                     }
                 }
             }
             finally
             {
                 IDisposable disposable;
                 if ((disposable = (enumerator as IDisposable)) != null)
                 {
                     disposable.Dispose();
                 }
             }
         }
         if (this._transferSkinProperties)
         {
             this.setupSkinProperties(transform);
         }
         coopDeadSharkCutHead component = base.transform.GetComponent <coopDeadSharkCutHead>();
         if (component)
         {
             component.syncRagDollForServer(transform.gameObject);
         }
         if (this._newPrefab2)
         {
             Transform transform3 = UnityEngine.Object.Instantiate <Transform>(this._newPrefab2, position, rotation);
             if (BoltNetwork.isServer && !this._doLocalOnlyCheck)
             {
                 BoltNetwork.Attach(transform3.gameObject);
             }
             if (!this._parentToWorld)
             {
                 transform3.parent = this._replaceTarget.transform.parent;
             }
         }
         if (!this._parentToWorld)
         {
             transform.parent = this._replaceTarget.transform.parent;
         }
         if (this._preserveScale)
         {
             transform.localScale = this._replaceTarget.transform.localScale;
         }
         BoltEntity component2 = this._replaceTarget.GetComponent <BoltEntity>();
         if (!BoltNetwork.isClient || !component2 || !component2.isAttached || component2.isOwner)
         {
             this._replaceTarget.transform.parent = null;
             if (!this._dontDisableReplaceTarget)
             {
                 this._replaceTarget.SetActive(false);
             }
             UnityEngine.Object.Destroy(this._replaceTarget, this._destroyTime);
         }
     }
     else if (this._destroyIfClient)
     {
         BoltEntity component3 = this._replaceTarget.GetComponent <BoltEntity>();
         if (!this._doLocalOnlyCheck || !component3 || !component3.isAttached)
         {
             UnityEngine.Object.Destroy(this._replaceTarget, this._destroyTime);
         }
     }
 }