Exemplo n.º 1
0
    public static void AttachAnimalToNetwork(AnimalSpawnZone zone, GameObject gameObject)
    {
        AnimalDespawner animalDespawner = gameObject.GetComponent <AnimalDespawner>();

        if (!animalDespawner)
        {
            animalDespawner = gameObject.AddComponent <AnimalDespawner>();
        }
        animalDespawner.SpawnedFromZone = zone;
        animalDespawner.DespawnRadius   = 70f;
        animalDespawner.UpdateRate      = 1f;
        if (BoltNetwork.isServer)
        {
            BoltEntity boltEntity = gameObject.AddComponent <BoltEntity>();
            BoltEntity component  = gameObject.GetComponent <CoopAnimalServer>().NetworkContainerPrefab.GetComponent <BoltEntity>();
            using (BoltEntitySettingsModifier boltEntitySettingsModifier = component.ModifySettings())
            {
                using (BoltEntitySettingsModifier boltEntitySettingsModifier2 = boltEntity.ModifySettings())
                {
                    boltEntitySettingsModifier2.clientPredicted          = boltEntitySettingsModifier.clientPredicted;
                    boltEntitySettingsModifier2.persistThroughSceneLoads = boltEntitySettingsModifier.persistThroughSceneLoads;
                    boltEntitySettingsModifier2.allowInstantiateOnClient = boltEntitySettingsModifier.allowInstantiateOnClient;
                    boltEntitySettingsModifier2.prefabId     = boltEntitySettingsModifier.prefabId;
                    boltEntitySettingsModifier2.updateRate   = boltEntitySettingsModifier.updateRate;
                    boltEntitySettingsModifier2.serializerId = boltEntitySettingsModifier.serializerId;
                }
            }
            BoltNetwork.Attach(gameObject);
        }
    }
Exemplo n.º 2
0
 private void OnProjectileThrown(GameObject projectileGO)
 {
     if (this._targetView.ActiveBonus == this._bonus)
     {
         GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this._prefab);
         gameObject.transform.parent        = projectileGO.transform;
         gameObject.transform.localPosition = this._position.localPosition;
         gameObject.transform.localRotation = this._position.localRotation;
         Rigidbody component = gameObject.GetComponent <Rigidbody>();
         if (component)
         {
             component.useGravity  = false;
             component.isKinematic = true;
         }
         if (!gameObject.GetComponent <destroyAfter>())
         {
             gameObject.AddComponent <destroyAfter>().destroyTime = 20f;
         }
         if (BoltNetwork.isRunning)
         {
             BoltEntity component2 = gameObject.GetComponent <BoltEntity>();
             if (component2 && !component2.isAttached)
             {
                 BoltNetwork.Attach(component2);
             }
         }
         this._targetView.ActiveBonus = (WeaponStatUpgrade.Types)(-1);
     }
 }
Exemplo n.º 3
0
 public override void Open_Perform()
 {
     if (!this.Interior.activeSelf)
     {
         this.Interior.SetActive(true);
         this.Lid.GetComponent <Animation>().Play();
         if (FMOD_StudioSystem.instance)
         {
             FMOD_StudioSystem.instance.PlayOneShot(this.OpenEvent, this.transform.position, null);
         }
         if (!BoltNetwork.isClient)
         {
             GameObject gameObject;
             if (Extensions.get_length(this.WorldItem) > 0)
             {
                 gameObject = (GameObject)UnityEngine.Object.Instantiate(this.WorldItem[UnityEngine.Random.Range(0, Extensions.get_length(this.WorldItem))], this.InsidePos.position, this.InsidePos.rotation);
             }
             if (BoltNetwork.isServer && Extensions.get_length(this.WorldItem) > 0)
             {
                 BoltNetwork.Attach(gameObject as GameObject);
             }
             if (Extensions.get_length(this.WorldItem) > 0)
             {
                 gameObject.transform.parent = this.InsidePos.transform;
             }
         }
         this.gameObject.SetActive(false);
     }
 }
