Fixed the light manager not handling removing lights properly. Also have it so now alll CustomObjects handle lights.

This commit is contained in:
JoshuaNavarro 2019-05-17 09:43:50 -07:00
parent 05aeabed12
commit 6c02af4596
13 changed files with 516 additions and 114 deletions

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Revitalize.Framework.Objects;
namespace Revitalize.Framework.Factories.Objects.Furniture
{
public class FactoryInfo
{
public BasicItemInformation info;
public FactoryInfo()
{
}
public FactoryInfo(MultiTiledObject obj)
{
this.info = obj.info;
}
public FactoryInfo(MultiTiledComponent component)
{
this.info = component.info;
}
}
}

View File

@ -9,10 +9,9 @@ using Revitalize.Framework.Objects.InformationFiles.Furniture;
namespace Revitalize.Framework.Factories.Objects.Furniture namespace Revitalize.Framework.Factories.Objects.Furniture
{ {
public class ChairFactoryInfo public class ChairFactoryInfo:FactoryInfo
{ {
public ChairInformation chairInfo; public ChairInformation chairInfo;
public BasicItemInformation itemInfo;
public ChairFactoryInfo() public ChairFactoryInfo()
{ {
@ -22,13 +21,13 @@ namespace Revitalize.Framework.Factories.Objects.Furniture
public ChairFactoryInfo(ChairMultiTiledObject chair) public ChairFactoryInfo(ChairMultiTiledObject chair)
{ {
this.chairInfo = null; this.chairInfo = null;
this.itemInfo = chair.info; this.info = chair.info;
} }
public ChairFactoryInfo(ChairTileComponent chair) public ChairFactoryInfo(ChairTileComponent chair)
{ {
this.chairInfo = chair.furnitureInfo; this.chairInfo = chair.furnitureInfo;
this.itemInfo = chair.info; this.info = chair.info;
} }
} }

View File

@ -37,6 +37,10 @@ namespace Revitalize.Framework.Factories.Objects
DeserializeTableFiles(); DeserializeTableFiles();
} }
private static void SerializeLamps()
{
LampTileComponent lampTop = new LampTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Chairs.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager()));
}
private static void SerializeChairs() private static void SerializeChairs()
@ -149,7 +153,7 @@ namespace Revitalize.Framework.Factories.Objects
if ((Path.GetFileName(file)).Contains("_")==true) continue; if ((Path.GetFileName(file)).Contains("_")==true) continue;
else else
{ {
chairObjects.Add(Path.GetFileNameWithoutExtension(file), new ChairMultiTiledObject(ModCore.Serializer.DeserializeContentFile<ChairFactoryInfo>(file).itemInfo)); chairObjects.Add(Path.GetFileNameWithoutExtension(file), new ChairMultiTiledObject(ModCore.Serializer.DeserializeContentFile<ChairFactoryInfo>(file).info));
} }
} }
//Deseralize components //Deseralize components
@ -163,7 +167,7 @@ namespace Revitalize.Framework.Factories.Objects
string name = splits[0]; string name = splits[0];
Vector2 offset = new Vector2(Convert.ToInt32(splits[1]), Convert.ToInt32(splits[2])); Vector2 offset = new Vector2(Convert.ToInt32(splits[1]), Convert.ToInt32(splits[2]));
ChairFactoryInfo info = ModCore.Serializer.DeserializeContentFile<ChairFactoryInfo>(file); ChairFactoryInfo info = ModCore.Serializer.DeserializeContentFile<ChairFactoryInfo>(file);
chairObjects[name].addComponent(offset, new ChairTileComponent(info.itemInfo, info.chairInfo)); chairObjects[name].addComponent(offset, new ChairTileComponent(info.info, info.chairInfo));
} }
} }
foreach (var v in chairObjects) foreach (var v in chairObjects)

View File

