diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/MiningDrillMachine.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/MiningDrillMachine.png new file mode 100644 index 00000000..62d79960 Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/MiningDrillMachine.png differ diff --git a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs index 29e52c18..93db17fa 100644 --- a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs +++ b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs @@ -25,6 +25,8 @@ namespace Revitalize.Framework.Configs /// public GlobalMachineConfig machinesConfig; + public MiningDrillConfig miningDrillConfig; + public ConfigManager() { this.vanillaMachineConfig = VanillaMachineRecipeConfig.InitializeConfig(); @@ -32,6 +34,7 @@ namespace Revitalize.Framework.Configs this.furnitureConfig = FurnitureConfig.InitializeConfig(); this.machinesConfig = GlobalMachineConfig.InitializeConfig(); this.objectsConfig = ObjectsConfig.InitializeConfig(); + this.miningDrillConfig = MiningDrillConfig.InitializeConfig(); } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs index ffeedb80..b0b799bc 100644 --- a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs +++ b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs @@ -19,6 +19,9 @@ namespace Revitalize.Framework.Configs public int grinderEnergyConsumption; public int grinderTimeToGrind; + public int miningDrillEnergyConsumption; + public int miningDrillTimeToMine; + public GlobalMachineConfig() { this.doMachinesConsumeEnergy = true; @@ -28,6 +31,8 @@ namespace Revitalize.Framework.Configs this.machineNotificationBubbleAlpha = 0.75f; this.grinderEnergyConsumption = 20; this.grinderTimeToGrind = 30; + this.miningDrillEnergyConsumption = 50; + this.miningDrillTimeToMine = 60; } public static GlobalMachineConfig InitializeConfig() diff --git a/GeneralMods/Revitalize/Framework/Configs/MiningDrillConfig.cs b/GeneralMods/Revitalize/Framework/Configs/MiningDrillConfig.cs new file mode 100644 index 00000000..296e3e99 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/MiningDrillConfig.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Configs +{ + public class MiningDrillConfig + { + + public double bauxiteMineChance; + public double tinMineChance; + public double leadMineChance; + public double silverMineChance; + public double titaniumMineChance; + public double prismaticNuggetMineChance; + public double copperMineChance; + public double ironMineChance; + public double goldMineChance; + public double iridiumMineChance; + public double stoneMineChance; + public double clayMineChance; + public double sandMineChance; + public double geodeMineChance; + public double frozenGeodeMineChance; + public double magmaGeodeMineChance; + public double omniGeodeMineChance; + //If requested put in all gems/minerals here. Otherwise hope that geodes do the trick. + + + public IntRange amountOfBauxiteToMine; + public IntRange amountOfTinToMine; + public IntRange amountOfLeadToMine; + public IntRange amountOfSilverToMine; + public IntRange amountOfTitaniumToMine; + public IntRange amountOfPrismaticNuggetsToMine; + public IntRange amountOfCopperToMine; + public IntRange amountOfIronToMine; + public IntRange amountOfGoldToMine; + public IntRange amountOfIridiumToMine; + public IntRange amountOfStoneToMine; + public IntRange amountOfClayToMine; + public IntRange amountOfSandToMine; + public IntRange amountOfGeodesToMine; + public IntRange amountOfFrozenGeodesToMine; + public IntRange amountOfMagmaGeodesToMine; + public IntRange amountOfOmniGeodesToMine; + + public MiningDrillConfig() + { + this.bauxiteMineChance = 0.25f; + this.tinMineChance = 0.3f; + this.leadMineChance = 0.15f; + this.silverMineChance = 0.10f; + this.titaniumMineChance = 0.05f; + this.prismaticNuggetMineChance = 0.005f; + this.copperMineChance = 0.35f; + this.ironMineChance = 0.20f; + this.goldMineChance = 0.10f; + this.iridiumMineChance = 0.005f; + this.stoneMineChance = 1.0f; + this.clayMineChance = 0.30f; + this.sandMineChance = 0.20f; + this.geodeMineChance = 0.25f; + this.frozenGeodeMineChance = 0.15f; + this.magmaGeodeMineChance = 0.05f; + this.omniGeodeMineChance = 0.01f; + + this.amountOfBauxiteToMine = new IntRange(1, 3); + this.amountOfClayToMine = new IntRange(1, 3); + this.amountOfCopperToMine = new IntRange(1, 3); + this.amountOfFrozenGeodesToMine = new IntRange(1, 1); + this.amountOfGeodesToMine = new IntRange(1, 1); + this.amountOfGoldToMine = new IntRange(1, 3); + this.amountOfIronToMine = new IntRange(1, 3); + this.amountOfIridiumToMine = new IntRange(1, 3); + this.amountOfLeadToMine = new IntRange(1, 3); + this.amountOfMagmaGeodesToMine = new IntRange(1, 1); + this.amountOfOmniGeodesToMine = new IntRange(1, 1); + this.amountOfPrismaticNuggetsToMine = new IntRange(1, 1); + this.amountOfSandToMine = new IntRange(1, 2); + this.amountOfSilverToMine = new IntRange(1, 3); + this.amountOfStoneToMine = new IntRange(1, 5); + this.amountOfTinToMine = new IntRange(1, 3); + this.amountOfTitaniumToMine = new IntRange(1, 3); + } + + + public static MiningDrillConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "MiningDrillMachine.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "MiningDrillMachine.json")); + else + { + MiningDrillConfig Config = new MiningDrillConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "MiningDrillMachine.json"), Config); + return Config; + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 945d7d6f..6ace0224 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -131,6 +131,11 @@ namespace Revitalize.Framework.Objects { get { + if (this.info == null) + { + this.updateInfo(); + } + //ModCore.log("Location Name is: " + this.info.locationName); if (this._location == null) { @@ -764,6 +769,11 @@ namespace Revitalize.Framework.Objects public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { + if (this.info == null) + { + this.updateInfo(); + } + if (this.location == null) { this.location = environment; diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index e0f0d739..552a7110 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -216,12 +216,21 @@ namespace Revitalize.Framework.Objects.Machines public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { + + base.updateWhenCurrentLocation(time, environment); } public override bool minutesElapsed(int minutes, GameLocation environment) { + if (this.info == null) + { + this.updateInfo(); + } + + ModCore.log(this.info.animationManager.currentAnimationName); + if (this.updatesContainerObjectForProduction) { //ModCore.log("Update container object for production!"); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs index e39f6ab7..2905a779 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs @@ -92,8 +92,8 @@ namespace Revitalize.Framework.Objects.Machines public override Dictionary getAdditionalSaveData() { Dictionary saveData = base.getAdditionalSaveData(); - saveData.Add("GUID", this.guid.ToString()); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + //saveData.Add("GUID", this.guid.ToString()); + //Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); return saveData; } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 0c0a7e3c..1bcf6898 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -451,7 +451,7 @@ namespace Revitalize.Framework.Objects { Dictionary saveData = base.getAdditionalSaveData(); saveData.Add("GUID", this.guid.ToString()); - Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); + //Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this); return saveData; } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index a6ed3818..c4ca919b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -268,6 +268,34 @@ namespace Revitalize.Framework.Objects grinder.addComponent(new Vector2(1, 1), grinder_1_1); this.AddItem("Grinder", grinder); + MultiTiledObject miningDrillMachine = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes))); + Machine miningDrillMachine_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 0, 16, 16), new Dictionary>() { + {"Default",new List(){new Animation(0,0,16,16) } }, + { "Mining",new List(){ + new Animation(0,0,16,16,30), + new Animation(16,0,16,16,30), + new Animation(32,0,16,16,30), + new Animation(48,0,16,16,30), + } } + }, "Mining"), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(), ModCore.Configs.machinesConfig.miningDrillEnergyConsumption, ModCore.Configs.machinesConfig.miningDrillTimeToMine, true, ""); + + Machine miningDrillMachine_0_1 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.MiningDrillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Mining Drill", "Omegasis.Revitalize.Objects.Machines.MiningDrill", "Digs up rocks and ores. Requires energy to run.", "Machine", Color.SteelBlue, -300, 0, false, 4000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "MiningDrillMachine"), new Animation(0, 16, 16, 16),new Dictionary>() { + {"Default",new List(){new Animation(0,16,16,16) } }, + { "Mining",new List(){ + new Animation(0,16,16,16,30), + new Animation(16,16,16,16,30), + new Animation(32,16,16,16,30), + new Animation(48,16,16,16,30), + } } + }, "Mining"), Color.White, false, new InventoryManager(18, 3, 6), null, new Energy.EnergyManager(1000, Enums.EnergyInteractionType.Consumes)), ModCore.ObjectManager.resources.miningDrillResources.Values.ToList(), ModCore.Configs.machinesConfig.miningDrillEnergyConsumption, ModCore.Configs.machinesConfig.miningDrillTimeToMine, false, ""); + miningDrillMachine.addComponent(new Vector2(0, 0), miningDrillMachine_0_0); + miningDrillMachine.addComponent(new Vector2(0, 1), miningDrillMachine_0_1); + miningDrillMachine_0_0.animationManager.setAnimation("Mining"); + miningDrillMachine_0_0.animationManager.playAnimation("Mining"); + miningDrillMachine_0_1.animationManager.setAnimation("Mining"); + miningDrillMachine_0_1.animationManager.playAnimation("Mining"); + this.AddItem("MiningDrillMachineV1",miningDrillMachine); + } private void loadInWires() diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index cf67ba45..9df39c04 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -32,6 +32,8 @@ namespace Revitalize.Framework.Objects public Dictionary ores; public Dictionary resources; + public Dictionary miningDrillResources; + /// /// A list of all visited floors on the current visit to the mines. /// @@ -48,7 +50,7 @@ namespace Revitalize.Framework.Objects this.ores = new Dictionary(); this.visitedFloors = new List(); this.resources = new Dictionary(); - + this.miningDrillResources = new Dictionary(); } @@ -59,6 +61,28 @@ namespace Revitalize.Framework.Objects this.loadInResourceItems(); this.serializeOreVeins(); this.loadOreVeins(); + this.loadInMiningDrillLootTable(); + } + + 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)); + this.miningDrillResources.Add("Tin", new ResourceInformation(this.getResource("Tin"), ModCore.Configs.miningDrillConfig.amountOfTinToMine.min, ModCore.Configs.miningDrillConfig.amountOfTinToMine.max, 1, 1,1,ModCore.Configs.miningDrillConfig.tinMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Lead", new ResourceInformation(this.getResource("Lead"), ModCore.Configs.miningDrillConfig.amountOfLeadToMine.min, ModCore.Configs.miningDrillConfig.amountOfLeadToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.leadMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Silver", new ResourceInformation(this.getResource("Silver"), ModCore.Configs.miningDrillConfig.amountOfSilverToMine.min, ModCore.Configs.miningDrillConfig.amountOfSilverToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.silverMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Titanium", new ResourceInformation(this.getResource("Titanium"), ModCore.Configs.miningDrillConfig.amountOfTitaniumToMine.min, ModCore.Configs.miningDrillConfig.amountOfTitaniumToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.titaniumMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Prismatic", new ResourceInformation(this.getResource("PrismaticNugget"), ModCore.Configs.miningDrillConfig.amountOfPrismaticNuggetsToMine.min, ModCore.Configs.miningDrillConfig.amountOfPrismaticNuggetsToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.prismaticNuggetMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Copper", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.CopperOre, 1), ModCore.Configs.miningDrillConfig.amountOfCopperToMine.min, ModCore.Configs.miningDrillConfig.amountOfCopperToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.copperMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Iron", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.IronOre, 1), ModCore.Configs.miningDrillConfig.amountOfIronToMine.min, ModCore.Configs.miningDrillConfig.amountOfIronToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.ironMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Gold", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.GoldOre, 1), ModCore.Configs.miningDrillConfig.amountOfGoldToMine.min, ModCore.Configs.miningDrillConfig.amountOfGoldToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.goldMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Iridium", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.IridiumOre,1), ModCore.Configs.miningDrillConfig.amountOfIridiumToMine.min, ModCore.Configs.miningDrillConfig.amountOfIridiumToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.iridiumMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Stone", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Stone, 1), ModCore.Configs.miningDrillConfig.amountOfStoneToMine.min, ModCore.Configs.miningDrillConfig.amountOfStoneToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.stoneMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Clay", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Clay, 1), ModCore.Configs.miningDrillConfig.amountOfClayToMine.min, ModCore.Configs.miningDrillConfig.amountOfClayToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.clayMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Sand", new ResourceInformation(this.getResource("Sand"), ModCore.Configs.miningDrillConfig.amountOfSandToMine.min, ModCore.Configs.miningDrillConfig.amountOfSandToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.sandMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("Geode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.Geode,1), ModCore.Configs.miningDrillConfig.amountOfGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.geodeMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("FrozenGeode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.FrozenGeode, 1), ModCore.Configs.miningDrillConfig.amountOfFrozenGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfFrozenGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.frozenGeodeMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("MagmaGeode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.MagmaGeode, 1), ModCore.Configs.miningDrillConfig.amountOfMagmaGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfMagmaGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.magmaGeodeMineChance, 0, 0, 0, 0)); + this.miningDrillResources.Add("OmniGeode", new ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.OmniGeode, 1), ModCore.Configs.miningDrillConfig.amountOfOmniGeodesToMine.min, ModCore.Configs.miningDrillConfig.amountOfOmniGeodesToMine.max, 1, 1, 1,ModCore.Configs.miningDrillConfig.omniGeodeMineChance, 0, 0, 0, 0)); } /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index a01cf47f..a43138bc 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -573,7 +573,8 @@ namespace Revitalize ModCore.ObjectManager.GetItem("Grinder",1), new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), ModCore.ObjectManager.GetTool("MiningDrillV1"), - ModCore.ObjectManager.GetTool("ChainsawV1") + ModCore.ObjectManager.GetTool("ChainsawV1"), + ModCore.ObjectManager.GetItem("MiningDrillMachineV1") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 28c0b0d9..a5dffd19 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -56,6 +56,7 @@ + @@ -483,6 +484,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index 4e53cfec..4c222d11 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -84,7 +84,11 @@ namespace StardustCore.Animations this.animations = animationString; if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + { this.setAnimation(startingAnimationKey, startingAnimationFrame); + this.playAnimation(startingAnimationKey, true, startingAnimationFrame); + } + else { this.currentAnimation = this.defaultDrawFrame; @@ -100,9 +104,9 @@ namespace StardustCore.Animations if (this.currentAnimation.frameDuration == -1 || !this.enabled || this.currentAnimation == this.defaultDrawFrame) return; //This is if this is a default animation or the animation stops here. if (this.currentAnimation.frameCountUntilNextAnimation == 0) - this.getNextAnimation(); + this.getNextAnimationFrame(); this.currentAnimation.tickAnimationFrame(); - this.requiresUpdate = true; + //this.requiresUpdate = true; } catch (Exception err) { @@ -112,25 +116,30 @@ namespace StardustCore.Animations } /// Get the next animation frame in the list of animations. - private void getNextAnimation() + private void getNextAnimationFrame() { this.currentAnimationListIndex++; - if (this.currentAnimationListIndex == this.currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. + if (this.currentAnimationListIndex == this.currentAnimationList.Count) + { //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. if (this.loopAnimation) { this.currentAnimationListIndex = 0; + this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex]; + this.currentAnimation.startAnimation(); + return; } else { - this.requiresUpdate = true; + //this.requiresUpdate = true; this.playDefaultAnimation(); return; } + } //Get the next animation from the list and reset it's counter to the starting frame value. this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex]; this.currentAnimation.startAnimation(); - this.requiresUpdate = true; + //this.requiresUpdate = true; } /// Gets the animation from the dictionary of all animations available. @@ -171,7 +180,7 @@ namespace StardustCore.Animations /// /// /// - public bool playAnimation(string AnimationName,bool overrideSameAnimation=false,int StartingFrame = 0) + public bool playAnimation(string AnimationName, bool overrideSameAnimation = false, int StartingFrame = 0) { if (this.animations.TryGetValue(AnimationName, out List dummyList)) { @@ -379,7 +388,7 @@ namespace StardustCore.Animations /// /// /// - public void draw(SpriteBatch b,Vector2 Position,Color drawColor,float scale,SpriteEffects flipped,float depth) + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, float scale, SpriteEffects flipped, float depth) { b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, 0f, Vector2.Zero, scale, flipped, depth); try @@ -393,7 +402,7 @@ namespace StardustCore.Animations } } - public void draw(SpriteBatch b, Vector2 Position, Color drawColor, float scale,float Rotation ,SpriteEffects flipped, float depth) + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, float scale, float Rotation, SpriteEffects flipped, float depth) { b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, Rotation, Vector2.Zero, scale, flipped, depth); try @@ -430,7 +439,7 @@ namespace StardustCore.Animations } } - public void draw(SpriteBatch b, Vector2 Position, Color drawColor, Vector2 scale, float Rotation,SpriteEffects flipped, float depth) + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, Vector2 scale, float Rotation, SpriteEffects flipped, float depth) { b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, Rotation, Vector2.Zero, scale, flipped, depth); try