Exemplo n.º 4
0
        public static BoltEntity AttachLocalPlayer(string name = null)
        {
            if (LocalPlayer.GameObject.GetComponent <BoltEntity>() != null && LocalPlayer.GameObject.GetComponent <BoltEntity>().isAttached)
            {
                return(LocalPlayer.GameObject.GetComponent <BoltEntity>());
            }

            Menu.Values.Self.Visible = true;

            LocalPlayer.GameObject.AddComponent <BoltPlayerSetup>();
            LocalPlayer.GameObject.AddComponent <BoltEntity>();
            using (var settingsModifier = LocalPlayer.GameObject.GetComponent <BoltEntity>().ModifySettings())
            {
                settingsModifier.prefabId                 = BoltPrefabs.player_net;
                settingsModifier.serializerId             = StateSerializerTypeIds.IPlayerState;
                settingsModifier.allowInstantiateOnClient = true;
                settingsModifier.persistThroughSceneLoads = true;
                settingsModifier.clientPredicted          = false;
                settingsModifier.updateRate               = 1;
            }
            var attachedEntity = BoltNetwork.Attach(LocalPlayer.GameObject).GetComponent <BoltEntity>();

            attachedEntity.GetState <IPlayerState>().name = !string.IsNullOrEmpty(name) ? name : GriefClientPro.PlayerName;
            LocalPlayer.Entity = attachedEntity;
            BoltNetwork.SetCanReceiveEntities(true);

            return(attachedEntity);
        }
Exemplo n.º 5
0
    private void die()
    {
        if (!this.controller)
        {
            return;
        }
        this.sendDisablePerchTarget();
        if (this.controller.initIdealBirds > 0)
        {
            this.controller.initIdealBirds--;
        }
        if (this.controller.initMaxBirds > 0)
        {
            this.controller.initMaxBirds--;
        }
        base.StopAllCoroutines();
        FMODCommon.PlayOneshot(this.DieEvent, base.transform);
        Transform transform = this.ragDoll.metgoragdoll(default(Vector3));

        if (BoltNetwork.isRunning && BoltNetwork.isServer)
        {
            BoltNetwork.Attach(transform.gameObject);
        }
        this.controller.Unspawn(base.gameObject);
    }
Exemplo n.º 6
0
    private void DieFire()
    {
        if (!this.controller)
        {
            return;
        }
        this.sendDisablePerchTarget();
        if (this.controller.initIdealBirds > 0)
        {
            this.controller.initIdealBirds--;
        }
        if (this.controller.initMaxBirds > 0)
        {
            this.controller.initMaxBirds--;
        }
        base.StopAllCoroutines();
        FMODCommon.PlayOneshot(this.DieEvent, base.transform);
        this.ragDoll.burning = true;
        Transform transform = this.ragDoll.metgoragdoll(default(Vector3));

        if (BoltNetwork.isRunning && BoltNetwork.isServer)
        {
            CoopRagdollToken coopRagdollToken = new CoopRagdollToken();
            coopRagdollToken.onFireApplied = true;
            BoltNetwork.Attach(transform.gameObject, coopRagdollToken);
        }
        this.controller.Unspawn(base.gameObject);
    }
Exemplo n.º 7
0
 void OnEnable()
 {
     if (!BoltEntityExtensions.IsAttached(gameObject.GetComponent <BoltEntity>()))
     {
         BoltNetwork.Attach(gameObject);
     }
 }
Exemplo n.º 8
0
 private void Start()
 {
     if (BoltNetwork.isRunning && this.entity && !this.entity.isAttached)
     {
         BoltNetwork.Attach(this.entity);
     }
 }
