private void ApplyAction(ISystemContainer systemContainer, MenuItem item, MenuAction action) { switch (item.Text) { case "Cancel": systemContainer.ActivitySystem.Pop(); return; case "Spawn": var spawnEntity = new TextInputActivity(systemContainer.ActivitySystem, "Spawn what entity?", ExecuteSpawnCommand); spawnEntity.InputText = "Monster:Bat"; systemContainer.ActivitySystem.Push(spawnEntity); break; case "Learn": var learnSkill = new TextInputActivity(systemContainer.ActivitySystem, "Learn what skill?", ExecuteLearnCommand); learnSkill.InputText = "Monster:Bat"; systemContainer.ActivitySystem.Push(learnSkill); break; case "SetMapCell": var setCell = new TextInputActivity(systemContainer.ActivitySystem, "Set cell to what?", ExecuteSetCellCommand); setCell.InputText = "Cell:Empty"; systemContainer.ActivitySystem.Push(setCell); break; case "God Mode": systemContainer.EntityEngine.AddComponent(systemContainer.PlayerSystem.Player, new GodMode()); ShowToast("GodMode enabled"); break; case "Toggle NoClip": systemContainer.PlayerSystem.Player.Get <Physical>().Passable = !systemContainer.PlayerSystem.Player.Get <Physical>().Passable; ShowToast("NoClip " + (systemContainer.PlayerSystem.Player.Get <Physical>().Passable ? "enabled" : "disabled")); break; case "Reveal Map": var map = systemContainer.MapSystem.MapCollection[systemContainer.RendererSystem.CameraPosition.Key]; ShowToast("Map revealed"); foreach (var cell in map.Cells) { map.SetSeen(cell.Key); if (cell.Value.Get <Physical>().Transparent) { foreach (var adjacentVector in Vector.GetAdjacentCellVectors()) { map.SetSeen(cell.Key + adjacentVector); } } } break; default: throw new ApplicationException($"Unhandled menu action {item.Text} in DebugMenu."); } }
private void AddCommandToMap(IMap map, MapCoordinate mapCoordinate, IEntity entityToAdd, ISystemContainer systemContainer) { string commandType; string parameters; bool paramsIncludeEntityName; if (entityToAdd.Has <MapGenerationCommand>()) { var component = entityToAdd.Get <MapGenerationCommand>(); commandType = component.Command; parameters = component.Parameters; paramsIncludeEntityName = false; } else { commandType = MapGenCommandType.Entity; parameters = null; paramsIncludeEntityName = true; } var entityName = entityToAdd.Get <Prototype>().Name; var mapAdd = entityToAdd.Get <CanAddToMap>(); if (mapAdd.SettableProperty != null) { Action <string> callback = (settablePropertyValue) => CompleteEntityCommand( map, mapCoordinate.ToVector(), commandType, Parameterise(entityName, mapAdd.SettableProperty, settablePropertyValue, parameters, paramsIncludeEntityName)); var inputBox = new TextInputActivity(systemContainer.ActivitySystem, "Enter a value for property {mapAdd.SettableProperty}:", callback); systemContainer.ActivitySystem.Push(inputBox); } else { CompleteEntityCommand(map, mapCoordinate.ToVector(), commandType, Parameterise(entityName, null, null, parameters, paramsIncludeEntityName)); } }