public override void Entry(IModHelper helper) { instance = this; helper.Events.Player.Warped += onWarped; // load content packs Log.info("Loading critter content packs..."); foreach (IContentPack contentPack in this.GetContentPacks()) { CritterEntry data = contentPack.ReadJsonFile <CritterEntry>("critter.json"); if (data == null) { Log.warn($" {contentPack.Manifest.Name}: ignored (no critter.json file)."); continue; } if (!File.Exists(Path.Combine(contentPack.DirectoryPath, "critter.png"))) { Log.warn($" {contentPack.Manifest.Name}: ignored (no critter.png file)."); continue; } Log.info(contentPack.Manifest.Name == data.Id ? contentPack.Manifest.Name : $" {contentPack.Manifest.Name} (id: {data.Id})"); CritterEntry.Register(data); } }
public override void Entry(IModHelper helper) { instance = this; PlayerEvents.Warped += onLocationChanged; /* * var ce = new Critters.CritterEntry(); * ce.Id = "eemie.bee"; * var a = new Critters.CritterEntry.Animation_(); * a.Frames.Add(new Critters.CritterEntry.Animation_.AnimationFrame_()); * ce.Animations.Add("test",a); * ce.SpawnConditions.Add(new Critters.CritterEntry.SpawnCondition_()); * var sl = new Critters.CritterEntry.SpawnLocation_(); * sl.Conditions.Add(new Critters.CritterEntry.SpawnLocation_.ConditionEntry_()); * ce.SpawnLocations.Add(sl); * helper.WriteJsonFile("test.json", ce); */ Log.info("Creating critter types..."); foreach (var file in Directory.EnumerateDirectories(Path.Combine(helper.DirectoryPath, "Critters"))) { var ce = helper.ReadJsonFile <CritterEntry>(Path.Combine(file, "critter.json")); if (ce == null) { Log.warn("\tFailed to load critter data for " + file); continue; } else if (!File.Exists(Path.Combine(file, "critter.png"))) { Log.warn("\tCritter " + file + " has no image, skipping"); continue; } Log.info("\tCritter type: " + ce.Id); CritterEntry.Register(ce); } }