diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs index dbac704f..0c27a9d5 100644 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs @@ -12,7 +12,9 @@ namespace Revitalize.Framework.Objects.InformationFiles { - + /// + /// The floors of the mine that this resource should spawn in. + /// public List floorsToSpawnOn; /// /// The list of floors to exclude spawning on in the mine. @@ -20,21 +22,32 @@ namespace Revitalize.Framework.Objects.InformationFiles public List floorsToExclude; /// - /// + /// Should this resource spawn in the mine in the mountains? /// - public List minesToSpawnIn; - public bool spawnInRegularMine; + /// + /// Should this resource spawn in Skull Cavern? + /// public bool spawnInSkullCavern; + /// + /// Should this resource spawn on farms. Notably the hiltop farm? + /// public bool spawnsOnFarm; + /// + /// Should this resource spawn in the quarry? + /// public bool spawnsInQuarry; + + /// + /// Empty Constructor. + /// public OreResourceInformation() : base() { } - public OreResourceInformation(Item I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,bool SpawnsOnFarm, bool SpawnsInQuarry,List FloorsToSpawnOn, List FloorsToExclude,bool SpawnInRegularMine,bool SpawnInSkullCave,float SpawnLuckFactor=0f,float DropLuckFactor=0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes,SpawnLuckFactor,DropLuckFactor) + public OreResourceInformation(Item I,bool SpawnsOnFarm, bool SpawnsInQuarry, bool SpawnInRegularMine, bool SpawnInSkullCave,List FloorsToSpawnOn,ListFloorsToExclude ,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, double ChanceToSpawn = 1f, double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes,ChanceToSpawn,ChanceToDrop,SpawnChanceLuckFactor,SpawnAmountLuckFactor,DropChanceLuckFactor,DropAmountLuckFactor) { this.spawnsOnFarm = SpawnsOnFarm; this.spawnsInQuarry = SpawnsInQuarry; @@ -44,16 +57,30 @@ namespace Revitalize.Framework.Objects.InformationFiles this.spawnInSkullCavern = SpawnInSkullCave; } + /// + /// Gets the number of drops that should spawn for this ore. + /// + /// + /// public override int getNumberOfDropsToSpawn(bool limitToMax = true) { return base.getNumberOfDropsToSpawn(limitToMax); } + /// + /// Gets the number of nodes that should spawn for this ore. + /// + /// + /// public override int getNumberOfNodesToSpawn(bool limitToMax = true) { return base.getNumberOfNodesToSpawn(limitToMax); } + /// + /// Can this ore spawn at the given location? + /// + /// public override bool canSpawnAtLocation() { if (this.spawnsOnFarm && Game1.player.currentLocation is StardewValley.Farm) diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs index aa832739..ac29c232 100644 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs @@ -17,12 +17,45 @@ namespace Revitalize.Framework.Objects.InformationFiles /// public Item droppedItem; + /// + /// The min amount of resources to drop given the getNumberOfDrops function. + /// public int minResourcePerDrop; + /// + /// The max amount of resources to drop given the getNumberOfDrops function. + /// public int maxResourcePerDrop; + /// + /// The min amount of nodes that would be spawned given the getNumberOfNodesToSpawn function. + /// public int minNumberOfNodesSpawned; + /// + /// The max amount of nodes that would be spawned given the getNumberOfNodesToSpawn function. + /// public int maxNumberOfNodesSpawned; - public float spawnLuckFactor; - public float dropLuckFactor; + /// + /// The influence multiplier that luck has on how many nodes of this resource spawn. + /// + public double spawnAmountLuckFactor; + /// + /// The influence multiplier that luck has on ensuring the resource spawns. + /// + public double spawnChanceLuckFactor; + + public double dropAmountLuckFactor; + /// + /// The influence multiplier that luck has on ensuring the resource drops. + /// + public double dropChanceLuckFactor; + + /// + /// The chance for the resource to spawn from 0.0 ~ 1.0 + /// + public double chanceToSpawn; + /// + /// The chance for the resource to drop from 0.0 ~ 1.0 + /// + public double chanceToDrop; /// /// Empty constructor. @@ -35,18 +68,30 @@ namespace Revitalize.Framework.Objects.InformationFiles /// /// Constructor. /// - /// The item to drop. - /// The min amount to drop. - /// The max amount to drop. - public ResourceInformaton(Item I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, float SpawnLuckFactor = 0f, float DropLuckFactor=0f) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public ResourceInformaton(Item I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,double ChanceToSpawn=1f,double ChanceToDrop=1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f,double DropChanceLuckFactor=0f, double DropAmountLuckFactor = 0f) { this.droppedItem = I; this.minResourcePerDrop = MinDropAmount; this.maxResourcePerDrop = MaxDropAmount; this.minNumberOfNodesSpawned = MinNumberOfNodes; this.maxNumberOfNodesSpawned = MaxNumberOfNodes; - this.spawnLuckFactor = SpawnLuckFactor; - this.dropLuckFactor = DropLuckFactor; + this.spawnAmountLuckFactor = SpawnAmountLuckFactor; + this.dropAmountLuckFactor = DropAmountLuckFactor; + this.chanceToSpawn = ChanceToSpawn; + this.chanceToDrop = ChanceToDrop; + this.spawnChanceLuckFactor = SpawnChanceLuckFactor; + this.dropChanceLuckFactor = DropChanceLuckFactor; } @@ -60,11 +105,11 @@ namespace Revitalize.Framework.Objects.InformationFiles if (limitToMax) { - amount = (int)Math.Min(amount + (this.dropLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value)), this.maxResourcePerDrop); + amount = (int)Math.Min(amount + (this.dropAmountLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value)), this.maxResourcePerDrop); } else { - amount = (int)(amount + (this.dropLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value))); + amount = (int)(amount + (this.dropAmountLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value))); } return amount; } @@ -78,22 +123,56 @@ namespace Revitalize.Framework.Objects.InformationFiles int amount = Game1.random.Next(this.minNumberOfNodesSpawned, this.maxNumberOfNodesSpawned + 1); if (limitToMax) { - amount = (int)Math.Min(amount + (this.spawnLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value)), this.maxNumberOfNodesSpawned); + amount = (int)Math.Min(amount + (this.spawnAmountLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value)), this.maxNumberOfNodesSpawned); } else { - amount = (int)(amount + (this.spawnLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value))); + amount = (int)(amount + (this.spawnAmountLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value))); } return amount; } + /// + /// Checks to see if the resource can spawn at the player's location. + /// + /// public virtual bool canSpawnAtLocation() { return true; } + /// + /// Checks to see if the resource can spawn at the given location. + /// + /// + /// public virtual bool canSpawnAtLocation(GameLocation location) { return true; } + + /// + /// Checks to see if this resource's spawn chance is greater than the spawn chance it is checked against. + /// + /// + public virtual bool shouldSpawn() + { + double chance = Game1.random.NextDouble(); + chance = (chance - (this.spawnChanceLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value))); + if (this.chanceToSpawn >= chance) return true; + else return false; + } + + /// + /// Checks to see if this resource's drop chance is greater than the spawn chance it is checked against. + /// + /// + public virtual bool shouldDropResource() + { + double chance = Game1.random.NextDouble(); + chance= (chance - (this.dropChanceLuckFactor * (Game1.player.LuckLevel + Game1.player.addedLuckLevel.Value))); + + if (this.chanceToDrop >= chance) return true; + else return false; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs index 99653b20..ef22a0fc 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ResourceManager.cs @@ -44,10 +44,10 @@ namespace Revitalize.Framework.Objects OreVeinObj testOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Test", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Test Ore Vein", "Omegasis.Revitalize.Resources.Ore.Test", "A ore vein that is used for testing purposes.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Test"), new Animation(0, 0, 16, 16)), Color.White, false, null, null)); - testOre.addComponent(new Vector2(0, 0), new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Test", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Test Ore Vein", "Omegasis.Revitalize.Resources.Ore.Test", "A ore vein that is used for testing purposes.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Test"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), new InformationFiles.OreResourceInformation(new StardewValley.Object(211, 1), 1, 10,1,20,false,false,new List() + testOre.addComponent(new Vector2(0, 0), new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Test", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Test Ore Vein", "Omegasis.Revitalize.Resources.Ore.Test", "A ore vein that is used for testing purposes.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Test"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), new InformationFiles.OreResourceInformation(new StardewValley.Object(211, 1),false,false,true,false,new List() { new IntRange(1,9) - },null,true,true,0,0))); + },new List(),1,5,1,10,1d,1d,0,0,0,0),new List())); this.ores.Add("Omegasis.Revitalize.Resources.Ore.Test", testOre); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs index 5fc24f2b..1b3374bc 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs @@ -19,23 +19,26 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins /// Deals with information tied to the resource itself. /// public ResourceInformaton resourceInfo; + public List extraDrops; public OreVeinTile() : base() { } - public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info,ResourceInformaton Resource) : base(PyTKData, Info) + public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info,ResourceInformaton Resource,List ExtraDrops) : base(PyTKData, Info) { this.health = 3; this.resourceInfo = Resource; + this.extraDrops = ExtraDrops != null ? ExtraDrops : new List(); } - public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation,ResourceInformaton Resource) : base(PyTKData, Info, TileLocation) + public OreVeinTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation,ResourceInformaton Resource, List ExtraDrops) : base(PyTKData, Info, TileLocation) { this.health = 3; this.resourceInfo = Resource; + this.extraDrops = ExtraDrops != null ? ExtraDrops : new List(); } @@ -127,12 +130,26 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins /// public void destoryVein() { - int amount = Game1.random.Next(this.resourceInfo.minResourcePerDrop, this.resourceInfo.maxResourcePerDrop); + int amount = this.resourceInfo.getNumberOfDropsToSpawn(); Item newItem = this.resourceInfo.droppedItem.getOne(); for(int i = 0; i < amount; i++) { Game1.createItemDebris(newItem.getOne(), this.TileLocation*Game1.tileSize, Game1.random.Next(0, 3), this.location); } + + if (this.extraDrops != null) + { + foreach (ResourceInformaton extra in this.extraDrops) + { + Item extraItem = extra.droppedItem.getOne(); + int extraAmount = extra.getNumberOfDropsToSpawn(); + for (int i = 0; i < amount; i++) + { + Game1.createItemDebris(extraItem.getOne(), this.TileLocation * Game1.tileSize, Game1.random.Next(0, 3), this.location); + } + } + } + if (this.location != null) { this.location.playSound("stoneCrack"); @@ -171,7 +188,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins public override Item getOne() { - OreVeinTile component = new OreVeinTile(this.data, this.info,this.resourceInfo); + OreVeinTile component = new OreVeinTile(this.data, this.info,this.resourceInfo,this.extraDrops); component.containerObject = this.containerObject; component.offsetKey = this.offsetKey; return component;