Exemplo n.º 9
0
 private void throwRocks()
 {
     if (BoltNetwork.isClient)
     {
         return;
     }
     for (int i = 0; i < this.ammoCount; i++)
     {
         Vector3 position = this.releasePos.position + this.releasePos.up * 2f + (this.releasePos.forward * UnityEngine.Random.Range(-0.6f, 0.6f) + this.releasePos.right * UnityEngine.Random.Range(-0.6f, 0.6f));
         MultiThrowerProjectile multiThrowerProjectile = UnityEngine.Object.Instantiate <MultiThrowerProjectile>(this.projectilePrefab, position, Quaternion.identity);
         Rigidbody rigidbody = multiThrowerProjectile._rigidbody;
         Vector2   vector    = this.randomCircle2(2.2f);
         Vector3   target    = new Vector3(this.landTarget.x + vector.x, this.landTarget.y, this.landTarget.z + vector.y);
         Vector3   a         = this.calculateBestThrowSpeed(this.releasePos.position, target, UnityEngine.Random.Range(2.4f, 2.6f));
         rigidbody.AddForce(a * (0.016666f / Time.fixedDeltaTime), ForceMode.VelocityChange);
         rigidbody.AddTorque(base.transform.right * UnityEngine.Random.Range(20f, 35f), ForceMode.VelocityChange);
         multiThrowerProjectile.InitProjectile(this.itemHolder.AmmoLoaded[i], (this.rockAmmo[i].transform.childCount <= 0) ? null : this.rockAmmo[i].transform.GetChild(0));
         if (BoltNetwork.isRunning)
         {
             BoltEntity component = multiThrowerProjectile.GetComponent <BoltEntity>();
             if (component)
             {
                 BoltNetwork.Attach(multiThrowerProjectile.gameObject);
                 IMultiThrowerProjectileState state = component.GetState <IMultiThrowerProjectileState>();
                 state.Thrower = this.entity;
                 state.AmmoId  = i + 1;
             }
         }
     }
     foreach (GameObject gameObject in this.rockAmmo)
     {
         gameObject.SetActive(false);
     }
 }
Exemplo n.º 10
0
 public static void AttachTrees()
 {
     if (BoltNetwork.isServer && CoopTreeGrid.AttachQueue != null)
     {
         int count = CoopTreeGrid.AttachQueue.Count;
         for (int i = 0; i < 100; i++)
         {
             if (CoopTreeGrid.AttachQueue.Count <= 0)
             {
                 break;
             }
             BoltEntity boltEntity = CoopTreeGrid.AttachQueue.Dequeue();
             if (!boltEntity.IsAttached())
             {
                 BoltNetwork.Attach(boltEntity.gameObject);
                 boltEntity.Freeze(true);
             }
             else
             {
                 i--;
             }
         }
         if (count > 0 && CoopTreeGrid.AttachQueue.Count == 0 && !CoopTreeGrid.AttachRoutineDone)
         {
             CoopTreeGrid.AttachRoutineDone = true;
             Scene.ActiveMB.StartCoroutine(CoopTreeGrid.AttacheRoutine());
         }
     }
 }
Exemplo n.º 11
0
    public void goRagdoll()
    {
        if (this.ragdollSpawned)
        {
            return;
        }
        this.ragdollSpawned = true;
        Transform transform = this.ragdoll.metgoragdoll(default(Vector3));

        if (PoolManager.Pools["creatures"].IsSpawned(this.rootTr))
        {
            this.spawnFunctions.despawn();
        }
        else
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
        CoopMutantDummyToken  coopMutantDummyToken  = new CoopMutantDummyToken();
        MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();

        this.skinRenderer.GetPropertyBlock(materialPropertyBlock);
        coopMutantDummyToken.skinDamage1 = materialPropertyBlock.GetFloat("_Damage1");
        coopMutantDummyToken.skinDamage2 = materialPropertyBlock.GetFloat("_Damage2");
        coopMutantDummyToken.skinDamage3 = materialPropertyBlock.GetFloat("_Damage3");
        coopMutantDummyToken.skinDamage4 = materialPropertyBlock.GetFloat("_Damage4");
        if (BoltNetwork.isRunning)
        {
            BoltNetwork.Attach(transform.gameObject, coopMutantDummyToken);
        }
    }
