Пример #1
0
    public void Deconstruct()
    {
        foreach (GhostStep ghostStep in this.m_Steps)
        {
            foreach (GhostSlot ghostSlot in ghostStep.m_Slots)
            {
                ghostSlot.Deconstruct();
            }
        }
        GameObject         gameObject         = new GameObject();
        OneShotSoundObject oneShotSoundObject = gameObject.AddComponent <OneShotSoundObject>();

        gameObject.name = "OneShotSoundObject from Construction ghost";
        oneShotSoundObject.m_SoundNameWithPath           = this.m_DeconsructSounds[UnityEngine.Random.Range(0, this.m_DeconsructSounds.Count)];
        oneShotSoundObject.gameObject.transform.position = base.transform.position;
        UnityEngine.Object.Destroy(base.gameObject);
    }
Пример #2
0
    private void DestroyMe()
    {
        GameObject        prefab    = GreenHellGame.Instance.GetPrefab(this.m_Info.m_ID.ToString() + "Ghost");
        ConstructionGhost component = prefab.GetComponent <ConstructionGhost>();

        foreach (GhostStep ghostStep in component.m_Steps)
        {
            foreach (GhostSlot ghostSlot in ghostStep.m_Slots)
            {
                if (UnityEngine.Random.Range(0f, 1f) < 0.5f)
                {
                    ItemsManager.Get().CreateItem((ItemID)Enum.Parse(typeof(ItemID), ghostSlot.m_ItemName), true, base.transform.TransformPoint(ghostSlot.transform.localPosition), Quaternion.identity);
                }
            }
        }
        GameObject         gameObject         = new GameObject();
        OneShotSoundObject oneShotSoundObject = gameObject.AddComponent <OneShotSoundObject>();

        gameObject.name = "OneShotSoundObject from Construction";
        oneShotSoundObject.m_SoundNameWithPath           = this.m_DestroySounds[UnityEngine.Random.Range(0, this.m_DestroySounds.Count)];
        oneShotSoundObject.gameObject.transform.position = base.transform.position;
        UnityEngine.Object.Destroy(base.gameObject);
    }
Пример #3
0
    public virtual void DestroyMe(bool check_connected = true)
    {
        if (this.m_Destroying)
        {
            return;
        }
        foreach (Construction construction in Construction.s_AllConstructions)
        {
            if (!(construction == this) && construction != null)
            {
                construction.OnOtherConstructionDestroyed(this);
            }
        }
        this.ResolveSlots();
        if (!Replicator.IsAnyObjectBeingDeserialized())
        {
            this.ReplRequestOwnership(false);
        }
        FoodProcessor component = base.gameObject.GetComponent <FoodProcessor>();

        if (component)
        {
            component.OnDestroyConstruction();
        }
        this.m_Destroying = true;
        GameObject prefab = GreenHellGame.Instance.GetPrefab(this.m_Info.m_ID.ToString() + "Ghost");

        if (prefab && this.ReplIsOwner())
        {
            foreach (GhostStep ghostStep in prefab.GetComponent <ConstructionGhost>().m_Steps)
            {
                foreach (GhostSlot ghostSlot in ghostStep.m_Slots)
                {
                    if (!ghostSlot.m_ItemName.ToLower().Contains("mud") && UnityEngine.Random.Range(0f, 1f) < 0.5f)
                    {
                        Vector3 position = (this.m_Info.m_ID == ItemID.Campfire && ghostSlot.gameObject.GetComponent <BoxCollider>()) ? ghostSlot.gameObject.GetComponent <BoxCollider>().center : ghostSlot.transform.localPosition;
                        ItemsManager.Get().CreateItem((ItemID)Enum.Parse(typeof(ItemID), ghostSlot.m_ItemName), true, base.transform.TransformPoint(position), Quaternion.identity);
                    }
                }
            }
        }
        foreach (ConstructionSlot constructionSlot in this.m_ConstructionSlots)
        {
            if (constructionSlot.m_Construction && constructionSlot.m_DestroyWithSnapParent && constructionSlot.m_MatchingItemIDs.Contains(constructionSlot.m_Construction.GetInfoID()))
            {
                constructionSlot.m_Construction.DestroyMe(true);
            }
        }
        if (this.m_DestroyWithFrame && check_connected)
        {
            foreach (Construction construction2 in this.m_ConnectedConstructions)
            {
                ConstructionSlot[] constructionSlots = construction2.m_ConstructionSlots;
                for (int i = 0; i < constructionSlots.Length; i++)
                {
                    if (constructionSlots[i].m_Construction == this)
                    {
                        construction2.DestroyMe(false);
                        break;
                    }
                }
            }
        }
        if (this.m_DestroyWithChilds)
        {
            foreach (ConstructionSlot constructionSlot2 in this.m_ConstructionSlots)
            {
                if (constructionSlot2.m_Construction)
                {
                    constructionSlot2.m_Construction.DestroyMe(false);
                }
            }
        }
        if (this.m_DestroySounds.Count > 0)
        {
            GameObject         gameObject         = new GameObject();
            OneShotSoundObject oneShotSoundObject = gameObject.AddComponent <OneShotSoundObject>();
            gameObject.name = "OneShotSoundObject from Construction";
            oneShotSoundObject.m_SoundNameWithPath           = this.m_DestroySounds[UnityEngine.Random.Range(0, this.m_DestroySounds.Count)];
            oneShotSoundObject.gameObject.transform.position = base.transform.position;
        }
        ConstructionGhostManager.Get().OnDestoryConstruction(this);
        ItemsManager.Get().m_WasConstructionDestroyed = true;
        this.OnDestroyConstruction();
        if (!Replicator.IsAnyObjectBeingDeserialized())
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
    }