public void BehaviorPack_AttachChildrenOnFirstUpdate() { var holder = new BehaviorHolder(new LivingConcrete()); var pack = new BehaviorPack(new List <Behavior>() { new WaitBehavior(1), new WaitBehavior(1), new WaitBehavior(1), }); holder.Attach(pack); holder.Update(0.001f); Assert.AreEqual(3, holder.AliveCount); }
static public BehaviorPack Deserialize(string root) { BehaviorPack pack = new BehaviorPack(); try { // Parse the manifest pack.Manifest = JsonConvert.DeserializeObject <Manifest>(File.ReadAllText(root + "/manifest.json"), new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore }); // Verify the icon exists. We will simply copy it later if (!File.Exists(root + "/pack_icon.png")) { throw new FileNotFoundException("Couldn't find " + root + "/pack_icon.png. Don't be a chump."); } // Entities, loot tables and trading are all optional sub directories if (Directory.Exists(root + "/entities")) { pack.Entities = ExtractEntities(root); } if (Directory.Exists(root + "/loot_tables")) { pack.LootTables = ExtractLootTables(root); } if (Directory.Exists(root + "/Trading")) { pack.Trading = ExtractTrading(root); } } catch (FileNotFoundException fileNotFound) { Console.WriteLine("Unable to Extract pack at " + root); Console.Write(fileNotFound.Message); return(null); } return(pack); }
public static bool Serialize(BehaviorPack pack, string ProjectName, string outputDirectory) { var now = DateTime.Now; string packDirectory = outputDirectory + "/" + ProjectName + "_" + now.Year.ToString() + now.Month.ToString() + now.Day.ToString() + "_" + now.Hour.ToString() + now.Minute.ToString() + now.Second.ToString(); try { Directory.CreateDirectory(packDirectory); pack.Manifest.Save(packDirectory); pack.Entities.Save(packDirectory); pack.LootTables.Save(packDirectory); pack.Trading.Save(packDirectory); } catch (Exception exception) { Console.WriteLine("Unable to create behavior pack at " + packDirectory); Console.Write(exception.Message); return(false); } return(true); }
public static void Main(string[] args) { BehaviorPack pack = new BehaviorPack("Medieval-Furniture", ID, RootPath); pack.CreateManifest() .Version(Version) .Uuid(new Guid("87509843-7615-4e49-a0db-bb83523da5a9")) .MinEngineVersion(GameVersion) .BaseGameVersion(GameVersion) .Description( "Medieval Furniture is a Bedrock Marketplace map with a huge assortment of medieval furniture!") .Authors("Gecko", "Freddy") .License("All Rights Reserved.") .Finish(); Filter query = new Filter(() => Filters.Singleton == 3); pack.CreateEntity(new Identifier(ID, "candle")) .ApplyFragment(EntityFragments.SetFakeBlock) .Finish(); pack.Save(); }
protected BaseFileFactory(BehaviorPack pack, string name, T builtObject) { BuiltObject = builtObject; Name = name; Pack = pack; }