@ -9,9 +9,8 @@ using Revitalize.Framework.Objects.InformationFiles.Furniture;
namespace Revitalize.Framework.Factories.Objects.Furniture namespace Revitalize.Framework.Factories.Objects.Furniture
{ {
public class TableFactoryInfo public class TableFactoryInfo:FactoryInfo
{ {
public BasicItemInformation info;
public TableInformation tableInfo; public TableInformation tableInfo;

View File

@ -10,6 +10,8 @@ namespace Revitalize.Framework.Illuminate
public Dictionary<Vector2, LightSource> lights; public Dictionary<Vector2, LightSource> lights;
public bool lightsOn; public bool lightsOn;
public const int lightBigNumber= 1000000;
public LightManager() public LightManager()
{ {
this.lights = new Dictionary<Vector2, LightSource>(); this.lights = new Dictionary<Vector2, LightSource>();
@ -38,7 +40,7 @@ namespace Revitalize.Framework.Illuminate
this.lights.TryGetValue(IdKey, out LightSource light); this.lights.TryGetValue(IdKey, out LightSource light);
Game1.currentLightSources.Remove(light); Game1.currentLightSources.Remove(light);
location.sharedLights.Remove((int)IdKey.X * 1000000 + (int)IdKey.Y); location.sharedLights.Remove((int)IdKey.X * lightBigNumber + (int)IdKey.Y);
return true; return true;
} }
@ -61,7 +63,7 @@ namespace Revitalize.Framework.Illuminate
Game1.showRedMessage("TURN ON!"); Game1.showRedMessage("TURN ON!");
Game1.currentLightSources.Add(light); Game1.currentLightSources.Add(light);
location.sharedLights.Add((int)IdKey.X*10000+(int)IdKey.Y,light); location.sharedLights.Add((int)IdKey.X*lightBigNumber+(int)IdKey.Y,light);
this.repositionLight(light, IdKey, gameObject); this.repositionLight(light, IdKey, gameObject);
return true; return true;
} }
@ -101,12 +103,19 @@ namespace Revitalize.Framework.Illuminate
{ {
this.turnOnLights(location, gameObject); this.turnOnLights(location, gameObject);
this.lightsOn = true; this.lightsOn = true;
return;
} }
else if (this.lightsOn) else if (this.lightsOn)
{ {
this.turnOffLights(Game1.player.currentLocation); this.turnOffLights(Game1.player.currentLocation);
this.lightsOn = false; this.lightsOn = false;
} return;
}
}
public virtual void removeForCleanUp(GameLocation loc)
{
this.turnOffLights(loc);
} }
} }
} }

View File

@ -49,7 +49,6 @@ namespace Revitalize.Framework.Objects
} }
set set
{ {
Revitalize.ModCore.log("GUESS SERIALIZATION IS WORKING???");
this.info =(BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(value, typeof(BasicItemInformation)); this.info =(BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(value, typeof(BasicItemInformation));
} }
} }
@ -61,9 +60,7 @@ namespace Revitalize.Framework.Objects
/// <summary>Empty constructor.</summary> /// <summary>Empty constructor.</summary>
public CustomObject() { public CustomObject() {
this.guid = Guid.NewGuid(); this.guid = Guid.NewGuid();
ModCore.log("Created new obj with guid: " + this.guid);
this.InitNetFields(); this.InitNetFields();
ModCore.log(System.Environment.StackTrace);
} }
/// <summary>Construct an instance.</summary> /// <summary>Construct an instance.</summary>
@ -73,8 +70,7 @@ namespace Revitalize.Framework.Objects
this.info = info; this.info = info;
this.initializeBasics(); this.initializeBasics();
this.guid = Guid.NewGuid(); this.guid = Guid.NewGuid();
ModCore.log("Created new obj with guid: " + this.guid);
ModCore.log(System.Environment.StackTrace);
} }
/// <summary>Construct an instance.</summary> /// <summary>Construct an instance.</summary>
@ -84,8 +80,7 @@ namespace Revitalize.Framework.Objects
this.info = info; this.info = info;
this.initializeBasics(); this.initializeBasics();
this.guid = Guid.NewGuid(); this.guid = Guid.NewGuid();
ModCore.log("Created new obj with guid: " + this.guid);
ModCore.log(System.Environment.StackTrace);
} }
/// <summary>Sets some basic information up.</summary> /// <summary>Sets some basic information up.</summary>
@ -258,7 +253,7 @@ namespace Revitalize.Framework.Objects
public override bool canBePlacedHere(GameLocation l, Vector2 tile) public override bool canBePlacedHere(GameLocation l, Vector2 tile)
{ {
if (this.info.ignoreBoundingBox) return true; if (this.info.ignoreBoundingBox && l.isObjectAtTile((int)tile.X,(int)tile.Y)==false) return true;
return base.canBePlacedHere(l, tile); return base.canBePlacedHere(l, tile);
} }

