public override void Resolve(GameLocation location, BaseFeatureSaveData featureSaveData) { Crop crop = (location.terrainFeatures[featureSaveData.featurePosition] as HoeDirt).crop; crop.dead = false; this.monitor.Log($"Restored {crop.indexOfHarvest} at position {featureSaveData.featurePosition} to life.", LogLevel.Trace); }
public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location) { FruitTreeSaveData fruitTreeSaveData = featureSaveData as FruitTreeSaveData; int numRemoved = 0; for (int i = 0; i < location.debris.Count; i++) { Debris debris = location.debris[i]; if (debris.chunkType.Value == 382 && debris.Chunks.Count == 1 && debris.Chunks[0].debrisType == 382) { if (!this.WithinRange(debris.Chunks[0].position.Value, GetCoalPosition(numRemoved, featureSaveData.FeaturePosition), Game1.tileSize * 2)) { continue; } this.monitor.Log( $"Removed dropped coal from fruit tree {numRemoved + 1}/{fruitTreeSaveData.FruitsOnTree}.", LogLevel.Trace); location.debris.RemoveAt(i); i--; numRemoved++; if (numRemoved == fruitTreeSaveData.FruitsOnTree) { return; } } } }
public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location) { int chunkType = -1; Debris.DebrisType debrisType = Debris.DebrisType.RESOURCE; int numChunks = -1; string removalMessage = ""; Random random = new Random((int)((double)Game1.uniqueIDForThisGame + (double)featureSaveData.featurePosition.X * 7.0 + (double)featureSaveData.featurePosition.Y * 11.0 + (double)Game1.mine.mineLevel + (double)Game1.player.timesReachedMineBottom)); if (random.NextDouble() < 0.005) { chunkType = 114; debrisType = Debris.DebrisType.OBJECT; numChunks = 1; removalMessage = "ancient seed"; } else if (random.NextDouble() < 0.01) { bool lessThan = random.NextDouble() < 0.5; chunkType = lessThan ? 382 : 8; debrisType = lessThan ? Debris.DebrisType.RESOURCE : Debris.DebrisType.CHUNKS; numChunks = random.Next(1, 2); removalMessage = "coal"; } else if (random.NextDouble() < 0.02) { chunkType = 92; debrisType = Debris.DebrisType.OBJECT; numChunks = random.Next(2, 4); removalMessage = "sap"; } if (chunkType != -1) { //A bug in the game code adds items to Game1.currentLocation instead of the location of the CosmeticPlant. location = Game1.currentLocation; for (int i = 0; i < location.debris.Count; i++) { Debris debris = location.debris[i]; if (debris.chunkType == chunkType && debris.debrisType == debrisType && debris.Chunks.Count == numChunks) { if (!WithinRange(featureSaveData.featurePosition, debris.Chunks[0].position / Game1.tileSize, 2)) { continue; } location.debris.RemoveAt(i); i--; monitor.Log($"Removed {removalMessage} for grass.", LogLevel.Trace); break; } } } }
public override void Resolve(GameLocation location, BaseFeatureSaveData featureSaveData) { Tree currentTree = location.terrainFeatures[featureSaveData.FeaturePosition] as Tree; TreeSaveData treeSaveData = featureSaveData as TreeSaveData; currentTree.stump.Value = false; currentTree.health.Value = treeSaveData.health; this.reflectionHelper.GetField <NetBool>(currentTree, "falling").GetValue().Value = false; this.monitor.Log($"Stopped {currentTree.GetType()} at position {featureSaveData.Feature} from falling.", LogLevel.Trace); }
public override void Resolve(GameLocation location, BaseFeatureSaveData featureSaveData) { location.terrainFeatures[featureSaveData.featurePosition] = featureSaveData.feature; monitor.Log($"Re-added {featureSaveData.feature.GetType()} at position {featureSaveData.featurePosition}.", LogLevel.Trace); //Handle duplicate items or other problems caused by re-adding the terrain feature foreach (ISideEffectHandler handler in sideEffectHandlers) { if (handler.CanHandle(featureSaveData)) { handler.Handle(featureSaveData, location); break; } } }
public override void Resolve(GameLocation location, BaseFeatureSaveData featureSaveData) { FruitTreeSaveData fruitTreeSaveData = featureSaveData as FruitTreeSaveData; FruitTree fruitTree = location.terrainFeatures[featureSaveData.featurePosition] as FruitTree; fruitTree.struckByLightningCountdown = 0; fruitTree.fruitsOnTree = fruitTreeSaveData.fruitsOnTree; monitor.Log($"Turned {fruitTree.GetType()} at position {featureSaveData.featurePosition} back to fruit.", LogLevel.Trace); //Handle the dropped coal if (sideEffectHandlers[0].CanHandle(fruitTreeSaveData)) { sideEffectHandlers[0].Handle(fruitTreeSaveData, location); } }
public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location) { Flooring f = location.terrainFeatures[featureSaveData.featurePosition] as Flooring; for (int i = 0; i < location.debris.Count; i++) { Debris debris = location.debris[i]; if (debris.item != null && debris.item.parentSheetIndex == GetParentSheetIndexForFlooring(f.whichFloor)) { if (!WithinRange(debris.Chunks[0].position / Game1.tileSize, featureSaveData.featurePosition, 2)) { continue; } monitor.Log($"Removed flooring with parentSheetIndex {debris.item.parentSheetIndex }.", LogLevel.Trace); location.debris.RemoveAt(i); return; } } }
public abstract void Handle(BaseFeatureSaveData featureSaveData, GameLocation location);
public abstract bool CanHandle(BaseFeatureSaveData featureSaveData);
public override bool CanHandle(BaseFeatureSaveData featureSaveData) { return(featureSaveData is CosmeticPlantSaveData); }
public override bool CanHandle(BaseFeatureSaveData featureSaveData) { return(featureSaveData is GrassSaveData grassSaveData && (grassSaveData.Feature as Grass).grassType.Value != 1); }
public override bool CanHandle(BaseFeatureSaveData featureSaveData) { return(featureSaveData is TreeSaveData); }
public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location) { DiggableWallSaveData diggableWallSaveData = featureSaveData as DiggableWallSaveData; this.reflectionHelper.GetField <NetInt>(location.terrainFeatures[featureSaveData.FeaturePosition], "health").GetValue().Value = diggableWallSaveData.Health; }
public override bool CanHandle(BaseFeatureSaveData featureSaveData) { return(featureSaveData is DiggableWallSaveData); }
public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location) { DiggableWallSaveData diggableWallSaveData = featureSaveData as DiggableWallSaveData; reflectionHelper.GetField <int>(location.terrainFeatures[featureSaveData.featurePosition], "health").SetValue(diggableWallSaveData.health); }
public override bool CanHandle(BaseFeatureSaveData featureSaveData) { return(featureSaveData.Feature is Flooring); }
public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location) { Tree tree = location.terrainFeatures[featureSaveData.FeaturePosition] as Tree; TreeSaveData treeSaveData = featureSaveData as TreeSaveData; //Growth stages 0 - 2 are instantly removed, so there are no side effects tree.health.Value = treeSaveData.health; if (tree.growthStage.Value >= 3) { int min = 5; int max = 8; int total = 30; //Trees at growth stage >5 spawn 2 debris with chunkType 92 each with 1 chunk (sap) //This must be a stump. if (tree.growthStage.Value >= 5) { int numToRemove = 2; for (int i = 0; i < location.debris.Count; i++) { Debris debris = location.debris[i]; if (debris.chunkType.Value == 92 && debris.debrisType.Value == Debris.DebrisType.RESOURCE && debris.Chunks.Count == 1) { if (!this.WithinRange(featureSaveData.FeaturePosition, debris.Chunks[0].position.Value / Game1.tileSize, 2)) { continue; } location.debris.RemoveAt(i); numToRemove--; i--; this.monitor.Log($"Removing sap for stage 5 stump. {numToRemove} left.", LogLevel.Trace); if (numToRemove == 0) { break; } } } min = 7; max = 10; total = 40; } else { //Trees at growth stage [3,4] spawn 1 debris with chunkType 388 with 4 chunks, each chunk has type 388 or 389 (extra wood) for (int i = 0; i < location.debris.Count; i++) { Debris debris = location.debris[i]; if (debris.chunkType.Value == 388 && debris.debrisType.Value == Debris.DebrisType.RESOURCE) { if (debris.Chunks.Count == 4 && (debris.Chunks[0].debrisType == 388 || debris.Chunks[0].debrisType == 389)) { if (!this.WithinRange(featureSaveData.FeaturePosition, debris.Chunks[0].position.Value / Game1.tileSize, 2)) { continue; } this.monitor.Log($"Removing 4 extra wood for tree stages 3 and 4.", LogLevel.Trace); location.debris.RemoveAt(i); break; } } } } //Trees of stage >3 spawn 4 chunks of up to total items, each chunk of size [min,max] with chunkType 12 and the chunks have debrisType 12 int numRemoved = 0; for (int i = 0; i < location.debris.Count; i++) { Debris debris = location.debris[i]; if (debris.chunkType.Value == 12 && debris.debrisType.Value == Debris.DebrisType.CHUNKS) { if (debris.Chunks.Count >= min && debris.Chunks.Count <= max && debris.Chunks[0].debrisType == 12) { if (!this.WithinRange(featureSaveData.FeaturePosition, debris.Chunks[0].position.Value / Game1.tileSize, 3) || numRemoved + debris.Chunks.Count > total) { continue; } this.monitor.Log( $"Removing wood, count: {debris.Chunks.Count}, total: {numRemoved + debris.Chunks.Count}/{total}.", LogLevel.Trace); numRemoved += debris.Chunks.Count; location.debris.RemoveAt(i); i--; if (numRemoved == total) { break; } } } } } }
public abstract void Resolve(GameLocation location, BaseFeatureSaveData featureSaveData);
public override bool CanHandle(BaseFeatureSaveData featureSaveData) { return(featureSaveData is FruitTreeSaveData fruitTreeSaveData && fruitTreeSaveData.FruitsOnTree != 0); }