private void configurePartneredObject(DecorationLayoutData decoration, GameObject current) { PartneredObject component = current.GetComponent <PartneredObject>(); if (!(component != null)) { return; } if (decoration.CustomProperties.ContainsKey("guid")) { component.Guid = decoration.CustomProperties["guid"]; guidDictionary[component.Guid] = current; } if (decoration.CustomProperties.ContainsKey("num")) { component.SetNumber(int.Parse(decoration.CustomProperties["num"])); } if (decoration.CustomProperties.ContainsKey("partner")) { component.PartnerGuid = decoration.CustomProperties["partner"]; } if (guidDictionary.ContainsKey(component.PartnerGuid)) { GameObject gameObject = guidDictionary[component.PartnerGuid]; component.Other = gameObject.GetComponent <PartneredObject>(); if (component.Other != null) { component.Other.Other = component; } } }
public void onOtherPartnerSet(PartneredObject po) { if (po.Other != null) { WarpToTransformAction componentInChildren = GetComponentInChildren <WarpToTransformAction>(); if (componentInChildren != null) { componentInChildren.TargetTransform = po.Other.transform; } } }
public void ProcessObject(GameObject go) { ManipulatableObjectEffects component = go.GetComponent <ManipulatableObjectEffects>(); if (component != null && go.GetComponent <ManipulatableStructure>() == null) { component.SetSelectable(!structuresEnabled); } PartneredObject component2 = go.GetComponent <PartneredObject>(); if (component2 != null) { sceneManipulationService.numberTracker.RegisterNumber(component2.Number); } }
public void SetOthers(GameObject[] others) { Assert.IsTrue(others.Length == 2, "The paired item only works with two items"); for (int i = 0; i < others.Length; i++) { if (others[i] != base.gameObject) { PartneredObject component = others[i].GetComponent <PartneredObject>(); if (component != null) { Other = component; } } } }
private void removePartneredObject(GameObject obj) { PartneredObject component = obj.GetComponent <PartneredObject>(); if (!(component != null)) { return; } numberTracker.UnregisterNumber(component.Number); if (component.Other != null) { ManipulatableObject component2 = component.Other.gameObject.GetComponent <ManipulatableObject>(); component.Other = null; if (component2 != null) { component2.RemoveObject(deleteChildren: false); } } }
private void onSplittableObjectChildrenSplit(SplittableObject splittableObject) { ManipulatableObject component = splittableObject.GetComponent <ManipulatableObject>(); CollidableObject component2 = splittableObject.GetComponent <CollidableObject>(); int nextAvailable = numberTracker.GetNextAvailable(); GameObject[] splitList = splittableObject.SplitList; foreach (GameObject gameObject in splitList) { CollidableObject collidableObject = gameObject.AddComponent <CollidableObject>(); collidableObject.CollisionRuleSet = component2.CollisionRuleSet; ManipulatableObject manipulatableObject = gameObject.AddComponent <ManipulatableObject>(); gameObject.AddComponent <ManipulatableObjectEffects>(); if (component != null) { manipulatableObject.DefinitionId = component.DefinitionId; } if (this.ObjectAdded != null) { this.ObjectAdded.InvokeSafe(manipulatableObject); } PartneredObject component3 = gameObject.GetComponent <PartneredObject>(); if (component3 != null) { component3.SetOthers(splittableObject.SplitList); component3.SetNumber(nextAvailable); } UpdateLayoutForManipulatableObject(sceneLayoutContainer, manipulatableObject); manipulatableObject.SetParent(sceneLayoutContainer); manipulatableObject.OnRemoved += onObjectRemoved; manipulatableObject.BeforeParentChanged += onBeforeManipulatableObjectReParented; manipulatableObject.AfterParentChanged += onAfterManipulatableObjectReParented; } component.RemoveObject(deleteChildren: false); splittableObject.ChildrenSplit -= onSplittableObjectChildrenSplit; }
private static void SetCustomPropertiesInDecoration(ref DecorationLayoutData data, PartneredObject po) { if (po != null) { Assert.IsNotNull(po.Other, "Other cannot be null"); data.CustomProperties["partner"] = po.Other.GetGuid(); data.CustomProperties["guid"] = po.GetGuid(); Assert.IsTrue(po.Number > 0, "Number not set"); data.CustomProperties["num"] = po.Number.ToString(); } }