View File

@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using PyTK.CustomElementHandler;
using StardewValley;
namespace Revitalize.Framework.Objects.Furniture
{
public class LampMultiTiledObject:MultiTiledObject
{
public LampMultiTiledObject() : base()
{
}
public LampMultiTiledObject(BasicItemInformation Info) : base(Info)
{
}
public LampMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition) : base(Info, TilePosition)
{
}
public LampMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition, Dictionary<Vector2, MultiTiledComponent> Objects) : base(Info, TilePosition, Objects)
{
}
public override void rotate()
{
base.rotate();
}
public override Item getOne()
{
Dictionary<Vector2, MultiTiledComponent> objs = new Dictionary<Vector2, MultiTiledComponent>();
foreach (var pair in this.objects)
{
objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne());
}
return new LampMultiTiledObject(this.info, this.TileLocation, objs);
}
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
{
LampMultiTiledObject obj = (LampMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<LampMultiTiledObject>(additionalSaveData["GUID"]);
if (obj == null)
{
return null;
}
Dictionary<Vector2, Guid> guids = new Dictionary<Vector2, Guid>();
foreach (KeyValuePair<Vector2, Guid> pair in obj.childrenGuids)
{
guids.Add(pair.Key, pair.Value);
}
foreach (KeyValuePair<Vector2, Guid> pair in guids)
{
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<LampTileComponent>(pair.Value.ToString());
component.InitNetFields();
obj.addComponent(pair.Key, component);
}
obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj);
return obj;
}
else
{
return Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]];
}
}
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
{
return base.canBePlacedHere(l, tile);
}
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
{
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
{
if (!this.isPlaceable())
return;
int x = Game1.getOldMouseX() + Game1.viewport.X + (int)((pair.Value as MultiTiledComponent).offsetKey.X * Game1.tileSize);
int y = Game1.getOldMouseY() + Game1.viewport.Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y * Game1.tileSize);
if ((double)Game1.mouseCursorTransparency == 0.0)
{
x = ((int)Game1.player.GetGrabTile().X + (int)((pair.Value as MultiTiledComponent).offsetKey.X)) * 64;
y = ((int)Game1.player.GetGrabTile().Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y)) * 64;
}
if (Game1.player.GetGrabTile().Equals(Game1.player.getTileLocation()) && (double)Game1.mouseCursorTransparency == 0.0)
{
Vector2 translatedVector2 = Utility.getTranslatedVector2(Game1.player.GetGrabTile(), Game1.player.FacingDirection, 1f);
translatedVector2 += (pair.Value as MultiTiledComponent).offsetKey;
x = (int)translatedVector2.X * 64;
y = (int)translatedVector2.Y * 64;
}
bool flag = (pair.Value as MultiTiledComponent).canBePlacedHere(location, new Vector2(x / Game1.tileSize, y / Game1.tileSize));
spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f);
(pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f);
//break;
//this.draw(spriteBatch, x / 64, y / 64, 0.5f);
}
}
public override void pickUp()
{
bool canPickUp = this.removeAndAddToPlayersInventory();
if (canPickUp)
{
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
{
(pair.Value as LampTileComponent).removeFromLocation((pair.Value as LampTileComponent).location, pair.Key);
}
this.location = null;
}
else
Game1.showRedMessage("NOOOOOOOO");
}
}
}

