Added in charging station.
This commit is contained in:
parent
f93fac1637
commit
b76a5ef39d
Binary file not shown.
After Width: | Height: | Size: 616 B |
|
@ -0,0 +1,196 @@
|
||||||
|
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 Newtonsoft.Json;
|
||||||
|
using PyTK.CustomElementHandler;
|
||||||
|
using Revitalize.Framework.Energy;
|
||||||
|
using Revitalize.Framework.Objects.InformationFiles;
|
||||||
|
using Revitalize.Framework.Utilities;
|
||||||
|
using StardewValley;
|
||||||
|
using StardustCore.Animations;
|
||||||
|
using StardustCore.UIUtilities;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Objects.Machines
|
||||||
|
{
|
||||||
|
public class ChargingStation:Machine
|
||||||
|
{
|
||||||
|
|
||||||
|
public ChargingStation() { }
|
||||||
|
|
||||||
|
public ChargingStation(CustomObjectData PyTKData, BasicItemInformation info, List<ResourceInformation> ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info)
|
||||||
|
{
|
||||||
|
this.producedResources = ProducedResources ?? new List<ResourceInformation>();
|
||||||
|
this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes;
|
||||||
|
this.timeToProduce = TimeToProduce;
|
||||||
|
this.updatesContainerObjectForProduction = UpdatesContainer;
|
||||||
|
this.MinutesUntilReady = TimeToProduce;
|
||||||
|
this.craftingRecipeBook = CraftingBook;
|
||||||
|
this.createStatusBubble();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChargingStation(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List<ResourceInformation> ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null) : base(PyTKData, info, TileLocation)
|
||||||
|
{
|
||||||
|
this.containerObject = obj;
|
||||||
|
this.producedResources = ProducedResources ?? new List<ResourceInformation>();
|
||||||
|
this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes;
|
||||||
|
this.timeToProduce = TimeToProduce;
|
||||||
|
this.updatesContainerObjectForProduction = UpdatesContainer;
|
||||||
|
this.MinutesUntilReady = TimeToProduce;
|
||||||
|
this.craftingRecipeBook = CraftingBook;
|
||||||
|
this.createStatusBubble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChargingStation(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey, List<ResourceInformation> ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null) : base(PyTKData, info, TileLocation)
|
||||||
|
{
|
||||||
|
this.offsetKey = offsetKey;
|
||||||
|
this.containerObject = obj;
|
||||||
|
this.producedResources = ProducedResources ?? new List<ResourceInformation>();
|
||||||
|
this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes;
|
||||||
|
this.timeToProduce = TimeToProduce;
|
||||||
|
this.updatesContainerObjectForProduction = UpdatesContainer;
|
||||||
|
this.MinutesUntilReady = TimeToProduce;
|
||||||
|
this.craftingRecipeBook = CraftingBook;
|
||||||
|
this.createStatusBubble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
|
||||||
|
{
|
||||||
|
base.updateWhenCurrentLocation(time, environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool minutesElapsed(int minutes, GameLocation environment)
|
||||||
|
{
|
||||||
|
if (this.updatesContainerObjectForProduction)
|
||||||
|
{
|
||||||
|
//ModCore.log("Update container object for production!");
|
||||||
|
//this.MinutesUntilReady -= minutes;
|
||||||
|
int remaining = minutes;
|
||||||
|
//ModCore.log("Minutes elapsed: " + remaining);
|
||||||
|
List<MultiTiledObject> energySources = new List<MultiTiledObject>();
|
||||||
|
if (this.ConsumesEnergy || this.EnergyManager.energyInteractionType == Enums.EnergyInteractionType.Storage)
|
||||||
|
{
|
||||||
|
//ModCore.log("This machine drains energy: " + this.info.name);
|
||||||
|
energySources = this.EnergyGraphSearchSources(); //Only grab the network once.
|
||||||
|
}
|
||||||
|
this.drainEnergyFromNetwork(energySources);
|
||||||
|
foreach(Item I in this.InventoryManager.items)
|
||||||
|
{
|
||||||
|
if (I is null) continue;
|
||||||
|
if (I is CustomObject == false) continue;
|
||||||
|
IEnergyInterface o = (IEnergyInterface)I;
|
||||||
|
if (o.EnergyManager.canReceieveEnergy)
|
||||||
|
{
|
||||||
|
this.EnergyManager.transferEnergyToAnother(o.EnergyManager, Math.Min(this.EnergyManager.remainingEnergy, o.EnergyManager.capacityRemaining));
|
||||||
|
}
|
||||||
|
if (this.EnergyManager.hasEnergy == false) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override Item getOne()
|
||||||
|
{
|
||||||
|
ChargingStation component = new ChargingStation(this.data, this.info.Copy(), this.TileLocation, this.offsetKey, this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.containerObject);
|
||||||
|
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"]));
|
||||||
|
ChargingStation self = Revitalize.ModCore.Serializer.DeserializeGUID<ChargingStation>(additionalSaveData["GUID"]);
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||||
|
{
|
||||||
|
//Get new container
|
||||||
|
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledObject>(additionalSaveData["ParentGUID"]);
|
||||||
|
self.containerObject = obj;
|
||||||
|
obj.addComponent(offsetKey, self);
|
||||||
|
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||||
|
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)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 void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||||
|
{
|
||||||
|
this.updateInfo();
|
||||||
|
|
||||||
|
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);
|
||||||
|
this.drawStatusBubble(spriteBatch, x, y, alpha);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.animationManager.tickAnimation();
|
||||||
|
// Log.AsyncC("Tick animation");
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
ModCore.ModMonitor.Log(err.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -246,6 +246,18 @@ namespace Revitalize.Framework.Objects
|
||||||
capacitor.addComponent(new Vector2(0, 0), capacitor_0_0);
|
capacitor.addComponent(new Vector2(0, 0), capacitor_0_0);
|
||||||
this.AddItem("Capacitor", capacitor);
|
this.AddItem("Capacitor", capacitor);
|
||||||
|
|
||||||
|
|
||||||
|
MultiTiledObject chargingStation = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 0, 16, 16)), Color.White, false,new InventoryManager(4,4,1), null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)));
|
||||||
|
ChargingStation chargingStation_0_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, true, "");
|
||||||
|
ChargingStation chargingStation_1_0 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 0, 16, 16)), Color.White, true, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, "");
|
||||||
|
ChargingStation chargingStation_0_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, "");
|
||||||
|
ChargingStation chargingStation_1_1 = new ChargingStation(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.ChargingStation", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Charging Station", "Omegasis.Revitalize.Objects.Machines.ChargingStation", "A place to charge your tools and other electrical components.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ChargingStation"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ChargingStation"), new Animation(16, 16, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(2000, Enums.EnergyInteractionType.Storage)), null, 0, 0, false, "");
|
||||||
|
chargingStation.addComponent(new Vector2(0, 0), chargingStation_0_0);
|
||||||
|
chargingStation.addComponent(new Vector2(1, 0), chargingStation_1_0);
|
||||||
|
chargingStation.addComponent(new Vector2(0, 1), chargingStation_0_1);
|
||||||
|
chargingStation.addComponent(new Vector2(1, 1), chargingStation_1_1);
|
||||||
|
this.AddItem("ChargingStation", chargingStation);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadInWires()
|
private void loadInWires()
|
||||||
|
|
|
@ -568,7 +568,8 @@ namespace Revitalize
|
||||||
ModCore.ObjectManager.GetItem("Lighthouse",1),
|
ModCore.ObjectManager.GetItem("Lighthouse",1),
|
||||||
ModCore.ObjectManager.GetItem("CopperWire",10),
|
ModCore.ObjectManager.GetItem("CopperWire",10),
|
||||||
batteryBin,
|
batteryBin,
|
||||||
ModCore.ObjectManager.GetItem("Capacitor",1)
|
ModCore.ObjectManager.GetItem("Capacitor",1),
|
||||||
|
ModCore.ObjectManager.GetItem("ChargingStation",1)
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,7 @@
|
||||||
<Compile Include="Framework\Objects\Items\Tools\HoeExtended.cs" />
|
<Compile Include="Framework\Objects\Items\Tools\HoeExtended.cs" />
|
||||||
<Compile Include="Framework\Objects\Items\Tools\PickaxeExtended.cs" />
|
<Compile Include="Framework\Objects\Items\Tools\PickaxeExtended.cs" />
|
||||||
<Compile Include="Framework\Objects\Items\Tools\WateringCanExtended.cs" />
|
<Compile Include="Framework\Objects\Items\Tools\WateringCanExtended.cs" />
|
||||||
|
<Compile Include="Framework\Objects\Machines\ChargingStation.cs" />
|
||||||
<Compile Include="Framework\Objects\Machines\EnergyGeneration\SolarPanel.cs" />
|
<Compile Include="Framework\Objects\Machines\EnergyGeneration\SolarPanel.cs" />
|
||||||
<Compile Include="Framework\Objects\Machines\Machine.cs" />
|
<Compile Include="Framework\Objects\Machines\Machine.cs" />
|
||||||
<Compile Include="Framework\Objects\Machines\Wire.cs" />
|
<Compile Include="Framework\Objects\Machines\Wire.cs" />
|
||||||
|
@ -433,6 +434,9 @@
|
||||||
<Content Include="Content\Graphics\Objects\Machines\Capacitor.png">
|
<Content Include="Content\Graphics\Objects\Machines\Capacitor.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Graphics\Objects\Machines\ChargingStation.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\Graphics\Objects\Machines\Sandbox.png">
|
<Content Include="Content\Graphics\Objects\Machines\Sandbox.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
Loading…
Reference in New Issue