Example #1
0
        public static GameLocation makeClone(GameLocation source)
        {
            Type type = source.GetType();

            DoLog.Log("Location was of type " + type.ToString(), 0);
            ConstructorInfo constructor = type.GetConstructor(new Type[]
            {
                typeof(string),
                typeof(string)
            });
            bool flag = constructor != null;

            if (flag)
            {
                DoLog.Log("Found a (string, string) constructor.  Invoking...", 0);
                try
                {
                    GameLocation gameLocation = constructor.Invoke(new object[]
                    {
                        source.mapPath.Value,
                        source.Name
                    }) as GameLocation;
                    DoLog.Log("Constructed location was of type " + gameLocation.GetType().ToString(), 0);
                    gameLocation.DayUpdate(Game1.dayOfMonth);
                    return(gameLocation);
                }
                catch (Exception)
                {
                }
            }
            ConstructorInfo constructor2 = type.GetConstructor(new Type[0]);
            bool            flag2        = constructor2 != null;
            GameLocation    result;

            if (flag2)
            {
                DoLog.Log("Found an empty constructor.  Invoking...", 0);
                GameLocation gameLocation2 = constructor2.Invoke(new object[0]) as GameLocation;
                DoLog.Log("Constructed location was of type " + gameLocation2.GetType().ToString(), 0);
                gameLocation2.loadObjects();
                gameLocation2.DayUpdate(Game1.dayOfMonth);
                result = gameLocation2;
            }
            else
            {
                DoLog.Log("Could not construct the location.  Defaulting to GameLocation class...", 0);
                result = new GameLocation(source.mapPath.Value, source.Name);
            }
            return(result);
        }