Exemplo n.º 12
0
    public static BoltEntity AttachLocalPlayer(GameObject go, string name, bool attachToRespawn)
    {
        if (go.GetComponent <BoltEntity>() && go.GetComponent <BoltEntity>().isAttached)
        {
            return(go.GetComponent <BoltEntity>());
        }
        go.AddComponent <BoltPlayerSetup>();
        go.AddComponent <BoltEntity>();
        using (BoltEntitySettingsModifier boltEntitySettingsModifier = go.GetComponent <BoltEntity>().ModifySettings())
        {
            boltEntitySettingsModifier.prefabId                 = BoltPrefabs.player_net;
            boltEntitySettingsModifier.serializerId             = StateSerializerTypeIds.IPlayerState;
            boltEntitySettingsModifier.allowInstantiateOnClient = true;
            boltEntitySettingsModifier.persistThroughSceneLoads = true;
            boltEntitySettingsModifier.clientPredicted          = false;
            boltEntitySettingsModifier.updateRate               = 1;
        }
        BoltEntity component = BoltNetwork.Attach(go).GetComponent <BoltEntity>();

        component.GetState <IPlayerState>().name = ((!string.IsNullOrEmpty(name)) ? name : "UNKNOWN");
        LocalPlayer.Entity = component;
        LocalPlayer.State  = component.GetState <IPlayerState>();
        BoltNetwork.SetCanReceiveEntities(true);
        return(component);
    }
Exemplo n.º 13
0
 private bool OnPrefabLoaded(GameObject prefab)
 {
     if (this && this._loading)
     {
         this._loading = false;
         if (base.enabled && base.gameObject.activeSelf && prefab && base.gameObject.activeInHierarchy)
         {
             Vector3    position   = base.transform.position;
             Quaternion rotation   = base.transform.rotation;
             GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab, position, rotation);
             this._instance = gameObject;
             if (BoltNetwork.isServer && !this._doLocalOnlyCheck && gameObject.GetComponent <BoltEntity>())
             {
                 BoltNetwork.Attach(gameObject.gameObject);
             }
             gameObject.SendMessage("OnSpawned", SendMessageOptions.DontRequireReceiver);
             if (this._parent)
             {
                 gameObject.transform.parent = this._parent.transform.parent;
             }
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 14
0
        private void FakeDrop(List <int> outfit, Vector3 dropPos)
        {
            if (outfit == null)
            {
                return;
            }
            List <int> list = (from eachValue in outfit
                               where eachValue > 0
                               select eachValue).ToList <int>();

            if (list.SafeCount <int>() == 0)
            {
                return;
            }
            if (this._fakeDropPrefabSource == null)
            {
                return;
            }
            GameObject     gameObject          = UnityEngine.Object.Instantiate <GameObject>(this._fakeDropPrefabSource, dropPos, Quaternion.identity);
            ClothingPickup componentInChildren = gameObject.GetComponentInChildren <ClothingPickup>();

            componentInChildren._presetOutfitItemIds = list;
            gameObject.name = string.Format("{0}_fakeDrop_clothes_{1}", this._fakeDropPrefabSource.name, list.Join("_"));
            if (BoltNetwork.isRunning)
            {
                BoltEntity component = gameObject.GetComponent <BoltEntity>();
                BoltNetwork.Attach(component);
            }
            LocalPlayer.Sfx.PlayWhoosh();
        }
Exemplo n.º 15
0
 private void DisolveBurnt()
 {
     if (!BoltNetwork.isRunning || (base.entity.isAttached && base.entity.isOwner))
     {
         if (this.DissolvedPrefab)
         {
             GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.DissolvedPrefab, base.transform.position, base.transform.rotation);
             if (this._scaleDisolve)
             {
                 gameObject.transform.localScale.Scale(this._targetRenderer.transform.localScale);
             }
             if (BoltNetwork.isRunning && gameObject.GetComponent <BoltEntity>())
             {
                 BoltNetwork.Attach(gameObject);
             }
         }
         if (BoltNetwork.isRunning)
         {
             BoltNetwork.Destroy(base.gameObject);
         }
         else
         {
             UnityEngine.Object.Destroy(base.gameObject);
         }
     }
 }
Exemplo n.º 16
0
 private void Start()
 {
     if (BoltNetwork.isRunning && base.entity && !base.entity.isAttached)
     {
         BoltNetwork.Attach(base.entity);
     }
 }
Exemplo n.º 17
0
 private void fireProjectile()
 {
     if (LocalPlayer.Inventory.RemoveItem(this._ammoId, 1, false, true))
     {
         Vector3    position   = this._ammoSpawnPosGo.transform.position;
         Quaternion rotation   = this._ammoSpawnPosGo.transform.rotation;
         GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this._boltProjectile, position, rotation);
         Rigidbody  component  = gameObject.GetComponent <Rigidbody>();
         if (BoltNetwork.isRunning)
         {
             BoltEntity component2 = gameObject.GetComponent <BoltEntity>();
             if (component2)
             {
                 BoltNetwork.Attach(gameObject);
             }
         }
         PickUp componentInChildren = gameObject.GetComponentInChildren <PickUp>(true);
         if (componentInChildren)
         {
             SheenBillboard[] componentsInChildren = gameObject.GetComponentsInChildren <SheenBillboard>();
             foreach (SheenBillboard sheenBillboard in componentsInChildren)
             {
                 sheenBillboard.gameObject.SetActive(false);
             }
             componentInChildren.gameObject.SetActive(false);
             if (base.gameObject.activeInHierarchy)
             {
                 base.StartCoroutine(this.enablePickupTrigger(componentInChildren.gameObject));
             }
         }
         Vector3 up = gameObject.transform.up;
         component.AddForce(22000f * (0.016666f / Time.fixedDeltaTime) * up);
     }
 }