View File

@ -0,0 +1,253 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using PyTK.CustomElementHandler;
using Revitalize.Framework.Illuminate;
using Revitalize.Framework.Utilities.Serialization;
using StardewValley;
namespace Revitalize.Framework.Objects.Furniture
{
public class LampTileComponent:FurnitureTileComponent
{
public bool canTurnOn
{
get
{
return this.info.lightManager != null;
}
}
public LightManager lights
{
get
{
return this.info.lightManager;
}
}
public LampTileComponent() : base()
{
}
public LampTileComponent(BasicItemInformation Info) : base(Info)
{
}
public LampTileComponent(BasicItemInformation Info, Vector2 TileLocation) : base(Info, TileLocation)
{
}
/// <summary>
/// Forcefully clears the held object without much fuss.
/// </summary>
public void clearHeldObject()
{
if (this.heldObject.Value != null)
{
if (Game1.player.isInventoryFull() == false)
{
Game1.player.addItemToInventoryBool(this.heldObject.Value, false);
this.heldObject.Value = null;
return;
}
else
{
Game1.createItemDebris(this.heldObject.Value, Vector2.Zero, 0);
}
}
}
public override bool performObjectDropInAction(Item dropInItem, bool probe, Farmer who)
{
return false; //this.pickUpItem()==PickUpState.DoNothing;
//return base.performObjectDropInAction(dropInItem, probe, who);
}
public override bool performDropDownAction(Farmer who)
{
return base.performDropDownAction(who);
}
//Checks for any sort of interaction IF and only IF there is a held object on this tile.
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
{
MouseState mState = Mouse.GetState();
KeyboardState keyboardState = Game1.GetKeyboardState();
if (mState.RightButton == ButtonState.Pressed && (!keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift)))
{
return this.rightClicked(who);
}
if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift)))
return this.shiftRightClicked(who);
//return base.checkForAction(who, justCheckingForActivity);
if (justCheckingForActivity)
return true;
return true;
//return this.clicked(who);
//return false;
}
public override bool performToolAction(Tool t, GameLocation location)
{
return base.performToolAction(t, location);
}
public override bool performUseAction(GameLocation location)
{
return base.performUseAction(location);
}
/// <summary>
/// Gets called when there is no actively held item on the tile.
/// </summary>
/// <param name="who"></param>
/// <returns></returns>
public override bool clicked(Farmer who)
{
return base.clicked(who);
}
public override bool rightClicked(Farmer who)
{
if (this.canTurnOn)
{
this.info.lightManager.toggleLights(this.location, this);
return true;
}
return false;
}
public override bool shiftRightClicked(Farmer who)
{
return base.shiftRightClicked(who);
}
public override Item getOne()
{
LampTileComponent component = new LampTileComponent(this.info);
component.containerObject = this.containerObject;
component.offsetKey = this.offsetKey;
return component;
}
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
{
//instead of using this.offsetkey.x use get additional save data function and store offset key there
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
LampTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID<LampTileComponent>(additionalSaveData["GUID"]);
if (self == null)
{
return null;
}
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
{
//Get new container
LampMultiTiledObject obj = (LampMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<LampMultiTiledObject>(additionalSaveData["ParentGUID"]);
self.containerObject = obj;
obj.addComponent(offsetKey, self);
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
}
else
{
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
}
return (ICustomObject)self;
}
public override Dictionary<string, string> getAdditionalSaveData()
{
Dictionary<string, string> saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
return saveData;
}
/// <summary>What happens when the object is drawn at a tile location.</summary>
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{
/*
if (this.info.ignoreBoundingBox == true)
{
x *= -1;
y *= -1;
}
*/
if (this.info == null)
{
Revitalize.ModCore.log("info is null");
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
}
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
//The actual planter box being drawn.
if (this.animationManager == null)
{
if (this.animationManager.getExtendedTexture() == null)
ModCore.ModMonitor.Log("Tex Extended is null???");
spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f));
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
}
else
{
//Log.AsyncC("Animation Manager is working!");
float addedDepth = 0;
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up)
{
addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y));
if (this.info.ignoreBoundingBox) addedDepth += 1.5f;
}
else if (this.info.ignoreBoundingBox)
{
addedDepth += 1.0f;
}
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f);
try
{
this.animationManager.tickAnimation();
// Log.AsyncC("Tick animation");
}
catch (Exception err)
{
ModCore.ModMonitor.Log(err.ToString());
}
if (this.heldObject.Value != null) SpriteBatchUtilities.Draw(spriteBatch, this, this.heldObject.Value, alpha, addedDepth);
}
// spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
}
}
}

