public static object ControlAndAct(DMEnv env, Investigator inv, CommandResult <DMEnv> action) { Scenario sce = env.Sce; if (!sce.PlayerNames.TryGetValue(env.SelfId, out string selfName)) { selfName = null; } sce.Control(env.SelfId, inv.Name); env.ClearCache(); action.Env = env; object res = action.Execute(); if (selfName != null) { sce.Control(env.SelfId, selfName); } env.Save(); return(res); }