Exemplo n.º 18
0
 private void Start()
 {
     if (!this.SkipAttach && BoltNetwork.isRunning && this.entity && !this.entity.isAttached)
     {
         BoltNetwork.Attach(base.gameObject);
     }
     base.Invoke("Explode", (float)this.WaitTime);
 }
Exemplo n.º 19
0
        private IEnumerator DelayedPoolSpawnMP(string pool, Transform prefab, Vector3 pos, Quaternion rot)
        {
            yield return(null);

            Transform t = PoolManager.Pools[pool].Spawn(prefab, pos, rot);

            BoltNetwork.Attach(t.gameObject);
            yield break;
        }
Exemplo n.º 20
0
    public Transform metgoragdoll(Vector3 varpvelocity = default(Vector3))
    {
        Transform transform = UnityEngine.Object.Instantiate(this.vargamragdoll, base.transform.position, base.transform.rotation) as Transform;

        transform.localScale = base.transform.localScale;
        this.metcopytransforms(base.transform, transform, varpvelocity * 1f);
        if (this.doCreepySkin)
        {
            transform.gameObject.SendMessage("setSkin", this.health.MySkin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            this.health.MySkin.GetPropertyBlock(this.bloodPropertyBlock);
            transform.gameObject.SendMessage("setSkinDamageProperty", this.bloodPropertyBlock, SendMessageOptions.DontRequireReceiver);
            if (BoltNetwork.isServer)
            {
                IMutantState         state = base.transform.parent.GetComponent <BoltEntity>().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");
                mutantTypeSetup component = base.transform.parent.GetComponent <mutantTypeSetup>();
                if (component)
                {
                    coopMutantDummyToken.storedRagDollName = component.storedRagDollName;
                }
                BoltNetwork.Attach(transform.gameObject, coopMutantDummyToken);
            }
        }
        if (this.animal)
        {
            animalSpawnFunctions component2 = base.transform.root.GetComponent <animalSpawnFunctions>();
            if (component2)
            {
                transform.gameObject.SendMessage("setSkin", component2.meshRenderer.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            }
        }
        if (this.bird)
        {
            lb_Bird component3 = base.transform.GetComponent <lb_Bird>();
            transform.gameObject.SendMessage("setSkin", component3.skin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
        }
        if (this.fish)
        {
            transform.gameObject.SendMessage("doSkinSetup", this.fishScript.fishTypeInt, SendMessageOptions.DontRequireReceiver);
        }
        if (this.burning)
        {
            transform.gameObject.SendMessage("enableFire", SendMessageOptions.DontRequireReceiver);
        }
        if (this.alreadyBurnt)
        {
            transform.gameObject.SendMessage("enableBurntSkin", SendMessageOptions.DontRequireReceiver);
        }
        this.burning      = false;
        this.alreadyBurnt = false;
        return(transform);
    }
Exemplo n.º 21
0
    private IEnumerator DelayedOnEnable()
    {
        yield return(null);

        if (base.entity && !base.entity.isAttached)
        {
            BoltNetwork.Attach(base.entity);
        }
        yield break;
    }
Exemplo n.º 22
0
        private void SetupEntity()
        {
            var entity = GetComponent <BoltEntity>();

            if (BoltNetwork.IsServer && !entity.isAttached)
            {
                BoltNetwork.Attach(entity.gameObject);
                entity.TakeControl();
                Debug.Log("Setup scene entity : " + entity.name);
            }
        }
Exemplo n.º 23
0
        public void PlaceTrophy(int itemId)
        {
            Transform transform = UnityEngine.Object.Instantiate <Transform>(Prefabs.Instance.TrophyPrefabs.First((Prefabs.TrophyPrefab tp) => tp._itemId == itemId)._prefab, base.transform.parent.position, base.transform.parent.rotation);

            transform.parent = base.transform.parent.parent;
            if (BoltNetwork.isRunning)
            {
                BoltNetwork.Attach(transform.gameObject);
            }
            UnityEngine.Object.Destroy(base.transform.parent.gameObject);
        }
Exemplo n.º 24
0
 private void OnProjectileThrown(GameObject projectileGO)
 {
     if (this._targetView.ActiveBonus == this._bonus)
     {
         GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this._prefab);
         gameObject.transform.parent        = projectileGO.transform;
         gameObject.transform.localPosition = this._position.localPosition;
         gameObject.transform.localRotation = this._position.localRotation;
         Rigidbody component = gameObject.GetComponent <Rigidbody>();
         if (component)
         {
             component.useGravity  = false;
             component.isKinematic = true;
         }
         if (gameObject.GetComponent <Molotov>())
         {
             CapsuleCollider component2 = gameObject.GetComponent <CapsuleCollider>();
             BoxCollider     component3 = gameObject.GetComponent <BoxCollider>();
             if (component3)
             {
                 component3.enabled = false;
             }
             Collider component4 = gameObject.transform.parent.GetComponent <Collider>();
             if (component4)
             {
                 Physics.IgnoreCollision(component2, component4, true);
             }
             if (component2)
             {
                 component2.radius = 3f;
                 component2.center = new Vector3(component2.center.x, 0.4f, component2.center.z);
                 component2.height = 1f;
             }
             if (!gameObject.GetComponent <molotovSpearFollow>())
             {
                 gameObject.AddComponent <molotovSpearFollow>();
             }
         }
         if (!gameObject.GetComponent <destroyAfter>())
         {
             gameObject.AddComponent <destroyAfter>().destroyTime = 20f;
         }
         if (BoltNetwork.isRunning)
         {
             BoltEntity component5 = gameObject.GetComponent <BoltEntity>();
             if (component5 && !component5.isAttached)
             {
                 BoltNetwork.Attach(component5);
             }
         }
         this._targetView.ActiveBonus = (WeaponStatUpgrade.Types)(-1);
     }
 }
Exemplo n.º 25
0
 void OnEnable()
 {
     if (!BoltEntityExtensions.IsAttached(gameObject.GetComponent <BoltEntity>()))
     {
         BoltNetwork.Attach(gameObject);
     }
     foreach (Transform child in transform)
     {
         child.localScale = shadow_scale;
     }
     rising = true;
 }
Exemplo n.º 26
0
 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);
         }
     }
 }
