2016-03-01 14:35:52 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics.Eventing.Reader;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
using StardewValley;
|
|
|
|
|
using StardewValley.BellsAndWhistles;
|
|
|
|
|
|
|
|
|
|
namespace StardewModdingAPI.Inheritance
|
|
|
|
|
{
|
2016-03-03 11:54:37 +08:00
|
|
|
|
[Obsolete]
|
2016-03-01 14:35:52 +08:00
|
|
|
|
public class SGameLocation : GameLocation
|
|
|
|
|
{
|
|
|
|
|
public GameLocation BaseGameLocation { get; private set; }
|
|
|
|
|
|
|
|
|
|
public SerializableDictionary<Vector2, SObject> ModObjects { get; set; }
|
|
|
|
|
|
2016-03-03 01:24:15 +08:00
|
|
|
|
public static SGameLocation ConstructFromBaseClass(GameLocation baseClass, bool copyAllData = false)
|
2016-03-01 14:35:52 +08:00
|
|
|
|
{
|
|
|
|
|
SGameLocation s = new SGameLocation();
|
|
|
|
|
s.BaseGameLocation = baseClass;
|
2016-03-03 01:24:15 +08:00
|
|
|
|
s.name = baseClass.name;
|
|
|
|
|
|
2016-03-05 14:32:04 +08:00
|
|
|
|
Log.Debug("CONSTRUCTED: " + s.name);
|
2016-03-02 08:36:12 +08:00
|
|
|
|
|
2016-03-03 01:24:15 +08:00
|
|
|
|
if (copyAllData)
|
2016-03-02 08:36:12 +08:00
|
|
|
|
{
|
2016-03-03 01:24:15 +08:00
|
|
|
|
foreach (var v in baseClass.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
|
2016-03-02 08:36:12 +08:00
|
|
|
|
{
|
2016-03-03 01:24:15 +08:00
|
|
|
|
try
|
2016-03-02 08:36:12 +08:00
|
|
|
|
{
|
2016-03-03 01:24:15 +08:00
|
|
|
|
var fi = s.GetType().GetField(v.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
if (fi != null && !fi.IsStatic)
|
|
|
|
|
{
|
|
|
|
|
fi.SetValue(s, v.GetValue(baseClass));
|
|
|
|
|
//Console.WriteLine("SET {0} ON {1} TO {2}", fi.Name, s.name, v.GetValue(baseClass));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2016-03-05 14:32:04 +08:00
|
|
|
|
Log.Error(ex);
|
2016-03-02 08:36:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-01 14:35:52 +08:00
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 01:24:15 +08:00
|
|
|
|
public static List<SGameLocation> ConstructFromBaseClasses(List<GameLocation> baseGameLocations, bool copyAllData = false)
|
2016-03-01 14:35:52 +08:00
|
|
|
|
{
|
2016-03-03 01:24:15 +08:00
|
|
|
|
return baseGameLocations.Select(gl => ConstructFromBaseClass(gl, copyAllData)).ToList();
|
2016-03-01 14:35:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void update(GameTime gameTime)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void draw(SpriteBatch b)
|
|
|
|
|
{
|
|
|
|
|
foreach (var v in ModObjects)
|
|
|
|
|
{
|
2016-03-01 15:16:35 +08:00
|
|
|
|
v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, 0.999f, 1);
|
2016-03-01 14:35:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-03 01:24:15 +08:00
|
|
|
|
|
|
|
|
|
public SGameLocation()
|
|
|
|
|
{
|
|
|
|
|
ModObjects = new SerializableDictionary<Vector2, SObject>();
|
|
|
|
|
}
|
2016-03-01 14:35:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|