View File

@ -55,13 +55,10 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
if (this.heldObject.Value != null) if (this.heldObject.Value != null)
{ {
ModCore.log("Help the held object!");
if (Game1.player.isInventoryFull() == false) if (Game1.player.isInventoryFull() == false)
{ {
Game1.player.addItemToInventoryBool(this.heldObject.Value, false); Game1.player.addItemToInventoryBool(this.heldObject.Value, false);
this.heldObject.Value = null; this.heldObject.Value = null;
ModCore.log("Recover item");
return; return;
} }
else else
@ -69,10 +66,6 @@ namespace Revitalize.Framework.Objects.Furniture
Game1.createItemDebris(this.heldObject.Value, Vector2.Zero, 0); Game1.createItemDebris(this.heldObject.Value, Vector2.Zero, 0);
} }
} }
else
{
ModCore.log("Why is there no held object here???");
}
} }
/// <summary> /// <summary>
@ -88,22 +81,6 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
this.heldObject.Value = (StardewValley.Object)Game1.player.ActiveObject.getOne(); this.heldObject.Value = (StardewValley.Object)Game1.player.ActiveObject.getOne();
Game1.player.reduceActiveItemByOne(); Game1.player.reduceActiveItemByOne();
ModCore.log("My guid: "+this.guid);
ModCore.log("Container guid: " + this.containerObject.guid);
foreach (var v in this.containerObject.objects)
{
if (v.Value.heldObject.Value != null) ModCore.log("Found a keeper to put down!");
else
{
ModCore.log("Nothing here seriously");
}
if (v.Value == this) ModCore.log("I AM PRESENT!");
ModCore.log("Other guid: " + (v.Value as TableTileComponent).guid);
}
} }
return PickUpState.DoNothing; return PickUpState.DoNothing;
} }
@ -166,7 +143,6 @@ namespace Revitalize.Framework.Objects.Furniture
if (justCheckingForActivity) if (justCheckingForActivity)
return true; return true;
ModCore.log("Check for action");
this.pickUpItem(false); this.pickUpItem(false);
return true; return true;
@ -176,13 +152,11 @@ namespace Revitalize.Framework.Objects.Furniture
public override bool performToolAction(Tool t, GameLocation location) public override bool performToolAction(Tool t, GameLocation location)
{ {
ModCore.log("Perform tool action");
return base.performToolAction(t, location); return base.performToolAction(t, location);
} }
public override bool performUseAction(GameLocation location) public override bool performUseAction(GameLocation location)
{ {
ModCore.log("Perform use action");
return base.performUseAction(location); return base.performUseAction(location);
} }
@ -194,19 +168,7 @@ namespace Revitalize.Framework.Objects.Furniture
public override bool clicked(Farmer who) public override bool clicked(Farmer who)
{ {
if (this.pickUpItem() == PickUpState.DoNothing) return false; if (this.pickUpItem() == PickUpState.DoNothing) return false;
ModCore.log("Clicked!");
foreach(var v in this.containerObject.objects)
{
if (v.Value.heldObject.Value != null) ModCore.log("Found a keeper!");
else
{
ModCore.log("Already null!");
}
}
///Not sure.
return base.clicked(who); return base.clicked(who);
//return base.rightClicked(who);
} }

View File

