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());
 }
示例#2
0
        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);
        }