private void onObjectSelected(ManipulatableObject obj) { if (obj == null) { return; } for (int i = 0; i < sceneModifiers.Length; i++) { if (!sceneModifiers[i].CanObjectBeSelected(obj)) { return; } } ObjectManipulator objectManipulator = obj.gameObject.AddComponentIfMissing <ObjectManipulator>(); objectManipulationManager.WatchObject(objectManipulator); obj.GetComponent <CollidableObject>().EnableTriggers(); obj.GetComponent <ManipulatableObjectEffects>().SetObjectManipulator(objectManipulator); Rigidbody rigidbody = obj.gameObject.AddComponentIfMissing <Rigidbody>(); rigidbody.isKinematic = true; rigidbody.useGravity = false; for (int i = 0; i < sceneModifiers.Length; i++) { sceneModifiers[i].AfterObjectSelected(obj, isNewObject); } isNewObject = false; selectedObjectStartingId = GetRelativeGameObjectPath(obj.gameObject); ManipulatableObject[] componentsInChildren = obj.GetComponentsInChildren <ManipulatableObject>(); foreach (ManipulatableObject manipulatableObject in componentsInChildren) { manipulatableObject.PathId = GetRelativeGameObjectPath(manipulatableObject.gameObject); } }
public void AfterObjectSelected(ManipulatableObject obj, bool isNewObject) { if (obj.GetComponent <ManipulatableStructure>() != null) { ObjectManipulator component = obj.GetComponent <ObjectManipulator>(); ManipulatableStructure component2 = obj.GetComponent <ManipulatableStructure>(); component.BaseLocationIsValid = !isNewObject; for (int i = 0; i < attractors.Count; i++) { attractors[i].SetTrackedObject(component, component2.SizeUnits, sceneManipulationService.ObjectManipulationInputController); attractors[i].OnAttracted += onAttracted; } } }
public bool CanObjectBeSelected(ManipulatableObject obj) { bool flag = obj.GetComponent <ManipulatableStructure>() != null; if (structuresEnabled != flag) { return(false); } return(true); }
public void SetNewDecoration(ManipulatableObject manipulatableObject) { removeDecorationListeners(); this.manipulatableObject = manipulatableObject; objectManipulator = manipulatableObject.GetComponent <ObjectManipulator>(); objectManipulator.PositionChanged += OnObjectManipulatorPositionChanged; objectManipulator.IsAllowedChanged += OnObjectManipulatorIsAllowedChanged; OnObjectManipulatorIsAllowedChanged(); SetPosition(); CoroutineRunner.Start(showNewDecoration(), this, "Show New Decoration"); }
private void onObjectedDeselected(ObjectManipulator obj) { ManipulatableObject component = obj.GetComponent <ManipulatableObject>(); ManipulatableObjectEffects component2 = obj.gameObject.GetComponent <ManipulatableObjectEffects>(); Rigidbody component3 = obj.gameObject.GetComponent <Rigidbody>(); if (!obj.WasReparented) { DecorationLayoutData decorationLayoutData = default(DecorationLayoutData); decorationLayoutData.Id = DecorationLayoutData.ID.FromFullPath(GetRelativeGameObjectPath(obj.gameObject)); decorationLayoutData.DefinitionId = component.DefinitionId; decorationLayoutData.Type = component.Type; decorationLayoutData.Position = obj.transform.localPosition; decorationLayoutData.Rotation = obj.transform.localRotation; decorationLayoutData.UniformScale = obj.transform.localScale.x; DecorationLayoutData data = decorationLayoutData; SetCustomPropertiesInDecoration(ref data, obj.GetComponent <PartneredObject>()); if (selectedObjectStartingId == null) { SceneLayoutData.AddDecoration(data); } else { string relativeGameObjectPath = GetRelativeGameObjectPath(component.gameObject); SceneLayoutData.UpdateDecoration(relativeGameObjectPath, data); } } selectedObjectStartingId = null; if ((bool)component2) { component2.ClearObjectManipulator(); } if ((bool)obj) { UnityEngine.Object.Destroy(obj); } if ((bool)component3) { UnityEngine.Object.Destroy(component3); } component.GetComponent <CollidableObject>().EnableTriggers(isTrigger: false); for (int i = 0; i < sceneModifiers.Length; i++) { sceneModifiers[i].AfterObjectDeselected(obj); } this.ObjectDeselected.InvokeSafe(component); }
public static Vector3 GetBaseOfTargetPoint(ManipulatableObject mo, float minTargetDistance) { CollidableObject component = mo.GetComponent <CollidableObject>(); if (component == null) { return(Vector3.zero); } Bounds bounds = component.GetBounds(); float num = bounds.size.z * 0.5f; if (num < minTargetDistance) { num = minTargetDistance; } Vector3 center = bounds.center; center.z += num; return(center); }
private bool SelectCurrentSelectedObject(GameObject obj) { CurrentlySelectedObject = obj; if (CurrentlySelectedObject != null) { ManipulatableObject componentInParent = CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); if (componentInParent != null) { storeOldObject(); if (this.ObjectSelected != null) { this.ObjectSelected.InvokeSafe(componentInParent); if (componentInParent.GetComponent <ObjectManipulator>() != null) { return(true); } } } } return(false); }
private DecorationLayoutData UpdateLayoutForManipulatableObject(Transform newParent, ManipulatableObject mo) { string pathId = mo.PathId; if (newParent != mo.transform.parent) { ObjectManipulator.SetUniqueGameObjectName(mo.gameObject, newParent); } DecorationLayoutData decorationLayoutData = default(DecorationLayoutData); decorationLayoutData.Id.Name = mo.gameObject.name; decorationLayoutData.Id.ParentPath = GetRelativeGameObjectPath(newParent.gameObject); decorationLayoutData.DefinitionId = mo.DefinitionId; decorationLayoutData.Type = mo.Type; decorationLayoutData.Position = mo.gameObject.transform.localPosition; decorationLayoutData.Rotation = mo.gameObject.transform.localRotation; decorationLayoutData.UniformScale = mo.gameObject.transform.localScale.x; DecorationLayoutData data = decorationLayoutData; if (data.Id.ParentPath == "") { data.Position = mo.gameObject.transform.position; data.Rotation = mo.gameObject.transform.rotation; data.UniformScale = mo.gameObject.transform.lossyScale.x; data.Id.ParentPath = null; } SetCustomPropertiesInDecoration(ref data, mo.GetComponent <PartneredObject>()); if (SceneLayoutData.ContainsKey(pathId)) { SceneLayoutData.UpdateDecoration(pathId, data); } else { SceneLayoutData.AddDecoration(data); } return(data); }