@ -52,7 +52,7 @@ namespace Revitalize.Framework.Objects
{ {
if (this.location == null) if (this.location == null)
this.location = Game1.player.currentLocation; this.location = Game1.player.currentLocation;
//this.info.lightManager.toggleLights(this.location, this); if(this.info.lightManager!=null)this.info.lightManager.toggleLights(this.location, this);
//ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero);
@ -69,11 +69,17 @@ namespace Revitalize.Framework.Objects
public virtual void removeFromLocation(GameLocation location, Vector2 offset) public virtual void removeFromLocation(GameLocation location, Vector2 offset)
{ {
this.cleanUpLights();
location.removeObject(this.TileLocation, false); location.removeObject(this.TileLocation, false);
this.location = null; this.location = null;
//this.performRemoveAction(this.TileLocation,location); //this.performRemoveAction(this.TileLocation,location);
} }
public virtual void cleanUpLights()
{
if (this.info.lightManager != null) this.info.lightManager.removeForCleanUp(this.location);
}
/// <summary>Places an object down.</summary> /// <summary>Places an object down.</summary>
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
{ {
@ -85,7 +91,7 @@ namespace Revitalize.Framework.Objects
/* /*
return base.placementAction(location, x, y, who); return base.placementAction(location, x, y, who);
*/ */
//this.updateLightManager();
this.performDropDownAction(who); this.performDropDownAction(who);
location.objects.Add(this.TileLocation, this); location.objects.Add(this.TileLocation, this);
@ -93,6 +99,7 @@ namespace Revitalize.Framework.Objects
} }
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
{ {
if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1)

View File

@ -65,9 +65,7 @@ namespace Revitalize.Framework.Objects
this.childrenGuids = new Dictionary<Vector2, Guid>(); this.childrenGuids = new Dictionary<Vector2, Guid>();
foreach (var v in ObjectsList) foreach (var v in ObjectsList)
{ {
ModCore.log("Original GUID: "+(v.Value as CustomObject).guid);
MultiTiledComponent component = (MultiTiledComponent)v.Value.getOne(); MultiTiledComponent component = (MultiTiledComponent)v.Value.getOne();
ModCore.log("Altered GUID: " + component.guid);
this.addComponent(v.Key, component); this.addComponent(v.Key, component);
} }
@ -179,7 +177,18 @@ namespace Revitalize.Framework.Objects
if (canPickUp) if (canPickUp)
{ {
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects) foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
{
if ((pair.Value as MultiTiledComponent).info.lightManager != null)
{
ModCore.log("Let there be light.");
if ((pair.Value as MultiTiledComponent).info.lightManager.lightsOn == true)
{
ModCore.log("Got a light???");
}
}
(pair.Value as MultiTiledComponent).removeFromLocation((pair.Value as MultiTiledComponent).location, pair.Key); (pair.Value as MultiTiledComponent).removeFromLocation((pair.Value as MultiTiledComponent).location, pair.Key);
}
this.location = null; this.location = null;
} }
else else

View File

@ -24,10 +24,7 @@ namespace Revitalize
//Bugs: //Bugs:
// -Chair tops cut off objects // -Chair tops cut off objects
// -ignoring bounding box cuts off objects
// -Tables don't draw their held objects
// -load content MUST be enabled for the table to be placed?????? WTF // -load content MUST be enabled for the table to be placed?????? WTF
// -multitiledobject cs 213 in placementAction must have special logic so that new components aren't being placed
// TODO: // TODO:
// //
// //
@ -35,8 +32,8 @@ namespace Revitalize
// -Multiple Lights On Object // -Multiple Lights On Object
// -Illumination Colors // -Illumination Colors
// Furniture: // Furniture:
// -rugs (WIP but buggy for clicking) // -rugs (done, needs factory info/sprite)
// -tables // -tables (done)
// -lamps // -lamps
// -chairs (done) // -chairs (done)
// -benches (done but needs factory info/sprite) // -benches (done but needs factory info/sprite)
@ -168,12 +165,12 @@ namespace Revitalize
MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null)); MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null));
//obj.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj); obj3.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj);
MultiTiledObject bigObject = new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White, false, null, null)); MultiTiledObject bigObject = new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White, false, null, null));
//bigObject.addComponent(new Vector2(0, 0), obj); bigObject.addComponent(new Vector2(0, 0), obj);
//bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(1, 0), obj2);
//bigObject.addComponent(new Vector2(2, 0), obj3); bigObject.addComponent(new Vector2(2, 0), obj3);
Recipe pie = new Recipe(new Dictionary<Item, int>() Recipe pie = new Recipe(new Dictionary<Item, int>()
{ {
@ -231,7 +228,7 @@ namespace Revitalize
{ {
throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!"); throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!");
} }
//Game1.player.addItemToInventory(customObjects["Omegasis.BigTiledTest"].getOne()); Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest"));
Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Tables.OakTable")); Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Tables.OakTable"));
@ -248,20 +245,7 @@ namespace Revitalize
{ {
if (customObjects.ContainsKey(objName)) if (customObjects.ContainsKey(objName))
{ {
CustomObject i =(CustomObject)customObjects[objName].getOne();
TableMultiTiledObject old = (TableMultiTiledObject)customObjects[objName];
ModCore.log("Old GUID:" + old.guid);
foreach (var v in old.objects)
{
log("OLD GUID PART: "+(v.Value as TableTileComponent).guid);
}
TableMultiTiledObject i =(TableMultiTiledObject)customObjects[objName].getOne();
foreach (var v in i.objects)
{
log("OLD GUID PART: " + (v.Value as TableTileComponent).guid);
}
ModCore.log("New GUID:" + i.guid);
return i; return i;
} }
else else

View File

@ -54,8 +54,9 @@
<Compile Include="Framework\Enums\Enums.cs" /> <Compile Include="Framework\Enums\Enums.cs" />
<Compile Include="Framework\Environment\DarkerNight.cs" /> <Compile Include="Framework\Environment\DarkerNight.cs" />
<Compile Include="Framework\Environment\DarkerNightConfig.cs" /> <Compile Include="Framework\Environment\DarkerNightConfig.cs" />
<Compile Include="Framework\Factories\Objects\FurnitureFactory.cs" /> <Compile Include="Framework\Factories\Objects\Furniture\FurnitureFactory.cs" />
<Compile Include="Framework\Factories\Objects\Furniture\ChairFactoryInfo.cs" /> <Compile Include="Framework\Factories\Objects\Furniture\ChairFactoryInfo.cs" />
<Compile Include="Framework\Factories\Objects\FactoryInfo.cs" />
<Compile Include="Framework\Factories\Objects\Furniture\TableFactoryInfo.cs" /> <Compile Include="Framework\Factories\Objects\Furniture\TableFactoryInfo.cs" />
<Compile Include="Framework\Graphics\Animations\Animation.cs" /> <Compile Include="Framework\Graphics\Animations\Animation.cs" />
<Compile Include="Framework\Graphics\Animations\AnimationManager.cs" /> <Compile Include="Framework\Graphics\Animations\AnimationManager.cs" />
@ -70,6 +71,8 @@
<Compile Include="Framework\Objects\Furniture\ChairTileComponent.cs" /> <Compile Include="Framework\Objects\Furniture\ChairTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\CustomFurniture.cs" /> <Compile Include="Framework\Objects\Furniture\CustomFurniture.cs" />
<Compile Include="Framework\Objects\Furniture\FurnitureTileComponent.cs" /> <Compile Include="Framework\Objects\Furniture\FurnitureTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\LampMultiTiledObject.cs" />
<Compile Include="Framework\Objects\Furniture\LampTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\RugMultiTiledObject.cs" /> <Compile Include="Framework\Objects\Furniture\RugMultiTiledObject.cs" />
<Compile Include="Framework\Objects\Furniture\RugTileComponent.cs" /> <Compile Include="Framework\Objects\Furniture\RugTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\TableMultiTiledObject.cs" /> <Compile Include="Framework\Objects\Furniture\TableMultiTiledObject.cs" />