99
edits
No edit summary |
(Rm refs to IPart.Name and IPart.DisplayName) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Modding]]{{Modding Info}}{{ | [[Category:Script Modding]]{{Modding Info}}{{Modding Topic Prerequisites|Modding:C Sharp Scripting}} | ||
== Tutorial == | == Tutorial == | ||
First, include a mutations.xml in your mod that defines a new mutation. | First, include a mutations.xml in your mod that defines a new mutation. | ||
Line 22: | Line 22: | ||
using System.Collections.Generic; | using System.Collections.Generic; | ||
using System.Text; | using System.Text; | ||
using XRL.Rules; | using XRL.Rules; | ||
using XRL.Messages; | using XRL.Messages; | ||
using ConsoleLib.Console; | using ConsoleLib.Console; | ||
namespace XRL.World.Parts.Mutation | namespace XRL.World.Parts.Mutation | ||
{ | { | ||
Line 32: | Line 32: | ||
class FreeholdTutorial_Udder : BaseMutation | class FreeholdTutorial_Udder : BaseMutation | ||
{ | { | ||
public override void Register(GameObject Object) | public override void Register(GameObject Object) | ||
{ | { | ||
} | } | ||
public override string GetDescription() | public override string GetDescription() | ||
{ | { | ||
return ""; | return ""; | ||
} | } | ||
public override string GetLevelText(int Level) | public override string GetLevelText(int Level) | ||
{ | { | ||
Line 52: | Line 46: | ||
return Ret; | return Ret; | ||
} | } | ||
public override bool | public override bool WantEvent(int ID, int cascade) | ||
{ | |||
return base.WantEvent(ID, cascade) || ID == BeforeRenderEvent.ID; | |||
} | |||
public override bool HandleEvent(BeforeRenderEvent e) | |||
{ | { | ||
if (ParentObject.IsPlayer()) | if (ParentObject.IsPlayer()) | ||
Line 64: | Line 63: | ||
return true; | return true; | ||
} | } | ||
public override bool FireEvent(Event E) | public override bool FireEvent(Event E) | ||
{ | { | ||
return base.FireEvent(E); | return base.FireEvent(E); | ||
} | } | ||
public override bool ChangeLevel(int NewLevel) | public override bool ChangeLevel(int NewLevel) | ||
{ | { | ||
return true; | return true; | ||
} | } | ||
public override bool Mutate(GameObject GO, int Level) | public override bool Mutate(GameObject GO, int Level) | ||
{ | { | ||
return true; | return true; | ||
} | } | ||
public override bool Unmutate(GameObject GO) | public override bool Unmutate(GameObject GO) | ||
{ | { | ||
Line 89: | Line 88: | ||
Here's a full decompiled example of the [[Flaming Hands]] mutation from the game's source code. | Here's a full decompiled example of the [[Flaming Hands]] mutation from the game's source code. (Note that, because it's decompiled, some of the variables have very generic names, like <code>gameObject</code> instead of something more descriptive, like <code>target</code>) | ||
<syntaxhighlight lang="csharp"> | <syntaxhighlight lang="csharp"> | ||
using System; | using System; | ||
Line 107: | Line 106: | ||
{ | { | ||
return true; | return true; | ||
} | } | ||