User:MomBun/Sandbox: Difference between revisions

981 bytes removed ,  21:25, 3 August 2022
editing constructor line
(some light edits to the xml side)
(editing constructor line)
Line 40: Line 40:


By default most mutations use gold/yellow for background and brown for foreground but this can be customized for any color of your choice, see [[Modding:Tiles]] and [[Modding:Colors_%26_Object_Rendering]] for further info on this.
By default most mutations use gold/yellow for background and brown for foreground but this can be customized for any color of your choice, see [[Modding:Tiles]] and [[Modding:Colors_%26_Object_Rendering]] for further info on this.
=== Constructor ===
This element should be a string argument (or a comma-delimited string of arguments, if there are more than one) to pass to the mutation's class constructor. All such arguments are received as string parameters in the mutation class constructor. For example, Corrosive Gas Generation and Sleep Gas Generation both use the same mutation class, GasGeneration. However, Mutations.xml passes a different argument to the constructor, which indicates which type of gas should be used.
Here are an example of how this is constructed from both <code>Mutations.XML</code> and <code>GasGeneration.cs</code>
<syntaxhighlight lang="xml">
<mutation Name="Sleep Gas Generation" Cost="2" MaxSelected="1" Class="GasGeneration" Constructor="SleepGas" Exclusions="Corrosive Gas Generation" BearerDescription="those who expel sleep gas" Code="bu"></mutation>
</syntaxhighlight>
<syntaxhighlight lang="csharp">
namespace XRL.World.Parts.Mutation
{
[Serializable]
public class GasGeneration : BaseMutation
{
        // In the above XML, you can see that the constructor is set to "SleepGas" which replaces the GasObject within this file
        // This means you could create a new mutation easily by copying the above xml, and replacing sleep gas with say confusion gas
public GasGeneration(string _GasObject)
{
this.GasObject = _GasObject;
this.SyncFromBlueprint();
}
</syntaxhighlight>


=== Exclusions ===
=== Exclusions ===
Line 69: Line 46:
=== BearerDescription ===
=== BearerDescription ===
It appears that this description is used in some of the random generation algorithms for villages and history in the game. For example, if a village reveres mutants with the Multiple Arms mutation, they might use the string defined in Mutations.xml ("the many-armed") to describe them in their praises or monuments.
It appears that this description is used in some of the random generation algorithms for villages and history in the game. For example, if a village reveres mutants with the Multiple Arms mutation, they might use the string defined in Mutations.xml ("the many-armed") to describe them in their praises or monuments.
=== Constructor ===
This is used by very few mutations, and its use case is as a string argument (or a comma-delimited string of arguments, if there are more than one) to pass to the mutation's class constructor. All such arguments are received as string parameters in the mutation class constructor.
It should be noted that this parameter is both advance and old, and it shouldn't be necessary and potentially avoided.
   
   
== C# Scripting, and Making The Mutation ==
== C# Scripting, and Making The Mutation ==
12

edits