Пример #1
0
        public Object Unwrap(Object customObject)
        {
            if (customObject == null)
            {
                return(null);
            }

            customObject.heldObject = Unwrap(customObject.heldObject);

            var customType = TryGetType(customObject);

            if (customObject.GetType() != customType)
            {
                return(customObject);
            }

            IConstructor <Object> basicCtor;

            switch (customObject)
            {
            case Furniture furniture:
                basicCtor = GetBasicCtor <Furniture>();
                break;

            default:
                basicCtor = GetBasicCtor <Object>();
                break;
            }

            var basicObject = basicCtor.Invoke();

            Cloner.Instance.CopyData(customObject, basicObject);
            return(basicObject);
        }
Пример #2
0
        /// <summary>
        /// Gets a dimension offset depending on the size of the object passed in.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static Vector2 GetDimensionOffsetFromItem(StardewValley.Object obj)
        {
            if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), obj.GetType()))
            {
                return(new Vector2(64f, 64f));
            }

            return(new Vector2(64f, 64f));
        }
Пример #3
0
        /// <summary>
        /// Gets a dimension offset depending on the size of the object passed in.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static Vector2 GetDimensionOffsetFromItem(StardewValley.Object obj)
        {
            if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), obj.GetType()))
            {
                return(new Vector2(64f, 64f));
            }
            if (ObjectUtilities.IsSameType(typeof(Revitalize.Framework.Objects.MultiTiledObject), obj.GetType()))
            {
                return(new Vector2(64f * (obj as MultiTiledObject).Width, 64f * (obj as MultiTiledObject).Height));
            }

            return(new Vector2(64f, 64f));
        }
Пример #4
0
        public Object Wrap(Object basicObject)
        {
            if (basicObject == null)
            {
                return(null);
            }

            basicObject.heldObject = Wrap(basicObject.heldObject);

            var customType = TryGetType(basicObject);

            if (customType == null || basicObject.GetType() == customType)
            {
                return(basicObject);
            }

            var customCtor   = CustomTypeConstructors.GetOrAddValue(customType, () => new Constructor <int, Object>(customType));
            var customObject = customCtor.Invoke(basicObject.ParentSheetIndex);

            Cloner.Instance.CopyData(basicObject, customObject);
            (customObject as IInitializable)?.Initialize();
            return(customObject);
        }