Added in fluids to resource manager. Got fluid pump able to be placed in water, added in infinite reach for placing custom objects.
This commit is contained in:
parent
0a676166f5
commit
43eb60e9b9
Binary file not shown.
After Width: | Height: | Size: 180 B |
Binary file not shown.
After Width: | Height: | Size: 127 B |
Binary file not shown.
After Width: | Height: | Size: 317 B |
|
@ -79,7 +79,7 @@ namespace Revitalize.Framework.Managers
|
|||
/// <summary>
|
||||
/// The remaining capacity on the tank.
|
||||
/// </summary>
|
||||
|
||||
|
||||
public int remainingCapacity
|
||||
{
|
||||
get
|
||||
|
@ -109,6 +109,21 @@ namespace Revitalize.Framework.Managers
|
|||
return this.amount == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public string getFluidDisplayString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
if (this.fluid != null)
|
||||
{
|
||||
b.Append(this.fluid.name);
|
||||
b.Append(": ");
|
||||
}
|
||||
b.Append(this.amount);
|
||||
b.Append("/");
|
||||
b.Append(this.capacity);
|
||||
return b.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
|
@ -165,11 +180,9 @@ namespace Revitalize.Framework.Managers
|
|||
if (this.CanRecieveThisFluid(L))
|
||||
{
|
||||
if (this.fluid == null) this.fluid = L.Copy();
|
||||
else
|
||||
{
|
||||
int intakeAmount=Math.Min(this.remainingCapacity, Amount);
|
||||
this.amount = this.amount + intakeAmount;
|
||||
}
|
||||
int intakeAmount = Math.Min(this.remainingCapacity, Amount);
|
||||
this.amount = this.amount + intakeAmount;
|
||||
|
||||
}
|
||||
else return;
|
||||
}
|
||||
|
@ -288,7 +301,7 @@ namespace Revitalize.Framework.Managers
|
|||
/// <param name="Capacity"></param>
|
||||
/// <param name="OnlyOutput"></param>
|
||||
/// <param name="AllowDoubleInput">Can both input tanks store the same Fluid?</param>
|
||||
public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput=false)
|
||||
public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput = false)
|
||||
{
|
||||
if (OnlyOutput)
|
||||
{
|
||||
|
@ -333,13 +346,13 @@ namespace Revitalize.Framework.Managers
|
|||
int remainingAmount = Amount;
|
||||
if (this.allowDoubleInput)
|
||||
{
|
||||
if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount>0)
|
||||
if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount > 0)
|
||||
{
|
||||
int allowedAmount = this.inputTank1.remainingCapacity;
|
||||
this.inputTank1.intakeFluid(L, remainingAmount);
|
||||
remainingAmount -= allowedAmount;
|
||||
}
|
||||
if (this.inputTank2.CanRecieveThisFluid(L)&& remainingAmount>0)
|
||||
if (this.inputTank2.CanRecieveThisFluid(L) && remainingAmount > 0)
|
||||
{
|
||||
int allowedAmount = this.inputTank2.remainingCapacity;
|
||||
this.inputTank2.intakeFluid(L, remainingAmount);
|
||||
|
@ -350,7 +363,7 @@ namespace Revitalize.Framework.Managers
|
|||
else
|
||||
{
|
||||
|
||||
if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount > 0 && this.inputTank2.DoesTankContainThisFluid(L)==false)
|
||||
if (this.inputTank1.CanRecieveThisFluid(L) && remainingAmount > 0 && this.inputTank2.DoesTankContainThisFluid(L) == false)
|
||||
{
|
||||
int allowedAmount = this.inputTank1.remainingCapacity;
|
||||
this.inputTank1.intakeFluid(L, remainingAmount);
|
||||
|
@ -381,15 +394,15 @@ namespace Revitalize.Framework.Managers
|
|||
|
||||
int requiredAmount = Amount;
|
||||
int tank1Amount = this.inputTank1.GetAmountOfFluidInThisTank(L);
|
||||
int tank2Amount= this.inputTank2.GetAmountOfFluidInThisTank(L);
|
||||
if (tank1Amount > 0 && requiredAmount>0)
|
||||
int tank2Amount = this.inputTank2.GetAmountOfFluidInThisTank(L);
|
||||
if (tank1Amount > 0 && requiredAmount > 0)
|
||||
{
|
||||
this.inputTank1.consumeFluid(requiredAmount);
|
||||
requiredAmount -= tank1Amount;
|
||||
this.requiresUpdate = true;
|
||||
|
||||
}
|
||||
if(tank2Amount>0 && requiredAmount > 0)
|
||||
if (tank2Amount > 0 && requiredAmount > 0)
|
||||
{
|
||||
this.inputTank2.consumeFluid(requiredAmount);
|
||||
requiredAmount -= tank2Amount;
|
||||
|
@ -434,7 +447,7 @@ namespace Revitalize.Framework.Managers
|
|||
}
|
||||
else
|
||||
{
|
||||
if(this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false)
|
||||
if (this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false)
|
||||
{
|
||||
return this.inputTank1.GetAmountOfFluidThisTankCanReceieve(L);
|
||||
}
|
||||
|
@ -473,7 +486,7 @@ namespace Revitalize.Framework.Managers
|
|||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -486,7 +499,7 @@ namespace Revitalize.Framework.Managers
|
|||
if (Other.canRecieveThisFluid(this.outputTank.fluid))
|
||||
{
|
||||
int actualAmount = Math.Min(this.outputTank.amount, Other.getMaxAmountOfFluidIntakePossible(this.outputTank.fluid));
|
||||
Other.intakeFluid(this.outputTank.fluid,actualAmount);
|
||||
Other.intakeFluid(this.outputTank.fluid, actualAmount);
|
||||
this.drainOutputTank(actualAmount);
|
||||
}
|
||||
}
|
||||
|
@ -504,7 +517,7 @@ namespace Revitalize.Framework.Managers
|
|||
|
||||
public FluidManagerV2 Copy()
|
||||
{
|
||||
return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput,this.fluidInteractionType,this.allowDoubleInput);
|
||||
return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput, this.fluidInteractionType, this.allowDoubleInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@ namespace Revitalize.Framework.Menus.Machines
|
|||
private AnimatedButton storageButton;
|
||||
private Vector2 storageRemainingDisplayLocation;
|
||||
|
||||
|
||||
private AnimatedButton inputFluidTank1Button;
|
||||
private AnimatedButton inputFluidTank2Button;
|
||||
private AnimatedButton outputFluidTankButton;
|
||||
private Vector2 fluidDisplayLocation;
|
||||
|
||||
private int requiredEnergyPer10Min;
|
||||
|
||||
private EnergyManager energy
|
||||
|
@ -89,6 +95,7 @@ namespace Revitalize.Framework.Menus.Machines
|
|||
this.timeDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width * .1f), this.yPositionOnScreen + (this.height * .25f));
|
||||
this.energyRequiredDisplayLocation = this.timeDisplayLocation + new Vector2(0, 64);
|
||||
this.storageRemainingDisplayLocation = this.energyRequiredDisplayLocation + new Vector2(0, 64);
|
||||
this.fluidDisplayLocation = this.storageRemainingDisplayLocation + new Vector2(0, 64);
|
||||
|
||||
this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4);
|
||||
this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f);
|
||||
|
@ -99,6 +106,12 @@ namespace Revitalize.Framework.Menus.Machines
|
|||
this.energyRequiredButton=new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Energy Required", this.energyRequiredDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "LightningBolt"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f);
|
||||
this.storageButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Storage Remaining", this.storageRemainingDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Chest"), new StardustCore.Animations.Animation(0, 0, 16, 32)), Color.White), new Rectangle(0, 0, 16, 32), 1f);
|
||||
|
||||
|
||||
this.inputFluidTank1Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 1 fluid:", this.fluidDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu",this.objectSource.info.fluidManager.inputTank1.fluid!=null? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank1.fluid!=null ? this.objectSource.info.fluidManager.inputTank1.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f);
|
||||
this.inputFluidTank2Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 2 fluid:", this.fluidDisplayLocation+new Vector2(0,64), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.inputTank2.fluid!=null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank2.fluid!=null ? this.objectSource.info.fluidManager.inputTank2.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f);
|
||||
ModCore.log(this.objectSource.info.fluidManager.outputTank.fluid != null ? "Color of fluid:" + this.objectSource.info.fluidManager.outputTank.fluid.color.ToString() : "Color is null!");
|
||||
this.outputFluidTankButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Output fluid:", this.fluidDisplayLocation+new Vector2(0,128), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.outputTank.fluid!=null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.outputTank.fluid!=null ? this.objectSource.info.fluidManager.outputTank.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f);
|
||||
|
||||
this.requiredEnergyPer10Min = RequiredEnergyPer10Min;
|
||||
}
|
||||
|
||||
|
@ -160,20 +173,38 @@ namespace Revitalize.Framework.Menus.Machines
|
|||
{
|
||||
this.batteryBackground.draw(b, 1f, 1f);
|
||||
this.energyMeterColorSwap();
|
||||
b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale)+ (int)(46 * this.batteryBackground.scale), (int)((9 * this.batteryBackground.scale)), (int)(46 * this.batteryBackground.scale * this.energy.energyPercentRemaining)), new Rectangle(0, 0, 1, 1), Color.White, 0f, new Vector2(0f,1f), SpriteEffects.None, 0.2f);
|
||||
b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale) + (int)(46 * this.batteryBackground.scale), (int)((9 * this.batteryBackground.scale)), (int)(46 * this.batteryBackground.scale * this.energy.energyPercentRemaining)), new Rectangle(0, 0, 1, 1), Color.White, 0f, new Vector2(0f, 1f), SpriteEffects.None, 0.2f);
|
||||
this.battergyEnergyGuage.draw(b, 1f, 1f);
|
||||
|
||||
this.energyRequiredButton.draw(b);
|
||||
b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min+" E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black);
|
||||
b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min + " E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black);
|
||||
}
|
||||
|
||||
if (this.objectSource.info.inventory.HasInventory)
|
||||
{
|
||||
this.storageButton.draw(b);
|
||||
b.DrawString(Game1.smallFont, "Storage remaining: "+ (this.objectSource.info.inventory.capacity-this.objectSource.info.inventory.ItemCount)+"/"+this.objectSource.info.inventory.capacity, this.storageRemainingDisplayLocation + new Vector2(0, 32f), Color.Black);
|
||||
b.DrawString(Game1.smallFont, "Storage remaining: " + (this.objectSource.info.inventory.capacity - this.objectSource.info.inventory.ItemCount) + "/" + this.objectSource.info.inventory.capacity, this.storageRemainingDisplayLocation + new Vector2(0, 32f), Color.Black);
|
||||
}
|
||||
|
||||
|
||||
if (this.objectSource.info.fluidManager.InteractsWithFluids)
|
||||
{
|
||||
if (this.objectSource.info.fluidManager.inputTank1.capacity > 0)
|
||||
{
|
||||
this.inputFluidTank1Button.draw(b);
|
||||
b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 0f), Color.Black);
|
||||
}
|
||||
if (this.objectSource.info.fluidManager.inputTank2.capacity > 0)
|
||||
{
|
||||
this.inputFluidTank2Button.draw(b);
|
||||
b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 64f), Color.Black);
|
||||
}
|
||||
if (this.objectSource.info.fluidManager.outputTank.capacity > 0)
|
||||
{
|
||||
//ModCore.log("Color:" + this.objectSource.GetFluidManager().outputTank.fluid.color);
|
||||
this.outputFluidTankButton.draw(b);
|
||||
b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 128f), Color.Black);
|
||||
}
|
||||
}
|
||||
|
||||
this.objectSource.drawFullyInMenu(b, new Vector2((int)(this.xPositionOnScreen + (this.width / 2) - (this.itemDisplayOffset.X / 2)), (int)(this.yPositionOnScreen + 128f)), .24f);
|
||||
Vector2 nameOffset = Game1.dialogueFont.MeasureString(this.objectSource.DisplayName);
|
||||
|
|
|
@ -0,0 +1,242 @@
|
|||
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 Revitalize.Framework.Objects.InformationFiles;
|
||||
using Revitalize.Framework.Utilities;
|
||||
using StardewValley;
|
||||
|
||||
namespace Revitalize.Framework.Objects.Machines
|
||||
{
|
||||
public class WaterPump: Machine
|
||||
{
|
||||
|
||||
public WaterPump() { }
|
||||
|
||||
public WaterPump(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 WaterPump(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 WaterPump(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);
|
||||
|
||||
this.animationManager.prepareForNextUpdateTick();
|
||||
}
|
||||
|
||||
|
||||
public override bool minutesElapsed(int minutes, GameLocation environment)
|
||||
{
|
||||
|
||||
this.updateInfo();
|
||||
//ModCore.log(this.info.animationManager.currentAnimationName);
|
||||
|
||||
if (this.updatesContainerObjectForProduction)
|
||||
{
|
||||
//ModCore.log("Update container object for production!");
|
||||
//this.MinutesUntilReady -= minutes;
|
||||
int remaining = minutes;
|
||||
//ModCore.log("Minutes elapsed: " + remaining);
|
||||
while (remaining > 0)
|
||||
{
|
||||
if (LocationUtilities.IsThereWaterAtThisTile(environment, (int)this.TileLocation.X, (int)this.TileLocation.Y))
|
||||
{
|
||||
this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Water"), 100);
|
||||
}
|
||||
remaining -= 10;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
//return base.minutesElapsed(minutes, environment);
|
||||
}
|
||||
|
||||
public override bool canBePlacedInWater()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool rightClicked(Farmer who)
|
||||
{
|
||||
if (this.location == null)
|
||||
this.location = Game1.player.currentLocation;
|
||||
if (Game1.menuUp || Game1.currentMinigame != null) return false;
|
||||
|
||||
//ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero);
|
||||
this.createMachineMenu();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Item getOne()
|
||||
{
|
||||
WaterPump component = new WaterPump(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook);
|
||||
component.containerObject = this.containerObject;
|
||||
component.offsetKey = this.offsetKey;
|
||||
return component;
|
||||
return component;
|
||||
}
|
||||
|
||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
WaterPump self = Revitalize.ModCore.Serializer.DeserializeGUID<WaterPump>(additionalSaveData["GUID"]);
|
||||
if (ModCore.IsNullOrDefault<Machine>(self)) return null;
|
||||
try
|
||||
{
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledObject>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
public override void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
base.rebuild(additionalSaveData, replacement);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if (this.animationManager.canTickAnimation())
|
||||
{
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
public override void updateInfo()
|
||||
{
|
||||
return;
|
||||
if (this.info == null || this.containerObject == null)
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
//ModCore.log("Updated item info!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.requiresUpdate())
|
||||
{
|
||||
//this.ItemInfo = this.text;
|
||||
this.text = this.ItemInfo;
|
||||
this.info.cleanAfterUpdate();
|
||||
//this.containerObject.updateInfo();
|
||||
//ModCore.log("Force an update for machine: " + this.info.name);
|
||||
MultiplayerUtilities.RequestUpdateSync(this.guid);
|
||||
}
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -122,10 +122,24 @@ namespace Revitalize.Framework.Objects
|
|||
return base.checkForAction(who, justCheckingForActivity);
|
||||
}
|
||||
|
||||
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
||||
{
|
||||
return base.canBePlacedHere(l, tile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override bool clicked(Farmer who)
|
||||
{
|
||||
//ModCore.log("Clicked a multiTiledComponent!");
|
||||
this.containerObject.pickUp(who);
|
||||
if (ModCore.playerInfo.justPlacedACustomObject == true) return false;
|
||||
if (PlayerUtilities.CanPlayerInventoryReceiveThisItem(this.containerObject)) {
|
||||
this.containerObject.pickUp(who);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
//return base.clicked(who);
|
||||
}
|
||||
|
@ -180,6 +194,7 @@ namespace Revitalize.Framework.Objects
|
|||
location.objects.Add(this.TileLocation, this);
|
||||
|
||||
|
||||
|
||||
if(this.getBoundingBox(this.TileLocation).Width==0&& this.getBoundingBox(this.TileLocation).Height == 0)
|
||||
{
|
||||
this.boundingBox.Value = new Rectangle(this.boundingBox.X, this.boundingBox.Y, Game1.tileSize, Game1.tileSize);
|
||||
|
|
|
@ -257,8 +257,8 @@ namespace Revitalize.Framework.Objects
|
|||
//Revitalize.ModCore.log(new Vector2(x + ((int)pair.Key.X), y + ((int)pair.Key.Y)));
|
||||
if ((pair.Value as MultiTiledComponent).info.ignoreBoundingBox)
|
||||
{
|
||||
x *= -1;
|
||||
y *= -1;
|
||||
//x *= -1;
|
||||
//y *= -1;
|
||||
}
|
||||
(pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f);
|
||||
//break;
|
||||
|
@ -283,10 +283,10 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
if ((pair.Value as MultiTiledComponent).info.lightManager != null)
|
||||
{
|
||||
ModCore.log("Let there be light.");
|
||||
//ModCore.log("Let there be light.");
|
||||
if ((pair.Value as MultiTiledComponent).info.lightManager.lightsOn == true)
|
||||
{
|
||||
ModCore.log("Got a light???");
|
||||
//ModCore.log("Got a light???");
|
||||
}
|
||||
}
|
||||
(pair.Value as MultiTiledComponent).removeFromLocation(who.currentLocation, pair.Key);
|
||||
|
|
|
@ -331,6 +331,13 @@ namespace Revitalize.Framework.Objects
|
|||
alloyFurnace.addComponent(new Vector2(0, 1), alloyFurnace_0_1);
|
||||
this.AddItem("AlloyFurnace", alloyFurnace);
|
||||
|
||||
|
||||
MultiTiledObject waterPumpV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)));
|
||||
WaterPump waterPumpV1_0_0 = new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 0, 16, 16)), Color.White, true, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, "");
|
||||
WaterPump waterPumpV1_0_1= new WaterPump(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WaterPump", TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Water Pump", "Omegasis.Revitalize.Objects.Machines.WaterPump", "Pumps up water from a water source.", "Machine", Color.SteelBlue, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "WaterPump"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "WaterPump"), new Animation(0, 16, 16, 16)), Color.White, false, null, null, null, false, null, null, new Managers.FluidManagerV2(5000, true, Enums.FluidInteractionType.Machine, false)), null, 0, 0, true, "");
|
||||
waterPumpV1.addComponent(new Vector2(0, 0), waterPumpV1_0_0);
|
||||
waterPumpV1.addComponent(new Vector2(0, 1), waterPumpV1_0_1);
|
||||
this.AddItem("WaterPumpV1", waterPumpV1);
|
||||
}
|
||||
|
||||
private void loadInWires()
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Revitalize.Framework.Factories.Objects.Resources;
|
||||
using Revitalize.Framework.Managers;
|
||||
using Revitalize.Framework.Objects.InformationFiles;
|
||||
using Revitalize.Framework.Objects.Items.Resources;
|
||||
using Revitalize.Framework.Objects.Resources.OreVeins;
|
||||
|
@ -33,6 +34,7 @@ namespace Revitalize.Framework.Objects
|
|||
public Dictionary<string, CustomObject> resources;
|
||||
|
||||
public Dictionary<string, ResourceInformation> miningDrillResources;
|
||||
public Dictionary<string, Fluid> fluids;
|
||||
|
||||
/// <summary>
|
||||
/// A list of all visited floors on the current visit to the mines.
|
||||
|
@ -51,6 +53,7 @@ namespace Revitalize.Framework.Objects
|
|||
this.visitedFloors = new List<int>();
|
||||
this.resources = new Dictionary<string, CustomObject>();
|
||||
this.miningDrillResources = new Dictionary<string, ResourceInformation>();
|
||||
this.fluids = new Dictionary<string, Fluid>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,8 +65,13 @@ namespace Revitalize.Framework.Objects
|
|||
this.serializeOreVeins();
|
||||
this.loadOreVeins();
|
||||
this.loadInMiningDrillLootTable();
|
||||
this.loadInFluidDictionary();
|
||||
}
|
||||
|
||||
private void loadInFluidDictionary()
|
||||
{
|
||||
this.fluids.Add("Water", new Fluid("Water", Color.Blue));
|
||||
}
|
||||
private void loadInMiningDrillLootTable()
|
||||
{
|
||||
this.miningDrillResources.Add("Bauxite", new ResourceInformation(this.getResource("Bauxite"), ModCore.Configs.miningDrillConfig.amountOfBauxiteToMine.min, ModCore.Configs.miningDrillConfig.amountOfBauxiteToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.bauxiteMineChance, 0, 0, 0, 0));
|
||||
|
@ -380,6 +388,23 @@ namespace Revitalize.Framework.Objects
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a fluid from the fluid dictionary.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public Fluid getFluid(string name)
|
||||
{
|
||||
if (this.fluids.ContainsKey(name))
|
||||
{
|
||||
return this.fluids[name].Copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a resource from the resource maanger.
|
||||
/// </summary>
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Revitalize.Framework.Player
|
|||
{
|
||||
public SittingInfo sittingInfo;
|
||||
public MagicManager magicManager;
|
||||
public bool justPlacedACustomObject;
|
||||
|
||||
public PlayerInfo()
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Revitalize.Framework.Utilities
|
|||
for(int i = 0; i < Game1.player.Items.Count; i++)
|
||||
{
|
||||
if (I == Game1.player.Items[i]) return true;
|
||||
if (I == null) return true;
|
||||
if (Game1.player.Items[i] == null) return true;
|
||||
if (I.canStackWith(Game1.player.Items[i])) return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -275,7 +275,7 @@ namespace Revitalize
|
|||
ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage;
|
||||
ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.ResetNormalToolsColorOnLeftClick;
|
||||
|
||||
|
||||
ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed1;
|
||||
|
||||
ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory;
|
||||
|
||||
|
@ -285,6 +285,28 @@ namespace Revitalize
|
|||
CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary<string, CraftingRecipeBook>();
|
||||
}
|
||||
|
||||
private void Input_ButtonPressed1(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e)
|
||||
{
|
||||
if(e.Button== SButton.MouseLeft)
|
||||
{
|
||||
if (Game1.player != null)
|
||||
{
|
||||
if (Game1.activeClickableMenu != null || Game1.eventUp || Game1.currentMinigame != null) return;
|
||||
if(Game1.player.ActiveObject is CustomObject)
|
||||
{
|
||||
if((Game1.player.ActiveObject as CustomObject).canBePlacedHere(Game1.player.currentLocation, Game1.currentCursorTile))
|
||||
{
|
||||
CustomObject o =(CustomObject) Game1.player.ActiveObject;
|
||||
o.placementAction(Game1.currentLocation,(int) Game1.currentCursorTile.X*Game1.tileSize,(int)Game1.currentCursorTile.Y*Game1.tileSize, Game1.player);
|
||||
//o.performObjectDropInAction(Game1.player.ActiveObject, true, Game1.player);
|
||||
Game1.player.reduceActiveItemByOne();
|
||||
playerInfo.justPlacedACustomObject = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -526,6 +548,7 @@ namespace Revitalize
|
|||
|
||||
private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
|
||||
{
|
||||
if (playerInfo.justPlacedACustomObject == true) playerInfo.justPlacedACustomObject = false;
|
||||
DarkerNight.SetDarkerColor();
|
||||
playerInfo.update();
|
||||
}
|
||||
|
@ -577,6 +600,7 @@ namespace Revitalize
|
|||
ModCore.ObjectManager.GetItem("MiningDrillMachineV1"),
|
||||
ModCore.ObjectManager.GetItem("AlloyFurnace"),
|
||||
new StardewValley.Object((int)Enums.SDVObject.IronBar,100),
|
||||
ModCore.ObjectManager.GetItem("WaterPumpV1")
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
<Compile Include="Framework\Illuminate\LightManager.cs" />
|
||||
<Compile Include="Framework\Illuminate\NamedColor.cs" />
|
||||
<Compile Include="Framework\Managers\ColorManager.cs" />
|
||||
<Compile Include="Framework\Managers\LiquidManagerV2.cs" />
|
||||
<Compile Include="Framework\Managers\FluidManagerV2.cs" />
|
||||
<Compile Include="Framework\Menus\CraftingInformationPage.cs" />
|
||||
<Compile Include="Framework\Menus\CraftingMenuV1.cs" />
|
||||
<Compile Include="Framework\Menus\Machines\MachineMenu.cs" />
|
||||
|
@ -168,6 +168,7 @@
|
|||
<Compile Include="Framework\Objects\Machines\EnergyGeneration\SolarPanel.cs" />
|
||||
<Compile Include="Framework\Objects\Machines\Grinder.cs" />
|
||||
<Compile Include="Framework\Objects\Machines\Machine.cs" />
|
||||
<Compile Include="Framework\Objects\Machines\WaterPump.cs" />
|
||||
<Compile Include="Framework\Objects\Machines\Wire.cs" />
|
||||
<Compile Include="Framework\Objects\Machines\WireMultiTiledObject.cs" />
|
||||
<Compile Include="Framework\Objects\MultiTiledComponent.cs" />
|
||||
|
@ -415,6 +416,12 @@
|
|||
<Content Include="Content\Graphics\Menus\EnergyMenu\BatteryFrame.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Menus\EnergyMenu\DropletColored.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Menus\EnergyMenu\DropletOutline.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Menus\EnergyMenu\LightningBolt.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@ -475,6 +482,9 @@
|
|||
<Content Include="Content\Graphics\Objects\Furniture\Tables\Oak Table.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Objects\Machines\AlloyFurnace.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Objects\Machines\BatteryBin.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@ -499,6 +509,9 @@
|
|||
<Content Include="Content\Graphics\Objects\Machines\SolarPanelTier1.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Objects\Machines\WaterPump.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Objects\Machines\Wires\CopperWire.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
Loading…
Reference in New Issue