This is extended answer to:
http://ludeon.com/forums/index.php?topic=5610.0
My original answer was ignored:
1) If you want to have arbitrary define type, you MUST extend Def.
Classes not extending Def are ignored by database assembler.
Extending ThingDef or any other "second level" defs require to use "Class" modifier, or base type constructor will be used.
2) You dont need to nest your type inside "ThingDefs" - you must define separate category, format is type name + s.
(note, ALL CAPS names will fail)
In other case database assembler will fail to find your def.
In case of "Class" modifier - def must be hosted in "base" folder, if Class points to type not accessable due to any reason - default type will be used, any additional fields will be ignored
Test type:
do require Rimgazer API to work.
Def folder will be Defs\typezs\arbitraryname.xml
3) XML def follow same rules as folders do:
Running such mod will show "REPLACED BY DEFINE" on game start.
In order to test code without running game and without usage of API - static initializer may be used.
It will be invoked early (or not invoked if something is wrong).
http://ludeon.com/forums/index.php?topic=5610.0
My original answer was ignored:
Quotefor no good reason.
You must extend thing def in your code with fields you like and define your thing def, not basic type.
1) If you want to have arbitrary define type, you MUST extend Def.
Classes not extending Def are ignored by database assembler.
Extending ThingDef or any other "second level" defs require to use "Class" modifier, or base type constructor will be used.
2) You dont need to nest your type inside "ThingDefs" - you must define separate category, format is type name + s.
(note, ALL CAPS names will fail)
In other case database assembler will fail to find your def.
In case of "Class" modifier - def must be hosted in "base" folder, if Class points to type not accessable due to any reason - default type will be used, any additional fields will be ignored
Test type:
Code Select
[EventListener("instance", "entry")]
public class typez : Def
{
public string testvalue = "NOT DEFINED";
public static typez instance;
public typez()
{
instance = this;
}
public static void entry()
{
}
[EventHandler(EventPriorityEnum.LOW)]
public void testa(GameStartedEvent e)
{
Log.Warning(testvalue);
}
}
do require Rimgazer API to work.
Def folder will be Defs\typezs\arbitraryname.xml
3) XML def follow same rules as folders do:
Code Select
<?xml version="1.0" encoding="utf-8" ?>
<typezs>
<typez>
<testvalue>REPLACED BY DEFINE</testvalue>
</typez>
</typezs>
Running such mod will show "REPLACED BY DEFINE" on game start.
In order to test code without running game and without usage of API - static initializer may be used.
It will be invoked early (or not invoked if something is wrong).
instance field is expected to store instance of listener, this is placeholder and will be removed later.