Exemplo n.º 1
0
        public static void refreshValidPrefabs(bool searchForDebris)
        {
            Common.Debug.assert(prefabsConfig != null);

            validPrefabs = prefabsConfig.getValidPrefabs();

            if (!searchForDebris)
            {
                return;
            }

            foreach (var pid in Object.FindObjectsOfType <PrefabIdentifier>())
            {
                if (isValidPrefab(pid.ClassId))
                {
                    DebrisTracker.track(pid.gameObject);
                }
                else
                {
                    if (pid.gameObject.GetComponent <DebrisDeconstructable>())
                    {
                        unpatchObject(pid.gameObject, true);
                    }

                    if (pid.gameObject.GetComponent <ResourceTracker>()?.overrideTechType == SalvageableDebrisDR.TechType)
                    {
                        DebrisTracker.untrack(pid.gameObject);
                    }
                }
            }

            DebrisTracker.untrackInvalid();                                                                                 $"DebrisPatcher: prefabs refreshed ({validPrefabs.Count} valid prefabs)".logDbg();
        }
Exemplo n.º 2
0
        public static void unpatchObject(GameObject go, bool removeDebrisCmp)
        {
            if (go.GetComponent <Constructable>()?.constructed == false)            // don't unpatch partially deconstructed objects
            {
                return;
            }
            $"DebrisPatcher: unpatching object {go.name}".logDbg();
            go.destroyComponent <Constructable>(false);

            if (removeDebrisCmp)
            {
                go.destroyComponent <DebrisDeconstructable>(false);
            }

            DebrisTracker.untrack(go);
        }
Exemplo n.º 3
0
 public void OnConstructedChanged(bool constructed) => DebrisTracker.untrack(gameObject);