Exemple #1
0
    public void DestroyThing(Thing rootThing, ThingDestruction destruction)
    {
        if (rootThing != null && rootThing.name != Universe.objectNameIfAlreadyDestroyed)
        {
            bool isPlacement       = rootThing.IsPlacement();
            bool isThrownOrEmitted = rootThing.isHeldAsHoldable || rootThing.isThrownOrEmitted;

            if (isPlacement || isThrownOrEmitted)
            {
                if (destruction.burst)
                {
                    Effects.BreakIntoPieces(rootThing, destruction);
                    rootThing.name = Universe.objectNameIfAlreadyDestroyed;
                }

                if (isPlacement)
                {
                    Managers.personManager.DoRedundantlyInformAboutThingDestruction(
                        rootThing.placementId, destruction);
                    Managers.temporarilyDestroyedThingsManager.AddPlacement(
                        rootThing, destruction.restoreInSeconds);
                }
                else if (isThrownOrEmitted)
                {
                    Misc.Destroy(rootThing.gameObject);
                    if (rootThing.isHeldAsHoldableByOurPerson)
                    {
                        Managers.personManager.CachePhotonHeldThingsData();
                    }
                }
            }
        }
    }