I stopped at one point writing c# code for Unity. I can't figure it out, do you guys have any ideas?
NullReferenceException: Object reference not set to an instance of an object
ConsoleLSystem.LSystemEvaluator._rewrite (ConsoleLSystem.LSystemNode node) (at Assets/Scripts/LSystem/Program.cs:157)
This is code from line 141 to 162. Here is the full code: https://pastebin.com/tL8inez5
public class LSystemEvaluator {
public LSystemNode lSystemString { get; set; }
public List<LSystemRule> lSystemRules { get; set; }
public String[] ignored { get; set; }
public LSystemEvaluator(LSystemNode startingString, List<LSystemRule> rules) {
lSystemString = startingString;
lSystemRules = rules;
ignored = new String[0];
}
public LSystemEvaluator(LSystemNode startingString, List<LSystemRule> rules, String[] ignored) {
lSystemString = startingString;
lSystemRules = rules;
this.ignored = ignored;
}
private LSystemNode _rewrite(LSystemNode node) {
foreach (var rule in lSystemRules) {
if (rule.is_aplicable(node, ignored)) {
return rule.rewrite(node, ignored);
}
}
return new LSystemNode(node.literal);