Exemplo n.º 27
0
 private void CancelCook()
 {
     if (this.CurrentStatus == Cook.Status.Cooking && (!BoltNetwork.isRunning || !base.entity.isAttached || base.entity.isOwner))
     {
         Item      item      = ItemDatabase.ItemById(this._itemId);
         Transform transform = UnityEngine.Object.Instantiate <Transform>((BoltNetwork.isRunning && item._pickupPrefabMP) ? item._pickupPrefabMP : item._pickupPrefab, this._targetRenderer.transform.position, this._targetRenderer.transform.rotation);
         if (BoltNetwork.isRunning)
         {
             BoltNetwork.Attach(transform.gameObject);
         }
         UnityEngine.Object.Destroy(base.gameObject);
     }
 }
Exemplo n.º 28
0
 public override void fireProjectile()
 {
     if (LocalPlayer.Inventory.RemoveItem(_ammoItemId, 1, false, true))
     {
         Vector3    position = _ammoSpawnPos.transform.position;
         Quaternion rotation = _ammoSpawnPos.transform.rotation;
         if (ForestVR.Enabled)
         {
             position = _ammoSpawnPosVR.transform.position;
             rotation = _ammoSpawnPosVR.transform.rotation;
         }
         GameObject gameObject = Object.Instantiate(_Ammo, position, rotation);
         gameObject.transform.localScale *= ModdedPlayer.instance.ProjectileSizeRatio;
         Rigidbody component  = gameObject.GetComponent <Rigidbody>();
         rockSound component2 = gameObject.GetComponent <rockSound>();
         if ((bool)component2)
         {
             component2.slingShot = true;
         }
         if (BoltNetwork.isRunning)
         {
             BoltEntity component3 = gameObject.GetComponent <BoltEntity>();
             if ((bool)component3)
             {
                 BoltNetwork.Attach(gameObject);
             }
         }
         PickUp componentInChildren = gameObject.GetComponentInChildren <PickUp>();
         if ((bool)componentInChildren)
         {
             SheenBillboard[] componentsInChildren = gameObject.GetComponentsInChildren <SheenBillboard>();
             SheenBillboard[] array = componentsInChildren;
             foreach (SheenBillboard sheenBillboard in array)
             {
                 sheenBillboard.gameObject.SetActive(false);
             }
             componentInChildren.gameObject.SetActive(false);
             if (base.gameObject.activeInHierarchy)
             {
                 base.StartCoroutine(enablePickupTrigger(componentInChildren.gameObject));
             }
         }
         Vector3 forward = _ammoSpawnPos.transform.forward;
         if (ForestVR.Enabled)
         {
             forward = _ammoSpawnPosVR.transform.forward;
         }
         component.AddForce(4000f * ModdedPlayer.instance.ProjectileSpeedRatio * (0.016666f / Time.fixedDeltaTime) * forward);
     }
 }
Exemplo n.º 29
0
    private void OnDeserialized()
    {
        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(LocalPlayer.Create._blueprints.Find((Create.BuildingBlueprint bp) => bp._type == Create.BuildingTypes.FireStand)._builtPrefab);

        gameObject.transform.position = base.transform.parent.position;
        gameObject.transform.rotation = base.transform.parent.rotation;
        gameObject.transform.parent   = base.transform.parent.parent;
        if (BoltNetwork.isRunning)
        {
            BoltNetwork.Attach(gameObject);
        }
        base.transform.parent.parent = null;
        UnityEngine.Object.Destroy(base.transform.parent.gameObject);
    }
Exemplo n.º 30
0
        public void SpawnFromPoolMP(string pool, Transform prefab, Vector3 pos, Quaternion rot, bool spawnedFromTree = false)
        {
            Transform transform = PoolManager.Pools[pool].Spawn(prefab, pos, rot);

            transform.parent = null;
            if (spawnedFromTree)
            {
                transform.SendMessage("enableSpawnedfromTree", SendMessageOptions.DontRequireReceiver);
            }
            if (BoltNetwork.isRunning)
            {
                BoltNetwork.Attach(transform.gameObject);
            }
        }