protected void CleanseDependantCards(ReflexCard reflexCard, ProgrammingElement pendingCard) { ReflexData clip = reflex.Copy(); if (reflexCard.cardType == CardSpace.CardType.Sensor) { if (pendingCard != null) { clip.Sensor = pendingCard as Sensor; } else { clip.Sensor = null; } } if (reflexCard.cardType == CardSpace.CardType.Actuator) { // Kind of a hack here to deal with mixing Switch and Inline. If either // of these actuators are removed and replaced with the other then we need // to clear the Modifier list to prevent loops and self-referential inlines. if (pendingCard != null && reflexCard != null) { if ((pendingCard.upid == "actuator.inlinetask" && reflexCard.Card.upid == "actuator.switchtask") || (pendingCard.upid == "actuator.switchtask" && reflexCard.Card.upid == "actuator.inlinetask")) { clip.Modifiers.Clear(); } } if (pendingCard != null) { clip.Actuator = pendingCard as Actuator; } else { clip.Actuator = null; } } if (reflexCard.cardType == CardSpace.CardType.Selector) { if (pendingCard != null) { clip.Selector = pendingCard as Selector; } else { clip.Selector = null; } } reflex.Paste(clip); }
} // end of Update() /// <summary> /// What happens if the user chooses one of the pre-programmed options. /// </summary> private void Select() { if (parent.parent != null) { // Call the OnSelect() method on the pie menu. This will cause it to go through // its normal process of creating and adding the new actor to the scene. parent.parent.OnSelect(null, null); // Now, need to get the brain of the bot we just added and // stuff it full of code. Yumm, stuffed bot brains... if (shared.actor != null) { // Got brain? Brain brain = shared.actor.Brain; ActorHelp help = shared.actorHelp; if (help.programs != null && help.programs.Count > 0) { ExampleProgram program = help.programs[shared.examplesGrid.SelectionIndex.Y]; for (int page = 0; page < program.pages.Count; page++) { Task task = (Task)brain.tasks[page]; for (int r = 0; r < program.pages[page].reflexes.Length; r++) { ReflexData clip = program.pages[page].reflexes[r]; Reflex reflex = new Reflex(task); task.AddReflex(reflex); reflex.Paste(clip); } } } } Instrumentation.IncrementCounter(Instrumentation.CounterId.AddItemHelpCardInsertExample); } parent.Deactivate(); } // end of Select()