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; } } }
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 renderDecoration(DecorationLayoutData decoration) { PrefabContentKey prefabContentKey = null; switch (decoration.Type) { case DecorationLayoutData.DefinitionType.Decoration: if (decorationDefs.TryGetValue(decoration.DefinitionId, out DecorationDefinition value2)) { prefabContentKey = value2.Prefab; } break; case DecorationLayoutData.DefinitionType.Structure: if (structureDefs.TryGetValue(decoration.DefinitionId, out StructureDefinition value)) { prefabContentKey = value.Prefab; } break; } if (prefabContentKey != null) { loadOrder.Enqueue(decoration.Id.GetFullPath()); CoroutineRunner.Start(processDecoration(decoration, prefabContentKey), this, "processDecoration"); } }
public static List <DecorationLayoutData> ToDecorationLayoutData(List <DecorationLayout> decorationLayout) { List <DecorationLayoutData> list = new List <DecorationLayoutData>(); if (decorationLayout != null) { for (int i = 0; i < decorationLayout.Count; i++) { try { DecorationLayoutData item = default(DecorationLayoutData); item.Id.Name = decorationLayout[i].id.name; item.Id.ParentPath = decorationLayout[i].id.parent; item.Position = decorationLayout[i].position; item.DefinitionId = Convert.ToInt32(decorationLayout[i].definitionId); item.Rotation = Quaternion.ToUnityQuaternion(decorationLayout[i].rotation); item.Type = ToDecorationLayoutDataDefinitionType(decorationLayout[i].type); item.UniformScale = decorationLayout[i].scale; item.CustomProperties = decorationLayout[i].customProperties; list.Add(item); } catch (Exception) { } } } return(list); }
private IEnumerator processDecoration(DecorationLayoutData decoration, PrefabContentKey contentKey) { PrefabCacheTracker.PrefabRequest prefabRequest = prefabCacheTracker.Acquire(contentKey); while (!prefabRequest.IsComplete) { yield return(null); } yield return(new WaitForEndOfFrame()); while (loadOrder.Peek() != decoration.Id.GetFullPath()) { yield return(null); } string idFromQueue = loadOrder.Dequeue(); Assert.IsTrue(idFromQueue == decoration.Id.GetFullPath()); if (prefabRequest != null && prefabRequest.Prefab != null) { bool flag = true; Transform transform = Container.Find(decoration.Id.ParentPath); if (transform == null) { if (string.IsNullOrEmpty(decoration.Id.ParentPath)) { transform = Container; } else { Log.LogErrorFormatted(this, "Invalid path of decoration. Removing from layout: {0}", decoration.Id.GetFullPath()); layout.RemoveDecoration(decoration, deleteChildren: true); flag = false; } } if (flag) { GameObject gameObject = UnityEngine.Object.Instantiate(prefabRequest.Prefab, transform, worldPositionStays: false); SplittableObject component = gameObject.GetComponent <SplittableObject>(); Vector3 localScale = gameObject.transform.localScale; if (component != null) { gameObject = component.ExtractSingleItem(); gameObject.transform.SetParent(transform, worldPositionStays: false); } configurePartneredObject(decoration, gameObject); gameObject.transform.localPosition = decoration.Position; gameObject.transform.localRotation = decoration.Rotation; gameObject.name = decoration.Id.Name; gameObject.transform.localScale = decoration.UniformScale * localScale; prefabCacheTracker.SetCache(gameObject, prefabRequest.ContentKey); } } else { Log.LogErrorFormatted(this, "Something went wrong loading {0}.", contentKey.Key); prefabCacheTracker.Release(contentKey); } checkForLoadComplete(); }
public void ObjectRemoved(DecorationLayoutData data, GameObject go) { ManipulatableStructure component = go.GetComponent <ManipulatableStructure>(); if ((bool)component) { Object.Destroy(component); } }
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(); } }
private bool onAddNewStructure(IglooUIEvents.AddNewStructure evt) { if (ClubPenguin.Core.SceneRefs.IsSet <SceneManipulationService>()) { DecorationLayoutData data = default(DecorationLayoutData); data.DefinitionId = evt.Definition.Id; data.Type = DecorationLayoutData.DefinitionType.Structure; ClubPenguin.Core.SceneRefs.Get <SceneManipulationService>().AddNewObject(evt.Definition.Prefab, evt.FinalTouchPoint, data); } return(false); }
public bool IsLayoutAtMaxItemLimit() { if (ObjectManipulationInputController != null && ObjectManipulationInputController.CurrentlySelectedObject != null) { DecorationLayoutData selectedItem = default(DecorationLayoutData); selectedItem.Id.Name = ObjectManipulationInputController.CurrentlySelectedObject.name; selectedItem.Id.ParentPath = GetRelativeGameObjectPath(ObjectManipulationInputController.CurrentlySelectedObject.transform.parent.gameObject); bool selectedItemIsAPair = ObjectManipulationInputController.CurrentlySelectedObject.GetComponent <SplittableObject>() != null; return(SceneLayoutData.IsLayoutAtMaxItemLimit(selectedItem, selectedItemIsAPair)); } return(SceneLayoutData.IsLayoutAtMaxItemLimit()); }
private void onDecorationAdded(SceneLayoutData sceneLayoutData, DecorationLayoutData decoration) { if (!sceneLayoutData.ItemLimitWarningShown && sceneLayoutData.LayoutCount < sceneLayoutData.MaxLayoutItems) { float num = (float)sceneLayoutData.LayoutCount / ((float)sceneLayoutData.MaxLayoutItems * 1f); if (num >= 0.85f) { string tokenTranslation = Service.Get <Localizer>().GetTokenTranslation("Igloos.ItemLimit.Banner"); Service.Get <EventDispatcher>().DispatchEvent(new IglooUIEvents.ShowNotification(tokenTranslation, 5f, null, adjustRectPositionForNotification: true, showAfterSceneLoad: false)); sceneLayoutData.ItemLimitWarningShown = true; } } }
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 ObjectAdded(DecorationLayoutData data, GameObject go) { if (data.Type == DecorationLayoutData.DefinitionType.Structure) { ManipulatableStructure manipulatableStructure = go.AddComponent <ManipulatableStructure>(); int sizeUnits = 0; if (structureDefinitions.TryGetValue(data.DefinitionId, out StructureDefinition value)) { sizeUnits = value.SizeUnits; } manipulatableStructure.SizeUnits = sizeUnits; } }
private bool structureHasItems(DecorationLayoutData structureData) { if (structureData.Type == DecorationLayoutData.DefinitionType.Structure && sceneManipulationService != null && sceneManipulationService.SceneLayoutData != null) { string fullPath = structureData.Id.GetFullPath(); foreach (DecorationLayoutData item in sceneManipulationService.SceneLayoutData.GetLayoutEnumerator()) { if (item.Id.ParentPath == fullPath) { return(true); } } } return(false); }
public static void ConvertToMutableSceneLayout(MutableSceneLayout mutableSceneLayout, SceneLayoutData sceneLayoutData) { mutableSceneLayout.zoneId = sceneLayoutData.LotZoneName; mutableSceneLayout.lightingId = sceneLayoutData.LightingId; mutableSceneLayout.musicId = sceneLayoutData.MusicTrackId; mutableSceneLayout.extraInfo = sceneLayoutData.ExtraInfo; mutableSceneLayout.decorationsLayout = new List <DecorationLayout>(); foreach (DecorationLayoutData item2 in sceneLayoutData.GetLayoutEnumerator()) { DecorationLayoutData current = item2; DecorationLayout item = default(DecorationLayout); ref DecorationLayout.Id id = ref item.id; DecorationLayoutData.ID id2 = current.Id; id.name = id2.Name; ref DecorationLayout.Id id3 = ref item.id;
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 List <KeyValuePair <DecorationDefinition, int> > GetAvailableDecorations() { HashSet <string> hashSet = new HashSet <string>(); if (cachedCalculatedDecorationInventory == null) { if (decorationInventory == null) { Log.LogError(this, "Attempting to access the Decoration inventory before it is loaded"); return(new List <KeyValuePair <DecorationDefinition, int> >()); } if (sceneLayout == null) { Log.LogError(this, "Attempting to access the Decoration inventory before scene is loaded"); return(new List <KeyValuePair <DecorationDefinition, int> >()); } cachedAvailableDecorationCounts = new Dictionary <int, int>(decorationInventory.Decorations); foreach (DecorationLayoutData item in sceneLayout.GetLayoutEnumerator()) { DecorationLayoutData current = item; bool flag = true; if (current.Type == DecorationLayoutData.DefinitionType.Decoration && cachedAvailableDecorationCounts.ContainsKey(current.DefinitionId)) { if (current.CustomProperties.ContainsKey("partner") && current.CustomProperties.ContainsKey("guid")) { flag = !hashSet.Contains(current.CustomProperties["partner"]); hashSet.Add(current.CustomProperties["guid"]); } if (flag) { Dictionary <int, int> dictionary; int definitionId; (dictionary = cachedAvailableDecorationCounts)[definitionId = current.DefinitionId] = dictionary[definitionId] - 1; } } } cachedCalculatedDecorationInventory = new List <KeyValuePair <DecorationDefinition, int> >(); foreach (KeyValuePair <int, int> cachedAvailableDecorationCount in cachedAvailableDecorationCounts) { if (decorationDefinitions.ContainsKey(cachedAvailableDecorationCount.Key)) { cachedCalculatedDecorationInventory.Add(new KeyValuePair <DecorationDefinition, int>(decorationDefinitions[cachedAvailableDecorationCount.Key], cachedAvailableDecorationCount.Value)); } } } return(cachedCalculatedDecorationInventory); }
internal override List <KeyValuePair <DecorationDefinition, int> > GetDefinitionsToDisplay() { List <KeyValuePair <DecorationDefinition, int> > list = new List <KeyValuePair <DecorationDefinition, int> >(); if (sceneLayoutData != null) { foreach (DecorationLayoutData item2 in sceneLayoutData.GetLayoutEnumerator()) { DecorationLayoutData current = item2; if (current.Type == DecorationLayoutData.DefinitionType.Decoration && dictionaryOfDecorationDefinitions.ContainsKey(current.DefinitionId)) { DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[current.DefinitionId]; int availableDecorationCount = SceneRefs.Get <SceneManipulationService>().GetAvailableDecorationCount(decorationDefinition.Id); KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount); if (!list.Contains(item)) { list.Add(item); } } } } if (SceneRefs.IsSet <SceneManipulationService>()) { SceneManipulationService sceneManipulationService = SceneRefs.Get <SceneManipulationService>(); if (sceneManipulationService.IsObjectSelectedForAdd) { ObjectManipulator currentObjectManipulator = sceneManipulationService.ObjectManipulationInputController.CurrentObjectManipulator; if (currentObjectManipulator != null) { int definitionId = currentObjectManipulator.GetComponent <ManipulatableObject>().DefinitionId; DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[definitionId]; int availableDecorationCount = sceneManipulationService.GetAvailableDecorationCount(decorationDefinition.Id); KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount); if (!list.Contains(item)) { list.Add(item); } } } } return(list); }
private ManipulatableObject addObjectManipulator(GameObject go, DecorationLayoutData data) { CollidableObject co = go.AddComponentIfMissing <CollidableObject>(); ManipulatableObject manipulatableObject = go.AddComponentIfMissing <ManipulatableObject>(); linkManipulatableObjectWithDefinition(manipulatableObject, co, data); manipulatableObject.OnRemoved += onObjectRemoved; manipulatableObject.BeforeParentChanged += onBeforeManipulatableObjectReParented; manipulatableObject.AfterParentChanged += onAfterManipulatableObjectReParented; if (this.ObjectAdded != null) { this.ObjectAdded.InvokeSafe(manipulatableObject); } go.AddComponentIfMissing <ManipulatableObjectEffects>(); for (int i = 0; i < sceneModifiers.Length; i++) { sceneModifiers[i].ObjectAdded(data, go); } return(manipulatableObject); }
public void OnDeleteClicked() { if (manipulatableObject.Type == DecorationLayoutData.DefinitionType.Structure) { if (sceneManipulationService != null) { if (sceneManipulationService.SceneLayoutData != null) { DecorationLayoutData decorationLayoutData = default(DecorationLayoutData); decorationLayoutData.Id = DecorationLayoutData.ID.FromFullPath(sceneManipulationService.GetRelativeGameObjectPath(manipulatableObject.gameObject)); decorationLayoutData.Type = DecorationLayoutData.DefinitionType.Structure; DecorationLayoutData structureData = decorationLayoutData; if (structureHasItems(structureData)) { Service.Get <EventDispatcher>().DispatchEvent(default(ObjectManipulationEvents.RemovingStructureWithItemsEvent)); } else { Service.Get <EventDispatcher>().DispatchEvent(new ObjectManipulationEvents.DeleteSelectedItemEvent(deleteChildren: false)); } } else { UnsetDecoration(); Log.LogError(this, "sceneManipulationService.layout is null"); } } else { UnsetDecoration(); Log.LogError(this, "sceneManipulationService is null"); } } else { Service.Get <EventDispatcher>().DispatchEvent(new ObjectManipulationEvents.DeleteSelectedItemEvent(deleteChildren: 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); }
public List <KeyValuePair <StructureDefinition, int> > GetAvailableStructures() { if (cachedCalculatedStructureInventory == null) { if (structureInventory == null) { Log.LogError(this, "Attempting to access the Structure inventory before it is loaded"); return(new List <KeyValuePair <StructureDefinition, int> >()); } if (sceneLayout == null) { Log.LogError(this, "Attempting to access the Structure inventory before scene is loaded"); return(new List <KeyValuePair <StructureDefinition, int> >()); } cachedAvailableStructureCounts = new Dictionary <int, int>(structureInventory.Structures); foreach (DecorationLayoutData item in sceneLayout.GetLayoutEnumerator()) { DecorationLayoutData current = item; if (current.Type == DecorationLayoutData.DefinitionType.Structure && cachedAvailableStructureCounts.ContainsKey(current.DefinitionId)) { Dictionary <int, int> dictionary; int definitionId; (dictionary = cachedAvailableStructureCounts)[definitionId = current.DefinitionId] = dictionary[definitionId] - 1; } } cachedCalculatedStructureInventory = new List <KeyValuePair <StructureDefinition, int> >(); foreach (KeyValuePair <int, int> cachedAvailableStructureCount in cachedAvailableStructureCounts) { if (structureDefinitions.ContainsKey(cachedAvailableStructureCount.Key)) { cachedCalculatedStructureInventory.Add(new KeyValuePair <StructureDefinition, int>(structureDefinitions[cachedAvailableStructureCount.Key], cachedAvailableStructureCount.Value)); } } } return(cachedCalculatedStructureInventory); }
private bool onDuplicateSelectedObject(IglooUIEvents.DuplicateSelectedObject evt) { SceneLayoutData activeSceneLayoutData = layoutManager.GetActiveSceneLayoutData(); if (activeSceneLayoutData.IsLayoutAtMaxItemLimit()) { Log.LogError(this, "Attempting to duplicate when max items already met"); return(false); } DecorationLayoutData data = default(DecorationLayoutData); bool flag = false; Vector3 zero = Vector3.zero; UnityEngine.Quaternion identity = UnityEngine.Quaternion.identity; Vector3 one = Vector3.one; if (!ClubPenguin.Core.SceneRefs.IsSet <ObjectManipulationInputController>()) { Log.LogError(this, "ObjectManipulationInputController not set when attempting to duplicate."); return(false); } ObjectManipulationInputController objectManipulationInputController = ClubPenguin.Core.SceneRefs.Get <ObjectManipulationInputController>(); if (objectManipulationInputController.CurrentlySelectedObject == null) { Log.LogError(this, "Currently selected object was null when attempting to duplicate."); return(false); } ManipulatableObject component = objectManipulationInputController.CurrentlySelectedObject.GetComponent <ManipulatableObject>(); zero = component.transform.position; identity = component.transform.rotation; Transform parent = component.transform.parent; component.transform.parent = null; one = component.transform.localScale; component.transform.parent = parent; data.DefinitionId = component.DefinitionId; data.Type = component.Type; if (true && ClubPenguin.Core.SceneRefs.IsSet <SceneManipulationService>()) { SceneManipulationService sceneManipulationService = ClubPenguin.Core.SceneRefs.Get <SceneManipulationService>(); if (data.Type == DecorationLayoutData.DefinitionType.Decoration) { Vector3 vector = Vector3.right; if (objectManipulationInputController.CurrentlySelectedObject.GetComponent <PartneredObject>() != null || objectManipulationInputController.CurrentlySelectedObject.GetComponent <SplittableObject>() != null) { vector = Vector3.right * 3f; } DecorationDefinition decorationDefinition = Service.Get <DecorationInventoryService>().GetDecorationDefinition(data.DefinitionId); int availableDecorationCount = sceneManipulationService.GetAvailableDecorationCount(data.DefinitionId); if (decorationDefinition != null && availableDecorationCount > 0) { sceneManipulationService.AddNewObject(decorationDefinition.Prefab, zero + vector, identity, one, data, setManipulationInputStateToDrag: false); } } else { StructureDefinition structureDefinition = Service.Get <DecorationInventoryService>().GetStructureDefinition(data.DefinitionId); int availableDecorationCount = sceneManipulationService.GetAvailableStructureCount(data.DefinitionId); if (structureDefinition != null && availableDecorationCount > 0) { sceneManipulationService.AddNewObject(structureDefinition.Prefab, zero + Vector3.right, identity, one, data, setManipulationInputStateToDrag: false); } } } return(false); }
public void AddNewObject(PrefabContentKey prefabContentKey, Vector3 worldPosition, Quaternion rotation, Vector3 scale, DecorationLayoutData data, bool setManipulationInputStateToDrag = true) { if (data.Type == DecorationLayoutData.DefinitionType.Decoration) { decorationInventoryService.MarkDecorationsDirty(); } else if (data.Type == DecorationLayoutData.DefinitionType.Structure) { decorationInventoryService.MarkStructuresDirty(); } prefabCacheTracker.Acquire(prefabContentKey, delegate(GameObject prefab, PrefabCacheTracker.PrefabRequest request) { onNewObjectLoaded(prefab, request, worldPosition, rotation, scale, data, setManipulationInputStateToDrag); }); }
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 onNewObjectLoaded(GameObject prefab, PrefabCacheTracker.PrefabRequest request, Vector3 worldPosition, Quaternion rotation, Vector3 scale, DecorationLayoutData data, bool setManipulationInputStateToDrag) { if (prefab == null) { Log.LogErrorFormatted(this, "Prefab was null"); return; } GameObject gameObject = UnityEngine.Object.Instantiate(prefab, sceneLayoutContainer); if (gameObject == null) { Log.LogErrorFormatted(this, "Instantiate returned a null game object for prefab {0}", prefab); return; } isNewObject = true; prefabCacheTracker.SetCache(gameObject, request.ContentKey); gameObject.transform.position = worldPosition; gameObject.transform.rotation = rotation; gameObject.transform.localScale = scale; ManipulatableObject arg = addObjectManipulator(gameObject, data); ObjectManipulationInputController.SelectState setSelectStateTo = ((!setManipulationInputStateToDrag) ? ObjectManipulationInputController.SelectState.Active : ObjectManipulationInputController.SelectState.Drag); if (ObjectManipulationInputController != null) { ObjectManipulationInputController.SelectNewObject(gameObject, setSelectStateTo); } SplittableObject component = gameObject.GetComponent <SplittableObject>(); if (component != null) { if (SceneLayoutData.LayoutCount >= SceneLayoutData.MaxLayoutItems - 2) { UnityEngine.Object.Destroy(gameObject); ResetAfterMaxReached(); } else { component.SetObjectManipulationController(ObjectManipulationInputController); component.ChildrenSplit += onSplittableObjectChildrenSplit; } } selectedObjectStartingId = null; this.NewObjectCreated.InvokeSafe(arg); }
public void AddNewObject(PrefabContentKey prefabContentKey, Vector2 finalTouchPosition, DecorationLayoutData data, bool setManipulationInputStateToDrag = true) { Vector3 worldPosition = Camera.main.ScreenToWorldPoint(new Vector3(finalTouchPosition.x, finalTouchPosition.y, 0f)); AddNewObject(prefabContentKey, worldPosition, Quaternion.identity, Vector3.one, data, setManipulationInputStateToDrag); }