public override void fillTile(ManipulatableObject enteringObject) { tileObject = enteringObject; full = true; free = false; pixels = fullPixels; }
private void InitializeControls() { if (!(objectManipulationInputController.CurrentlySelectedObject != null)) { return; } ManipulatableObject componentInParent = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); ObjectManipulator componentInParent2 = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>(); if (!(componentInParent2 != null)) { return; } switch (componentInParent.Type) { case DecorationLayoutData.DefinitionType.Structure: HideRotationControls(); HideScaleControls(); break; case DecorationLayoutData.DefinitionType.Decoration: { IGameData gameData = Service.Get <IGameData>(); Dictionary <int, DecorationDefinition> dictionary = gameData.Get <Dictionary <int, DecorationDefinition> >(); if (dictionary.ContainsKey(componentInParent.DefinitionId)) { DecorationDefinition def = dictionary[componentInParent.DefinitionId]; ConfigureScalingOptions(def, componentInParent2); ConfigureRotationOptions(def, componentInParent2); } break; } } }
private void OnNoSelectionStateTouchPhaseEnded(GameObject obj, Vector2 touchPosition) { ResetSelected(objectBeingDeleted: false, deleteChildren: false); CurrentState.ExitState(); touchOffset = Vector2.zero; ManipulatableObject manipulatableObject = null; if (obj != null) { manipulatableObject = obj.GetComponentInParent <ManipulatableObject>(); if (NaturalDragFromTouchPosition) { Vector2 vector = Camera.main.WorldToScreenPoint(obj.transform.position); touchOffset = vector - touchPosition; } } if (manipulatableObject != null) { obj = manipulatableObject.gameObject; if (SelectCurrentSelectedObject(obj)) { activeSelectionState.CurrentlySelectedObject = obj; CurrentState = activeSelectionState; } } CurrentState.EnterState(TargetLayerMask, MinTimeToMoveInput); }
private void OnObjectManipulationInputControllerInteractionStateChanged(InteractionState state) { switch (state) { case InteractionState.DragItem: break; case InteractionState.NoSelectedItem: case InteractionState.ActiveSelectedItem: if (newlyAddedObject != null) { calculateTargetPositionForSelectedObject(newlyAddedObject); newlyAddedObject = null; } else if (objectManipulationInputController.CurrentlySelectedObject != null) { notNewlyAddedObjectSelect(); } break; case InteractionState.DisabledInput: case InteractionState.SwipeScreen: newlyAddedObject = null; break; } }
private void onObjectManipulationInputControllerObjectSelected(ManipulatableObject obj) { if (obj != null && (objectManipulationInputController.CurrentState.State == InteractionState.ActiveSelectedItem || objectManipulationInputController.CurrentState.State == InteractionState.NoSelectedItem)) { InitializeControls(); } }
public void SelectNewObject(GameObject obj, SelectState setSelectStateTo = SelectState.Drag) { if (!(obj != null)) { return; } ResetSelected(objectBeingDeleted: false, deleteChildren: false); CurrentState.ExitState(); addNewSelectedObject(obj); InputProcessingPaused = false; if (this.NewObjectAdded != null && CurrentlySelectedObject != null) { ManipulatableObject component = CurrentlySelectedObject.GetComponent <ManipulatableObject>(); if (component != null) { this.NewObjectAdded.InvokeSafe(component); } } switch (setSelectStateTo) { case SelectState.Active: CurrentState = activeSelectionState; break; case SelectState.Drag: CurrentState = dragItemInputInteractionState; break; } CurrentState.EnterState(TargetLayerMask, MinTimeToMoveInput); }
private void onSceneManipulationServiceObjectRemoved(ManipulatableObject obj) { if (obj != null) { Object.Instantiate(DestroyDecorationParticlePrefab, obj.transform.position, Quaternion.identity); } }
private void removeObjectManipulators() { modifyObjectManipulators(delegate(GameObject go, DecorationLayoutData data) { ManipulatableObjectEffects component = go.GetComponent <ManipulatableObjectEffects>(); if ((bool)component) { UnityEngine.Object.Destroy(component); } ManipulatableObject component2 = go.GetComponent <ManipulatableObject>(); if ((bool)component2) { component2.OnRemoved -= onObjectRemoved; component2.BeforeParentChanged -= onBeforeManipulatableObjectReParented; component2.AfterParentChanged -= onAfterManipulatableObjectReParented; UnityEngine.Object.Destroy(component2); } CollidableObject component3 = go.GetComponent <CollidableObject>(); if ((bool)component3) { UnityEngine.Object.Destroy(component3); } for (int i = 0; i < sceneModifiers.Length; i++) { sceneModifiers[i].ObjectRemoved(data, go); } }); }
private void linkManipulatableObjectWithDefinition(ManipulatableObject mo, CollidableObject co, DecorationLayoutData data) { CollisionRuleSetDefinitionKey collisionRuleSet = null; switch (data.Type) { case DecorationLayoutData.DefinitionType.Decoration: { if (decorationDefinitions.TryGetValue(data.DefinitionId, out var value2)) { collisionRuleSet = value2.RuleSet; mo.Type = DecorationLayoutData.DefinitionType.Decoration; mo.DefinitionId = value2.Id; } break; } case DecorationLayoutData.DefinitionType.Structure: { if (structureDefinitions.TryGetValue(data.DefinitionId, out var value)) { collisionRuleSet = value.RuleSet; mo.Type = DecorationLayoutData.DefinitionType.Structure; mo.DefinitionId = value.Id; } break; } } co.CollisionRuleSet = collisionRuleSet; }
private void OnActiveSelectionStateTouchPhaseEnded(GameObject obj) { ResetSelected(objectBeingDeleted: false, deleteChildren: false); CurrentState.ExitState(); ManipulatableObject manipulatableObject = null; if (obj != null) { manipulatableObject = obj.GetComponentInParent <ManipulatableObject>(); } if (manipulatableObject == null) { CurrentState = noSelectionState; } else { CurrentlySelectedObject = manipulatableObject.gameObject; activeSelectionState.CurrentlySelectedObject = manipulatableObject.gameObject; if (SelectCurrentSelectedObject(manipulatableObject.gameObject)) { CurrentState = activeSelectionState; } else { CurrentState = noSelectionState; } } CurrentState.EnterState(TargetLayerMask, MinTimeToMoveInput); }
protected void onObjectAddedOrRemoved(ManipulatableObject manipulatableObject) { inventoryCountPairs = GetAvailableItems(); if (manipulatableObject.Type != decorationDefinitionType || inventoryCountPairs == null) { return; } inventoryCountPairs = sortInventoryList(inventoryCountPairs); bool flag = false; int count = inventoryCountPairs.Count; for (int i = 0; i < count; i++) { DecorationDefinitionType key = inventoryCountPairs[i].Key; if (key.GetId() == manipulatableObject.DefinitionId) { if (PooledScrollRect.IsIndexCellVisible(i + numberOfStaticButtons)) { IglooCustomizationButton component = PooledScrollRect.GetCellAtIndex(i + numberOfStaticButtons).GetComponent <IglooCustomizationButton>(); component.SetItemCount(inventoryCountPairs[i].Value, showItemCountsWithZeroCount, tintItemsWithZeroCount); } objectAddedOrRemoved(i, manipulatableObject); flag = true; break; } } if (!flag) { manipulatedObjectNotFound(manipulatableObject); } }
private bool ResetSelected(bool objectBeingDeleted, bool deleteChildren) { bool flag = false; if (CurrentlySelectedObject != null) { ManipulatableObject component = CurrentlySelectedObject.GetComponent <ManipulatableObject>(); ObjectManipulator componentInParent = CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>(); if (componentInParent != null) { if (componentInParent.IsAllowed) { Transform parent = CurrentlySelectedObject.transform.parent; CurrentlySelectedObject.transform.SetParent(oldParentOfSelectedObject, worldPositionStays: true); component.SetParent(parent); componentInParent.WasReparented = true; } else if (!restoreOldObject()) { flag = true; } if (!objectBeingDeleted && this.ObjectDeselected != null) { this.ObjectDeselected.InvokeSafe(componentInParent); } if (flag) { component.RemoveObject(deleteChildren); } } } CurrentlySelectedObject = null; return(flag); }
private void DeleteSelectedItem(bool deleteChildren) { GameObject gameObject = CurrentlySelectedObject; UnityEngine.Object.Destroy(oldObject); oldObject = null; if (!deleteChildren) { ManipulatableObject component = CurrentlySelectedObject.GetComponent <ManipulatableObject>(); if (component != null) { this.ObjectBeforeDelete.InvokeSafe(component); } } bool flag = ResetSelected(objectBeingDeleted: true, deleteChildren); if (gameObject != null && !flag) { ManipulatableObject componentInParent = gameObject.GetComponentInParent <ManipulatableObject>(); if (componentInParent != null) { componentInParent.RemoveObject(deleteChildren); } } }
private void onObjectRemoved(GameObject obj, bool deleteChildren) { DecorationLayoutData decorationLayoutData = default(DecorationLayoutData); decorationLayoutData.Id = DecorationLayoutData.ID.FromFullPath(GetRelativeGameObjectPath(obj)); DecorationLayoutData decoration = decorationLayoutData; SceneLayoutData.RemoveDecoration(decoration, deleteChildren); if (selectedObjectStartingId == decoration.Id.GetFullPath()) { selectedObjectStartingId = null; ObjectManipulator component = obj.GetComponent <ObjectManipulator>(); if (component != null) { for (int i = 0; i < sceneModifiers.Length; i++) { sceneModifiers[i].AfterObjectDeselected(component); } } } decorationInventoryService.MarkStructuresDirty(); decorationInventoryService.MarkDecorationsDirty(); if (this.ObjectRemoved != null) { ManipulatableObject component2 = obj.GetComponent <ManipulatableObject>(); this.ObjectRemoved.InvokeSafe(component2); } UnityEngine.Object.Destroy(obj); removePartneredObject(obj); }
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); } }
private IEnumerator delayTillLoadComplete(ManipulatableObject manipulatableObject, Bounds boundsForCameraTarget, float minCameraDistance) { while (decorationOptionsUIInstance == null) { yield return(null); } setNewDecorationDetails(manipulatableObject, boundsForCameraTarget, minCameraDistance); }
protected override void manipulatedObjectNotFound(ManipulatableObject manipulatableObject) { base.manipulatedObjectNotFound(manipulatableObject); if (decorationCategoryManager != null && decorationCategoryManager.GetCurrentFilter() is InMyIglooDecorationCategoryFilter) { decorationCategoryManager.RefreshDecorationsDisplayed(); } }
private void setNewDecorationDetails(ManipulatableObject manipulatableObject, Bounds boundsForCameraTarget, float minCameraDistance) { if (!decorationOptionsUIInstance.IsInitialized) { decorationOptionsUIInstance.Init(SceneManipulationServiceRef, boundsForCameraTarget, minCameraDistance); } decorationOptionsUIInstance.SetNewDecoration(manipulatableObject); }
private void onConfirmSquashedObjectBeforeDragComplete(ObjectManipulator selected, Action <bool> callback) { if (selected == null) { return; } HashSet <ManipulatableObject> squashed = new HashSet <ManipulatableObject>(); foreach (Collider currentCollider in selected.CurrentColliders) { ManipulatableObject componentInParent = currentCollider.GetComponentInParent <ManipulatableObject>(); if (componentInParent != null && componentInParent.IsSquashed) { squashed.Add(componentInParent); ManipulatableObject[] componentsInChildren = componentInParent.GetComponentsInChildren <ManipulatableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { squashed.Add(componentsInChildren[i]); } } } Action <int, Action <bool> > confirmObjectRemoval = Service.Get <ObjectManipulationService>().ConfirmObjectRemoval; if (squashed.Count > 0 && confirmObjectRemoval != null) { confirmObjectRemoval(squashed.Count, delegate(bool delete) { if (delete) { foreach (ManipulatableObject item in squashed) { if (item != null) { item.RemoveObject(deleteChildren: false); } } } objectManipulationInputController.SkipOneFrame = true; if (callback != null) { callback(delete); } }); return; } foreach (ManipulatableObject item2 in squashed) { if (item2 != null) { item2.RemoveObject(deleteChildren: false); } } if (callback != null) { callback(obj: true); } }
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 bool restoreOldObject() { if (oldObject != null) { copyTransform(oldObject.transform, CurrentlySelectedObject.transform); ManipulatableObject component = CurrentlySelectedObject.GetComponent <ManipulatableObject>(); component.SetParent(oldParent); return(true); } return(false); }
private void onObjectBeforeDelete(ManipulatableObject mo) { ManipulatableObject[] componentsInChildren = mo.GetComponentsInChildren <ManipulatableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].transform.parent == mo.transform) { componentsInChildren[i].SetParent(sceneLayoutContainer); Assert.IsTrue(componentsInChildren[i].transform.parent == sceneLayoutContainer); } } }
protected override void objectAddedOrRemoved(int itemIndex, ManipulatableObject manipulatableObject) { base.objectAddedOrRemoved(itemIndex, manipulatableObject); if (decorationCategoryManager != null && decorationCategoryManager.GetCurrentFilter() is InMyIglooDecorationCategoryFilter) { int totalInventoryCountForDecoration = decorationInventoryService.GetTotalInventoryCountForDecoration(manipulatableObject.DefinitionId); if (totalInventoryCountForDecoration == inventoryCountPairs[itemIndex].Value) { decorationCategoryManager.RefreshDecorationsDisplayed(); } } }
private int getSelectedDefinitionId() { if (ObjectManipulationInputController.CurrentlySelectedObject != null) { ManipulatableObject component = ObjectManipulationInputController.CurrentlySelectedObject.GetComponent <ManipulatableObject>(); if (component != null) { return(component.DefinitionId); } throw new InvalidOperationException($"Could not find ManipulatableObject component on {ObjectManipulationInputController.CurrentlySelectedObject.name}"); } return(-1); }
private void onAfterManipulatableObjectReParented(Transform newParent, GameObject obj) { ObjectManipulator.SetUniqueGameObjectName(obj, newParent); UpdateLayoutForManipulatableObject(newParent, obj.GetComponent <ManipulatableObject>()); foreach (Transform item in obj.transform) { ManipulatableObject component = item.GetComponent <ManipulatableObject>(); if (component != null) { component.SetParent(component.transform.parent); } } }
private void onBeforeManipulatableObjectReParented(Transform newParent, GameObject obj) { ManipulatableObject component = obj.GetComponent <ManipulatableObject>(); DecorationLayoutData decorationLayoutData = default(DecorationLayoutData); decorationLayoutData.Id = DecorationLayoutData.ID.FromFullPath(component.PathId); DecorationLayoutData decoration = decorationLayoutData; if (SceneLayoutData.ContainsKey(decoration.Id.GetFullPath())) { SceneLayoutData.RemoveDecoration(decoration, deleteChildren: true); } }
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; } } }
private void ScaleSelectedItem(ObjectManipulator m, float delta) { ManipulatableObject componentInParent = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); Dictionary <int, DecorationDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <int, DecorationDefinition> >(); if (dictionary.ContainsKey(componentInParent.DefinitionId)) { DecorationDefinition decorationDefinition = dictionary[componentInParent.DefinitionId]; float num = m.Scale + delta; if (num >= decorationDefinition.MinScale && num <= decorationDefinition.MaxScale) { m.ScaleTo(num); } } }
private void RotatedSelectedItem(ObjectManipulator m, float delta) { ManipulatableObject componentInParent = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); Dictionary <int, DecorationDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <int, DecorationDefinition> >(); if (dictionary.ContainsKey(componentInParent.DefinitionId)) { DecorationDefinition decorationDefinition = dictionary[componentInParent.DefinitionId]; float degrees = m.CurrentRotationDegreesAroundUp + delta; float degrees2 = RotateClamp360Degrees(degrees); if (isValidRotation(degrees2)) { m.RotateBy(delta); } } }
private void notNewlyAddedObjectSelect() { ManipulatableObject component = objectManipulationInputController.CurrentlySelectedObject.GetComponent <ManipulatableObject>(); if (component != null) { if (CenterCameraOnSelect) { calculateTargetPositionForSelectedObject(component); } else { eventDispatcher.DispatchEvent(new IglooUIEvents.ShowSelectedUIWidget(component, boundsForCameraTarget, MinCameraTargetDistanceOnNewItem)); } } }
public override void insertObject(ManipulatableObject enteringObject) { tileObject = enteringObject; pixels = freePixels; full = true; }
public void addObject(ManipulatableObject obj, int x, int y) { trafficMap.getObjectBooleanMap()[x, y] = true; trafficMap.getObjectMap()[x, y] = obj; objectList.Add(obj); }
void Start() { mo = gameObject.GetComponent<ManipulatableObject> (); mo.powered = powered; wasPowered = powered; }
public override void insertObject(ManipulatableObject enteringObject) { tileObject = enteringObject; if (tileObject.isJumpable()) { jumpable = true; } else { jumpable = false; } }
public override void fillTile(ManipulatableObject enteringObject) { }
public override void insertObject(ManipulatableObject enteringObject) { }