public void RestoreTargetFromInstanceID() { if (target_instance_id != -1 && target == null) { KPrefabID instance = KPrefabIDTracker.Get().GetInstance(target_instance_id); if ((bool)instance) { IAssignableIdentity component = instance.GetComponent <IAssignableIdentity>(); if (component != null) { SetTarget(component, instance.gameObject); } else { Debug.LogWarningFormat("RestoreTargetFromInstanceID target ID {0} was found but it wasn't an IAssignableIdentity, destroying proxy object.", target_instance_id); Util.KDestroyGameObject(base.gameObject); } } else { Debug.LogWarningFormat("RestoreTargetFromInstanceID target ID {0} was not found, destroying proxy object.", target_instance_id); Util.KDestroyGameObject(base.gameObject); } } }
private void CheckTarget() { if (target == null) { KPrefabID instance = KPrefabIDTracker.Get().GetInstance(target_instance_id); if ((Object)instance != (Object)null) { target = instance.GetComponent <IAssignableIdentity>(); if (target != null) { MinionIdentity minionIdentity = target as MinionIdentity; if ((bool)minionIdentity) { minionIdentity.ValidateProxy(); } else { StoredMinionIdentity storedMinionIdentity = target as StoredMinionIdentity; if ((bool)storedMinionIdentity) { storedMinionIdentity.ValidateProxy(); } } } } } }
private void CleanupLimboMinions() { KPrefabID component = GetComponent <KPrefabID>(); if (component.InstanceID == -1) { DebugUtil.LogWarningArgs("Minion with an invalid kpid! Attempting to recover...", name); if ((UnityEngine.Object)KPrefabIDTracker.Get().GetInstance(component.InstanceID) != (UnityEngine.Object)null) { KPrefabIDTracker.Get().Unregister(component); } component.InstanceID = KPrefabID.GetUniqueID(); KPrefabIDTracker.Get().Register(component); DebugUtil.LogWarningArgs("Restored as:", component.InstanceID); } if (component.conflicted) { DebugUtil.LogWarningArgs("Minion with a conflicted kpid! Attempting to recover... ", component.InstanceID, name); if ((UnityEngine.Object)KPrefabIDTracker.Get().GetInstance(component.InstanceID) != (UnityEngine.Object)null) { KPrefabIDTracker.Get().Unregister(component); } component.InstanceID = KPrefabID.GetUniqueID(); KPrefabIDTracker.Get().Register(component); DebugUtil.LogWarningArgs("Restored as:", component.InstanceID); } assignableProxy.Get().SetTarget(this, base.gameObject); }
public static KPrefabIDTracker Get() { if (Instance == null) { Instance = new KPrefabIDTracker(); } return(Instance); }
protected override void OnCleanUp() { pendingDestruction = true; if (InstanceID != -1) { KPrefabIDTracker.Get().Unregister(this); } Trigger(1969584890, null); }
public static GameObject KInstantiate(GameObject original, Vector3 position, Quaternion rotation, GameObject parent = null, string name = null, bool initialize_id = true, int gameLayer = 0) { if (App.IsExiting) { return(null); } GameObject gameObject = null; if ((UnityEngine.Object)original == (UnityEngine.Object)null) { DebugUtil.LogWarningArgs("Missing prefab"); } if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null) { if ((UnityEngine.Object)original.GetComponent <RectTransform>() != (UnityEngine.Object)null && (UnityEngine.Object)parent != (UnityEngine.Object)null) { gameObject = UnityEngine.Object.Instantiate(original, position, rotation); gameObject.transform.SetParent(parent.transform, true); } else { Transform parent2 = null; if ((UnityEngine.Object)parent != (UnityEngine.Object)null) { parent2 = parent.transform; } gameObject = UnityEngine.Object.Instantiate(original, position, rotation, parent2); } if (gameLayer != 0) { gameObject.SetLayerRecursively(gameLayer); } } if (name != null) { gameObject.name = name; } else { gameObject.name = original.name; } KPrefabID component = gameObject.GetComponent <KPrefabID>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { if (initialize_id) { component.InstanceID = KPrefabID.GetUniqueID(); KPrefabIDTracker.Get().Register(component); } KPrefabID component2 = original.GetComponent <KPrefabID>(); component.CopyTags(component2); component.CopyInitFunctions(component2); component.RunInstantiateFn(); } return(gameObject); }
internal void OnDeserializedMethod() { KPrefabIDTracker kPrefabIDTracker = KPrefabIDTracker.Get(); KPrefabID instance = kPrefabIDTracker.GetInstance(InstanceID); if ((bool)instance) { conflicted = true; } kPrefabIDTracker.Register(this); }
public ReferenceType Get() { if ((Object)obj == (Object)null && id != -1) { KPrefabID instance = KPrefabIDTracker.Get().GetInstance(id); if ((Object)instance != (Object)null) { obj = ((Component)instance).GetComponent <ReferenceType>(); if ((Object)obj == (Object)null) { id = -1; Debug.LogWarning("Missing " + typeof(ReferenceType).Name + " reference: " + id); } } else { Debug.LogWarning("Missing KPrefabID reference: " + id); id = -1; } } return(obj); }
public static void DestroyInstance() { Instance = null; }