Ken Webb 2010-07-16T13:45:52Z
In the Bestiary sample Xholon app, beasts exist in a grid and perform various behaviors. Launch the app from the Bestiary blog.
Read more about Licorice, the green-eyed black cat (colored green on the Bestiary grid).
You can paste houses into the Grid node, or directly into any grid cell. Some examples that can be copied and pasted:
<BestiaryPattern x="10" y="10"> _WWWWW _W...W PDE..W _W...W _WWWWW </BestiaryPattern>
<BestiaryPattern> _____P _WWWWDWWWWWWW _W...E......W PDE.........W _W..........W _W..........W _W.........EDP _W..........W PDE.........W _W..........W _W.......E..W _WWWWWWWWDWWW _________P </BestiaryPattern>
<BestiaryPattern x="25" y="45"> _WWWWW _W...W PDE..W _W...W _W..WWWW _W.....WW _W......WWWWWWWW _W........W....W PDE.......W....W _W............EDP _W........W....W _WWWWW..WWWWWWWW ___W......W ___W......W ___WWWWWWWW </BestiaryPattern>
The following two houses are specialized cat traps. Once a cat enters the outer door, you can keep closing doors until you've herded it into the inner room. Then you can reopen all but the inner door, and wait to lure in another cat.
<BestiaryPattern x="10" y="10"> _WWWWW______WWWWWW _W...WWWWWWWW....W PDE..DDDDDDDD....W _W...WWWWWWWW....W _WWWWW______WWWWWW </BestiaryPattern>
<BestiaryPattern x="10" y="10"> ____________WWWWWW _WWWWWWWWWWWW....W PDDDDDDDDDDDD....W _WWWWWWWWWWWW....W ____________WWWWWW </BestiaryPattern>
The following .png images are how the above houses and cat traps look once they've been pasted into the grid. You can actually paste .png images directly into the grid, although it doesn't seem to work from this wiki site. You will need to use the images on the Xholon JNLP page.
Just follow these steps, using the images on the JNLP page:
You can paste in new cats with cat behaviors.
<Cat> <MovingCatbehavior/> <GrowingCatbehavior/> <FreedomOfMovementCatbehavior/> </Cat>
You can paste in multiple cats at a time, as a forest.
<_-.beasts> <Cat multiplicity="10"> <MovingCatbehavior/> <GrowingCatbehavior/> <FreedomOfMovementCatbehavior/> </Cat> </_-.beasts>
Other things you can do with the Bestiary app include:
To paste a dog into the grid, select the following text. Paste it anywhere on the grid, or paste it into the Beasts node in the Xholon GUI (the tree).
<Dog implName="lang:beanshell:inline:"><![CDATA[ import org.primordion.user.app.Bestiary.Beast; public class Dog extends Beast {} new Dog(); ]]></Dog>
The dog won't move until you add a move behavior. Paste the following as a last child of the dog.
<MovingDogbehavior implName="lang:beanshell:inline:"><![CDATA[ import org.primordion.xholon.base.IXholon; import org.primordion.user.app.Bestiary.MovingBeastBehavior; public class MovingDogbehavior extends MovingBeastBehavior { public void postConfigure() { setBeast(getParentNode()); } protected boolean canMoveThruDoor(IXholon door) { return false; } } new MovingDogbehavior(); ]]></MovingDogbehavior>
And what will happen when cats and dogs run into each other outdoors? Try this.
<ScareCatToDeathDogbehavior implName="lang:beanshell:inline:"><![CDATA[ import org.primordion.xholon.base.IXholon; import org.primordion.user.app.Bestiary.BeastBehavior; public class ScareCatToDeathDogbehavior extends BeastBehavior { public void postConfigure() { setBeast(getParentNode()); } public void act() { scareCatToDeath(); super.act(); } protected void scareCatToDeath() { IXholon node = getBeast().getFirstSibling(); while (node != null) { if ((node != this) && ("Cat".equals(node.getXhcName()))) { // scare the cat to death; make it "cat"atonic by removing movement and other behaviors removeCatBehaviors(node); return; } node = node.getNextSibling(); } } protected void removeCatBehaviors(IXholon cat) { IXholon b = cat.getFirstChild(); while (b != null) { IXholon temp = b; b = b.getNextSibling(); temp.removeChild(); } } } new ScareCatToDeathDogbehavior(); ]]></ScareCatToDeathDogbehavior>