public T Create <T>(StateObjectOptions options, params object[] parameter) where T : StateObject { if ((options & StateObjectOptions.Temporary) == StateObjectOptions.Temporary && (options & StateObjectOptions.PlayerRelative) == StateObjectOptions.PlayerRelative) { throw new BurntimeLogicException(); } if ((options & StateObjectOptions.PlayerRelative) == StateObjectOptions.PlayerRelative) { PlayerRelativeStateLink <T> state = new PlayerRelativeStateLink <T>(); added.Add(state); for (int i = 0; i < Root.Player.Length; i++) { T obj = (T)Activator.CreateInstance(typeof(T)); obj.container = this; added.Add(obj); state.Add(obj); } UpdateDebugInfo(); return(state); } else { StateObject obj = (StateObject)Activator.CreateInstance(typeof(T)); obj.container = this; if ((options & StateObjectOptions.Temporary) != StateObjectOptions.Temporary && !temporaryMode) { added.Add(obj); UpdateDebugInfo(); } bool old = temporaryMode; temporaryMode |= (options & StateObjectOptions.Temporary) == StateObjectOptions.Temporary; obj.InitInstance(parameter); temporaryMode = old; return((T)obj); } }
public T Create <T>(StateObjectOptions options) where T : StateObject { return(Create <T>(options, null)); }