public static ValMap ToMap(StardewValley.Object obj) { var result = new ValMap(); string type = obj.Type; if (type == "asdf") { type = obj.Name; // because, c'mon. } result.map[_type] = new ValString(type); // ToDo: limit the following to ones that really apply for this type. result.map[_name] = new ValString(obj.Name); result["displayName"] = new ValString(obj.DisplayName); result["health"] = new ValNumber(obj.getHealth()); if (obj.isLamp.Get()) { result["isOn"] = ValNumber.Truth(obj.IsOn); } result["quality"] = new ValNumber(obj.Quality); result.map[_harvestable] = ValNumber.Truth(obj.readyForHarvest.Get()); result["minutesTillReady"] = new ValNumber(obj.MinutesUntilReady); result["value"] = new ValNumber(obj.sellToStorePrice()); result["description"] = new ValString(obj.getDescription()); return(result); }
static ValMap ToMap(TerrainFeature feature) { if (feature == null) { return(null); } var result = new ValMap(); result.map[_type] = result["name"] = new ValString(feature.GetType().Name); if (feature is Tree tree) { result.map[_treeType] = new ValNumber(tree.treeType.Value); result.map[_growthStage] = new ValNumber(tree.growthStage.Value); result.map[_health] = new ValNumber(tree.health.Value); result.map[_stump] = ValNumber.Truth(tree.stump.Value); result.map[_tapped] = ValNumber.Truth(tree.tapped.Value); result.map[_hasSeed] = ValNumber.Truth(tree.hasSeed.Value); } else if (feature is HoeDirt hoeDirt) { result.map[_dry] = ValNumber.Truth(hoeDirt.state.Value != 1); var crop = hoeDirt.crop; if (crop == null) { result.map[_crop] = null; } else { ValMap cropInfo = new ValMap(); cropInfo.map[_phase] = new ValNumber(crop.currentPhase.Value); cropInfo.map[_maxPhase] = new ValNumber(crop.phaseDays.Count - 1); cropInfo.map[_mature] = ValNumber.Truth(crop.fullyGrown.Value); cropInfo.map[_dead] = ValNumber.Truth(crop.dead.Value); cropInfo.map[_harvestMethod] = ValNumber.Truth(crop.harvestMethod.Value); bool harvestable = (int)crop.currentPhase.Value >= crop.phaseDays.Count - 1 && (!crop.fullyGrown.Value || (int)crop.dayOfCurrentPhase.Value <= 0); cropInfo.map[_harvestable] = ValNumber.Truth(harvestable); //Note: we might be able to get the name of the crop // using crop.indexOfHarvest or crop.netSeedIndex var product = new StardewValley.Object(crop.indexOfHarvest.Value, 0); cropInfo.map[_name] = new ValString(product.DisplayName); result.map[_crop] = cropInfo; } } return(result); }
static ValMap ToMap(Character character) { if (character == null) { return(null); } var result = new ValMap(); result.map[_type] = new ValString("Character"); result.map[_name] = new ValString(character.Name); result["displayName"] = new ValString(character.displayName); result["facing"] = new ValNumber(character.FacingDirection); result["isEmoting"] = ValNumber.Truth(character.isEmoting); result["emote"] = new ValNumber(character.CurrentEmote); result["isMonster"] = ValNumber.Truth(character.IsMonster); return(result); }